unicode strings and strings mix

Gerhard Häring gerhard at bigfoot.de
Tue Jun 18 01:35:31 EDT 2002


Roman Suzi wrote in comp.lang.python:
> Is there any way to define "default" encoding

Yes.

> so the following error will not happen?
> 
>>>> unichr(0x3345) + "×Á×Á×"
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> UnicodeError: ASCII decoding error: ordinal not in range(128)

'x' and 'A' are in the ASCII range, so this shouldn't produce an
exception. I also cannot reproduce it with sys.getdefaultencoding() ==
"ascii".

Gerhard
-- 
mail:   gerhard <at> bigfoot <dot> de       registered Linux user #64239
web:    http://www.cs.fhm.edu/~ifw00065/    OpenPGP public key id 86AB43C0
public key fingerprint: DEC1 1D02 5743 1159 CD20  A4B6 7B22 6575 86AB 43C0
reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b')))



More information about the Python-list mailing list