Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Unanswered

ANSI File format

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.

Categories:
  • Martin Dráb Profile Picture
    Martin Dráb 225,490 Super User 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 225,490 Super User 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 225,490 Super User on at
    RE: ANSI File format

    How do you check encoding of the generated file?

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,696 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,490 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans