Bug in python (Weird UnicodeDecodeError)

Scott David Daniels scott.daniels at acm.org
Tue Dec 13 16:49:36 EST 2005


dbri.tcc at gmail.com wrote:
> ... partway through the database results I get something like this:
>     for item in list:
> UnicodeDecodeError : 'utf8' codec can't decode bytes in position 26-28:
> invalid data
It is quite likely that the position is not what you think it is.
For one of the bad strings, print:
     repr(thestring), [ord(ch) for ch in thestring]
This may give you a clue (and will definitely help us help you).
So far you have explained to us why you are confused, but have
not explained (with enough precision) what is going wrong in a
way that anyone can help you.  I suspect that "position" is more
like a Unicode data point than the position within the string you
are feeding.

Show us the code doing the translation and the data it is being fed,
and we can help.

--Scott David Daniels
scott.daniels at acm.org



More information about the Python-list mailing list