Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

X++ character encoding?

(0) ShareShare
ReportReport
Posted on by 6,603

Hello.

Are there libraries available within X++ to modify the character encoding from UTF-8 to ANSI? We're sending native label format instructions to a thermal printer. The format is stored in a SQL table but once retrieved the character set or encoding is changed so when it's sent to the printer the encoded logo does not print. I used Notepad++ to view the label data prior to storing it in AX and after it retrieved for printing from AX; Notepad++ shows the working set as "ANSI" (5K file size) while the non-printing logo version is "ANSI as UTF8" (8K file size). Any help would be greatly appreciated. Thank you.

*This post is locked for comments

  • bankk Profile Picture
    6,603 on at
    RE: X++ character encoding?

    Martin, I'm very appreciative of the information you've provided. Though they didn't directly resolve my issue, as you had already cautioned me, but they did lead me ultimately to a solution. Many thanks!

  • Martin Dráb Profile Picture
    233,354 Most Valuable Professional on at
    RE: X++ character encoding?

    You can use .NET objects directly in X++ thanks to .NET Intereop from X++. It has some limitations, such as the need for fully qualified names, no support for generics, the fact that X++ doesn't understand properties etc., but it's a great tool anyway. I use it really often.

    For example, this is valid X++ code (if I didn't make any mistake):

    System.Text.UTF8Encoding utf8 = System.Text.Encoding::get_UTF8();
  • bankk Profile Picture
    6,603 on at
    RE: X++ character encoding?

    Martin, many thanks for the reference. Using TextIo and its codepage parameter, I was able to take in a UTF file, converted it to ACP, wrote it out to a file, sent the file to the printer and it worked great.

    My situation is a bit different in that I would retrieve the data from a query, then need to convert it to a different encoding, then using a StreamWriter to send the data directly to the printer. Could you enlighten me on how .Net objects would be referenced in the context of a X++ class?

  • Verified answer
    Martin Dráb Profile Picture
    233,354 Most Valuable Professional on at
    RE: X++ character encoding?

    X++ offers some limited options, e.g. the codepage parameter of TextIo's constructor. Nevertheless you can do much more with System.Text.Encoding class and its specific implementations.

    This is just a generic answer because I don't know your specific situation.

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics AX (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 100 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 48

#3
shanawaz davood basha Profile Picture

shanawaz davood basha 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans