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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

ANSI File format

(0) ShareShare
ReportReport
Posted on by 30

Hi All,

I am generating a text file through a batch class, here my file gets generated fine but with UTF-8 encoding whereas expected is ANSI format. 

I have used following code in batch class, here 0 is used which is normally for ANSI format but generates file in UTF-8 in place of ANSI when running in batch.(running this code on client works fine but fails in the batch/server) 

file = new TextIo(fileName, 'W', 0); 

Any help is appreciated.

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    237,801 Most Valuable Professional on at

    How do you check encoding of the generated file?

  • Brajesh singh Profile Picture
    30 on at

    Hi Martin,

    Thanks for responding.

    Right click the generated file and edit in notepad++. See in bottom right corner.

  • Martin Dráb Profile Picture
    237,801 Most Valuable Professional on at

    The text file doesn't (have to) contain any information about the format; Notepad++ is merely guessing based on the content.

    If you have only ASCII characters there, use Encoding > Convert to ANSI, save the file, re-open it and you'll again see UTF-8 in the bottom right corner.

  • Brajesh singh Profile Picture
    30 on at

    Hi Martin,

    Thanks for the response, it does makes sense. I guess this should convince my functional. Again thanks a lot for your help.

  • Kannan01 Profile Picture
    65 on at

    Please have a look at this blog,

    arkvarmad365fo.wordpress.com/.../

    Code should supposed to be like,

    System.Text.Encoding encoding = System.Text.Encoding::GetEncoding(1252);

    System.Byte[] byteArray = encoding.GetBytes(textFileContent);

    System.IO.MemoryStream textStream = new System.IO.MemoryStream(byteArray);

  • Martin Dráb Profile Picture
    237,801 Most Valuable Professional on at

    Kannan01, you seem to be copying this reply to all threads that mention ANSI. Plese stop doing it. Read the question first. If you have an answer, provide it. But if what you want to say have nothing to do with the topic, simply leave the thread untouched.

    I assume that the only reason why you started responding to several years old threads is to promote your blog. While relevant contribution is welcome, this may be considered spam.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans