handling unicode data
Fredrik Lundh
fredrik at pythonware.com
Wed Jun 28 13:16:28 EDT 2006
Filipe wrote:
> Thanks for the reply.
> Instead of:
> term = row[1]
> I tried:
> term = unicode(row[1], "iso-8859-1")
>
> but the following error was returned when printing "term":
> Traceback (most recent call last):
> File "test.py", line 11, in ?
> print term
> 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 31: character maps to <undefined>
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 ?
</F>
More information about the Python-list
mailing list