handling unicode data
Filipe
fcorreia at gmail.com
Wed Jun 28 13:45:42 EDT 2006
Fredrik Lundh wrote:
> works for me, given your example:
> >>> s = "Fran\xd8a"
> >>> unicode(s, "iso-8859-1")
> u'Fran\xd8a'
>
> what does
> print repr(row[1])
>
> print in this case ?
It prints:
'Fran\xd8a'
The error I'm getting is beeing thrown when I print the value to the
console. If I just convert it to unicode all seems ok (except for not
beeing able to show it in the console, that is... :).
For example, when I try this:
print unicode("Fran\xd8a", "iso-8859-1")
I get the error:
Traceback (most recent call last):
File "a.py", line 1, in ?
print unicode("Fran\xd8a", "iso-8859-1")
File "c:\Program Files\Python24\lib\encodings\cp437.py", line 18, in
encode
return codecs.charmap_encode(input,errors,encoding_map)
UnicodeEncodeError: 'charmap' codec can't encode character u'\xd8' in
position 4
: character maps to <undefined>
More information about the Python-list
mailing list