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 :
Finance | Project Operations, Human Resources, ...
Answered

Shift-JIS encoding in fixed length text file using X++

(1) ShareShare
ReportReport
Posted on by 2,114
Hi Techies,
 
We've got a requirement where we need to prepare a fixed length file using X++ with Shift-JIS, encoding.
Below is the sample code for reference -
 
_fileData, is a string, which creates a fixed length data and using stream writer we are writing it in file.
using (var stream = new MemoryStream())            {          var writer = new StreamWriter(stream);         writer.Write(_fileData);                    writer.Flush();          stream.Position = 0;} 


Whereas, we tried placing 'System.Text.Encoding::GetEncoding(932)' , but it didn't work? If anyone has worked on such requirement, your thoughts would be insightful !
 
var writer = new StreamWriter(stream, System.Text.Encoding::GetEncoding(932));

 

Thanks in advance !
I have the same question (0)
  • Martin Dráb Profile Picture
    238,955 Most Valuable Professional on at
    Please never describe a problem by mere "it didn't work". Instead, tell us what happened.
     
    Also, consider giving us code that others can run and reproduce your problem. It doesn't apply to your current snippet, because it doesn't contain population of stream variable.
  • Sangram Shinde Profile Picture
    2,114 on at
    Apologies Sir Martin for incomplete info.
    After adding below code, we are able to see the file with 'ANSI' tag as shown in below screen shot, which created the confusion, but after checking more, encoding - ANSI vs SHIFT JIS vs UTF-8 in c# - Stack Overflow
    it seems, tag (ANSI) will show as per the system configuration, which may appear as Shift-JIS, could you share more light on this, which understanding is correct?
     
    var writer = new StreamWriter(stream, System.Text.Encoding::GetEncoding(932));
     
     
     
     
  • Verified answer
    Martin Dráb Profile Picture
    238,955 Most Valuable Professional on at
    If the file doesn't contain any identification of encoding (such as Unicode BOM), the text editor can only guess what the encoding may be, therefore this is nothing to rely on. Select encoding manually (Encoding > Character sets > Japanese > Shift-JIS in Notepad++, which you seem to be using) to see whether the file looks correct if interpreted as Shift-JIS.

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!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 531

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 402 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 257 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans