Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

X++ character encoding?

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
    bankk 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
    Martin Dráb 230,149 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
    bankk 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
    Martin Dráb 230,149 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans