Skip to content Skip to sidebar Skip to footer

Python Unicode, Have Unicode Number In Normal String, Want To Print Unicode

Im using IDLE on windows 7. When I run the following code uni = u'\u4E0D' binary = uni.encode('utf-8') print binary It prints the unicode character with number 4E0D correctly. But

Solution 1:

s = '4e0d'
c = unichr(int(s, 16))

Solution 2:

Not the quickest way, but readable at least:

s = "4E0D"
orig = "\u" + s
uni = orig.decode('cp1252')

Post a Comment for "Python Unicode, Have Unicode Number In Normal String, Want To Print Unicode"