web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

X++ character encoding?

(0) ShareShare
ReportReport
Posted on by 6,611

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)
  • Verified answer
    Martin Dráb Profile Picture
    240,546 Most Valuable Professional on at

    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.

  • bankk Profile Picture
    6,611 on at

    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?

  • Martin Dráb Profile Picture
    240,546 Most Valuable Professional on at

    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,611 on at

    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!

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans