web
You’re offline. This is a read only version of the page.
close
Skip to main content
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

I have the same question (0)
  • 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
    235,838 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
    235,838 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Mansi Soni – Community Spotlight

We are honored to recognize Mansi Soni as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Syed Haris Shah Profile Picture

Syed Haris Shah 9

#2
Mea_ Profile Picture

Mea_ 4

#3
howalker Profile Picture

howalker 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans