Encoding/decoding: Still don't get it :-/
nospam at nospam.com
Fri Mar 13 13:56:48 CET 2009
I must be dense, but I still don't understand 1) why Python sometimes
barfs out this type of error when displaying text that might not be
Unicode-encoded, 2) whether I should use encode() or decode() to solve
the issue, or even 3) if this is a Python issue or due to APWS SQLite
wrapper that I'm using:
sql = 'SELECT id,address FROM companies'
for row in rows:
id = row
#could be 'utf-8', 'iso8859-1' or 'cp1252'
address = row
address = row.decode('iso8859-1')
address = row.decode('cp1252')
152 Traceback (most recent call last):
File "C:\zip.py", line 28, in <module>
File "C:\Python25\lib\encodings\cp437.py", line 12, in encode
UnicodeEncodeError: 'charmap' codec can't encode character u'\xc8' in
4: character maps to <undefined>
Thank you for any tip.
More information about the Python-list