Unicode getting in the way...

Martin von Loewis loewis at informatik.hu-berlin.de
Thu Mar 8 05:29:03 EST 2001


"Dan Maas" <dmaas at dcine.com> writes:

> At some random point in my code, foo changes from being a
> 'string' object to a  'unicode' object. Subsequent attempts
> to manipulate foo fail with a UnicodeError (ASCII decoding
> error, ordinal not in range(128)).
> 
> How can I stop this from happening? I just need raw 8-bit
> strings everywhere!

Apparently, you add a Unicode object to the string at some point. You
need to find the place where that happens, and convert the Unicode
object into a byte string. Python cannot do that for you, since you
need to specify what encoding you want to use.

Regards,
Martin




More information about the Python-list mailing list