Issue
temp = "à la Carte"
print type(temp)
utemp = unicode(temp)
The code above results in an error. My goal is to process the temp string and use a find to check if it contains specific string in it but cannot process due to the error:
UnicodeDecodeError: ('unknown', u'\xe0', 0, 1, '')
Solution
You need to specify the encoding: otherwise unicode()
doesn't know what \xe0
means, because that is encoding-specific.
>>> temp = "à la Carte"
>>> utemp = unicode(temp,encoding="Windows-1252")
>>> utemp
u'\xe0 la Carte'
>>> print utemp
à la Carte
Answered By - BoarGules
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.