0

I have a list of code points (U+XXXX) that I need to convert into real characters. My code points are for UTF-8. I've scoured the previous mentions of unicode and don't see how to do that.

I can strip U+XXXX to get the number (XXXX), but then what? Some have suggested "unichr()" but that is not even recognized in Python3.

Sorry if this is basic; just started programming in Python.

wdchild
  • 51
  • 7

2 Answers2

1

Python 3.x doesn't have unichr() because Python 3.x supports Unicode strings natively.

3>> chr(int('3042', 16))
'あ'
Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
0

unichr() is replaced by chr() in python3, you can convert strings like 'U+XXXX' to characters like this:

chr(int('U+XXXX'.lstrip('U+'), 16))
zbtong
  • 319
  • 1
  • 8