web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Shift_JIS encoding in Business Central SaaS version

(0) ShareShare
ReportReport
Posted on by 88

Hi All,

 

In BC SaaS version, it is only possible to export a file with TextEncoding::Windows/UTF-8/ASCII.

But one our customer want to export file with specific encoding type (shift_jis) and which is possible in NAV and BC Onprem versions with help of .NET variables. Is there any workaround to achieve below source code in BC SaaS version?

 

//[DotNet Variable: FilestreamWriter , FileEncoding ]

TextFile.WRITEMODE(TRUE);

TextFile.TEXTMODE(TRUE);

TextFile.CREATE(FileName);

TextFile.CREATEOUTSTREAM(FileOutStream);

FilestreamWriter := FilestreamWriter.StreamWriter(FileOutStream,FileEncoding.GetEncoding('shift_jis'));

Thanks

I have the same question (0)
  • Suggested answer
    Inge M. Bruvik Profile Picture
    1,111 Moderator on at

    In BC Online there is an encoding codeunit avalible in the system app.T

    The codeunit 1406 called Encoding. Takes a text and a Destination codepage as parameter. Maybe you can use that function?

  • Suggested answer
    YUN ZHU Profile Picture
    95,718 Super User 2025 Season 2 on at

    Hi, I think what Inge mentioned should be codeunit 1486 "Encoding". You can have a try.

    pastedimage1683507883482v1.png

    pastedimage1683507936231v2.png

    And, some info in MS Docs:

    File Handling and Text Encoding
    https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-file-handling-and-text-encoding

    Hope this helps as well.

    Thanks.

    ZHU

  • Dharmender Profile Picture
    88 on at

    Thanks ZHU for your suggestion.

    My basic requirement is to export data from BC SaaS with Shift-JIS encoding text file.

    Tried with the following code but Japanese characters showing ????? format.

    //65001:codepage for utf-8, 932: codepage for shift_jis.

    Encoding.Convert(65001, 932, HeaderLineJPText);

    -----------------------------------------------------------------------------

    12100077777777?)??????????                            02180005?????????????

    -----------------------------------------------------------------------------

  • Dharmender Profile Picture
    88 on at

    Thank Bruvik for your suggestion.

    Tried encoding codeunit but still it not working. exported file showing ???

    //65001:codepage for utf-8, 932: codepage for shift_jis.

    Encoding.Convert(65001, 932, HeaderLineJPText);

  • Suggested answer
    Dharmender Profile Picture
    88 on at

    Thanks all for your time and suggestions. Achieved final result with following code.

    //DotNetEncoding: Codeunit DotNet_Encoding;

    //DotNetStreamWriter: Codeunit DotNet_StreamWriter;

    //932 : codepage for shift-jis encode

    //Fine Code

    TempBlob.CreateOutStream(OutStr);

    DotNetEncoding.Encoding(932);                                                    

    DotNetStreamWriter.StreamWriter(OutStr, DotNetEncoding);

    DotNetStreamWriter.WriteLine(HeaderLineJPText);            

    DotNetStreamWriter.Flush();  

    //Bad code

    TempBlob.CreateOutStream(OutStr);

    DotNetEncoding.Encoding(932);                            

    DotNetStreamWriter.StreamWriter(OutStr, DotNetEncoding);

    OutStr.Write(HeaderLineJPText);                              

    OutStr.WriteText();    

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,664

#2
YUN ZHU Profile Picture

YUN ZHU 960 Super User 2025 Season 2

#3
Jainam M. Kothari Profile Picture

Jainam M. Kothari 773 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans