Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Export CSV file using x++ code in UTF8 format without BOM?

(0) ShareShare
ReportReport
Posted on by 1,235

How to export CSV file using x++ in UTF8 format without BOM? 

Can someone help with sample code here? 

*This post is locked for comments

  • Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: Export CSV file using x++ code in UTF8 format without BOM?

    There is an code sample in that thread, create you file as you do using commaTextIo and then rewrite it using new encoding System.IO.File::WriteAllText(filename, System.IO.File::ReadAllText(filename), encoding);

  • SomuAx2012 Profile Picture
    SomuAx2012 1,235 on at
    RE: Export CSV file using x++ code in UTF8 format without BOM?

    System.IO.File::WriteAllText(@'C:\test.txt', "Data 123", encoding);

    This writes the file when I have simple string like one shown above. When I have multiple lines in my file I am trying concatenating multiple lines using '\n' to make one big string so I can use this code. But that results in creating a file with 0kb. Please suggest.

  • Verified answer
    Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: Export CSV file using x++ code in UTF8 format without BOM?

    Please check this thread community.dynamics.com/.../220574 discussing similar question.

  • SomuAx2012 Profile Picture
    SomuAx2012 1,235 on at
    RE: Export CSV file using x++ code in UTF8 format without BOM?

    Thanks for your reply Andre. I am trying to develop a custom transaction data CSV export. I am required to export the CSV in UTF8 format with out BOM(Byte Order Mark).

    I am exporting the csv using CommaTextIo io = new TextIo(filename, 'W', 65001);

    Now trying to figure out how I can export the same without BOM.

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 292,489 Super User 2025 Season 1 on at
    RE: Export CSV file using x++ code in UTF8 format without BOM?

    Hi SomuAx2012,

    Please elaborate. What exactly do you mean with BOM here? What data needs to be exported and where exactly do you need help?

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,489 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans