Convert UTF-8 octets to unicode code points

后端 未结 4 1140
粉色の甜心
粉色の甜心 2020-12-09 05:42

I have a set of UTF-8 octets and I need to convert them back to unicode code points. How can I do this in python.

e.g. UTF-8 octet [\'0xc5\',\'0x81\'] should be con

4条回答
  •  情歌与酒
    2020-12-09 06:18

    l = ['0xc5','0x81']
    s = ''.join([chr(int(c, 16)) for c in l]).decode('utf8')
    s
    >>> u'\u0141'
    

提交回复
热议问题