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

  • Suggested answer
    Dharmender Profile Picture
    Dharmender 88 on at
    RE: Shift_JIS encoding in Business Central SaaS version

    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();    

  • Dharmender Profile Picture
    Dharmender 88 on at
    RE: Shift_JIS encoding in Business Central SaaS version

    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);

  • Dharmender Profile Picture
    Dharmender 88 on at
    RE: Shift_JIS encoding in Business Central SaaS version

    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?????????????

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

  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 78,032 Super User 2025 Season 1 on at
    RE: Shift_JIS encoding in Business Central SaaS version

    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

  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 997 Moderator on at
    RE: Shift_JIS encoding in Business Central SaaS version

    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?

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,409 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans