<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Text encoding like iconv from UTF-8 to CP858 for Printer]]></title><description><![CDATA[<p dir="auto">Hello Community</p>
<p dir="auto">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.<br />
The JSON Data seams to be UTF-8, the Printer needs CP858. I solved this in Node-blue like this:</p>
<p dir="auto"><em>$str  = "Encoded Text:  ".iconv ("UTF-8" , "CP858" , $text).chr(0x0a); // Print Text and Line Feed</em></p>
<p dir="auto">Since I'm new to M5Stack / UiFLow, I tried it in Blocky:<br />
<img src="/assets/uploads/files/1639302696109-d6dda90b-1402-4a37-9324-3bb5a18cddb3-grafik.png" alt="0_1639302700866_d6dda90b-1402-4a37-9324-3bb5a18cddb3-grafik.png" class=" img-fluid img-markdown" /><br />
But I couldn't make any Settings to the "decoding" Block, so I switched to the "Python" Tab and edited as following:</p>
<p dir="auto"><em>uart2.write(str('Encoded Text').decode('utf-8').encode('cp858')+"\r\n")</em></p>
<p dir="auto">Since I'm also not familiar with Python I found those Guides:<br />
<a href="https://stackoverflow.com/questions/30662112/is-there-any-function-like-iconv-in-python" target="_blank" rel="noopener noreferrer nofollow ugc">https://stackoverflow.com/questions/30662112/is-there-any-function-like-iconv-in-python</a></p>
<p dir="auto">I also found this Forumpost: <a href="https://forum.m5stack.com/topic/1897/ui-flow-text-encode-decode" target="_blank" rel="noopener noreferrer nofollow ugc">https://forum.m5stack.com/topic/1897/ui-flow-text-encode-decode</a> wich brings me to: <a href="https://docs.python.org/3/howto/unicode.html" target="_blank" rel="noopener noreferrer nofollow ugc">https://docs.python.org/3/howto/unicode.html</a></p>
<p dir="auto">Is there someone who can help me, with even posting the Code I have to insert.<br />
Is it even possible to solve just within Blockly without changing to Python View?</p>
]]></description><link>https://community.m5stack.com/topic/3822/text-encoding-like-iconv-from-utf-8-to-cp858-for-printer</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Apr 2026 11:29:59 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/3822.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 12 Dec 2021 09:57:48 GMT</pubDate><ttl>60</ttl></channel></rss>