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

Announcements

No record found.

News and Announcements icon
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,165 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
    99,598 Super User 2026 Season 1 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,028 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,121 Super User 2026 Season 1

#3
Teagen Boll Profile Picture

Teagen Boll 669 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans