Skip to main content

Notifications

Announcements

No record found.

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

  • Martin Dráb Profile Picture
    Martin Dráb 230,466 Most Valuable Professional on at
    RE: ANSI File format

    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.

  • Kannan01 Profile Picture
    Kannan01 65 on at
    RE: ANSI File format

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

  • Brajesh singh Profile Picture
    Brajesh singh 30 on at
    RE: ANSI File format

    Hi Martin,

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

  • Martin Dráb Profile Picture
    Martin Dráb 230,466 Most Valuable Professional on at
    RE: ANSI File format

    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
    Brajesh singh 30 on at
    RE: ANSI File format

    Hi Martin,

    Thanks for responding.

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

  • Martin Dráb Profile Picture
    Martin Dráb 230,466 Most Valuable Professional on at
    RE: ANSI File format

    How do you check encoding of the generated file?

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,735 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,466 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans