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)

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

I have the same question (1)
  • André Arnaud de Calavon Profile Picture
    301,132 Super User 2025 Season 2 on at

    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?

  • SomuAx2012 Profile Picture
    1,235 on at

    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.

  • Verified answer
    Mea_ Profile Picture
    60,284 on at

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

  • SomuAx2012 Profile Picture
    1,235 on at

    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.

  • Mea_ Profile Picture
    60,284 on at

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

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