Python converts my 8-bit strings
Fredrik Lundh
fredrik at effbot.org
Sun Jan 14 19:21:22 EST 2001
gradha at iname.com wrote:
> When I for example fed string.split with an 8 bit string, all the 8 bit
> characters get converted into what looks like utf-8 codes.
you're probably confusing the string escaping done by
the "repr" function with utf-8 encoding.
>>> a = "åäö" # 8-bit characters
>>> a # uses repr to print the result
'\206\204\224' # octal escapes for åäö
>>> print a # prints the actual contents
åäö
>>> a.split("ä")
['\206', '\224'] # uses repr for each list item
>>> for item in a.split("ä"):
... print item # prints each item as is
...
å
ö
Cheers /F
More information about the Python-list
mailing list