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
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!
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();
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?
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.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156