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

Announcements

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,120
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
    239,670 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,120 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
    239,670 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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

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

#1
André Arnaud de Calavon Profile Picture

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

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 635 Super User 2026 Season 1

#3
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 547

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans