Tuesday, October 31, 2006

Python note: the value and the display of a unicode string

Sometimes it is necessary to view the unicode encoding of a special character or to see the display of a certain unicode code. Here is some example code.

print '\xe6\x8d\xae'.decode("utf-8")
<displays the unicode character>

print repr(<the unicode character here>)
'\xe6\x8d\xae'

No comments: