title: How to convert string from UCS2 to readable text
body: <p>I need to convert the given string from UCS2 to readable text. How can I implement this in Python and C++ Arduino without using third-party modules.</p>
  <pre><code>st =&quot;041204410451002004210443043F04350440003A00200031003300200413041100200438043D044204350440043D043504420430002C00200031003500300020043C0438043D00200030002004410435043A0020043D04300020043C043E04310438043B044C043D044B043500200420041A00200434043E002000320037002E00300038002E00320032&quot;
  </code></pre>
  <p>I found this code, but it does not work as it should. Can you please tell me how to do the correct calculation?</p>
  <pre><code>def con():
      UCS2ToChar = ''
      res = &quot;&quot;
      arrUCS2 = list(&quot;0412&quot;)
  
      if (arrUCS2[1] == '4'):
          if (arrUCS2[2] == '0'): UCS2ToChar = 89
          elif (arrUCS2[2] == '1'): UCS2ToChar = 64
          elif (arrUCS2[2] == '2'): UCS2ToChar = 48
          elif (arrUCS2[2] == '3'): UCS2ToChar = 32
          elif (arrUCS2[2] == '4'): UCS2ToChar = 16
          elif (arrUCS2[2] == '4'): UCS2ToChar = 73
  
          if (int(arrUCS2[3]) &gt; int('9')):
              UCS2ToChar -= (int(arrUCS2[3]) - 55)
          else:
              UCS2ToChar -= (int(arrUCS2[3]) - int('0'))
          UCS2ToChar = (int(UCS2ToChar))
          res += (chr(UCS2ToChar))
          print(res)
  con()
  </code></pre>
  <p>If you do this print (ord ('B')) then the code of the letter (which, in theory, is encrypted there) will be different from that obtained using this enumeration.</p>