web
You’re offline. This is a read only version of the page.
close
Skip to main content
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,108
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)
  • Verified answer
    Martin Dráb Profile Picture
    236,166 Most Valuable Professional on at
    Shift-JIS encoding in fixed length text file using X++
    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.
  • Sangram Shinde Profile Picture
    2,108 on at
    Shift-JIS encoding in fixed length text file using X++
    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));
     
     
     
     
  • Martin Dráb Profile Picture
    236,166 Most Valuable Professional on at
    Shift-JIS encoding in fixed length text file using X++
    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.

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,340

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 835 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 640 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans