Text encoding like iconv from UTF-8 to CP858 for Printer
-
Hello Community
I have an M5Stack Ink Core that receives JSON Data via MQTT. Sofar thats running. Then it prints the Data over UART to an ESC/Pos Serial Printer. That runs too, but Text has to be encoded.
The JSON Data seams to be UTF-8, the Printer needs CP858. I solved this in Node-blue like this:$str = "Encoded Text: ".iconv ("UTF-8" , "CP858" , $text).chr(0x0a); // Print Text and Line Feed
Since I'm new to M5Stack / UiFLow, I tried it in Blocky:

But I couldn't make any Settings to the "decoding" Block, so I switched to the "Python" Tab and edited as following:uart2.write(str('Encoded Text').decode('utf-8').encode('cp858')+"\r\n")
Since I'm also not familiar with Python I found those Guides:
https://stackoverflow.com/questions/30662112/is-there-any-function-like-iconv-in-pythonI also found this Forumpost: https://forum.m5stack.com/topic/1897/ui-flow-text-encode-decode wich brings me to: https://docs.python.org/3/howto/unicode.html
Is there someone who can help me, with even posting the Code I have to insert.
Is it even possible to solve just within Blockly without changing to Python View?
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login