Reputation: 15136
I have a string:
\xe2\x80\x8e\xd7\x93\xd7\x9c\xd7\x99\xd7\xaa\xe2\x80\x8e
want to achange it to unicode using python
how do I do that?
Upvotes: 0
Views: 2465
Reputation: 1123400
That is UTF-8 data already; python is showing you the string literal form.
>>> print '\xe2\x80\x8e\xd7\x93\xd7\x9c\xd7\x99\xd7\xaa\xe2\x80\x8e'.decode('utf8')
דלית
The above line decodes the UTF-8 data to a unicode
object with .decode('utf8') and prints that; the
printstatement inspects the encoding used by my terminal and re-encodes the
unicode` object so that my terminal can display it properly.
You may want to read up on Python and Unicode:
Pragmatic Unicode by Ned Batchelder
The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) by Joel Spolsky
Upvotes: 6