Dr. Dobb's Python-URL! - weekly Python news and links (Dec 30)

Max M maxm at mxm.dk
Tue Jan 4 13:43:53 EST 2005


Thomas Heller wrote:

> It seems also the error messages aren't too helpful:
> 
>>>>"ä".encode("latin-1")
> 
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> UnicodeDecodeError: 'ascii' codec can't decode byte 0x84 in position 0: ordinal not in range(128)
> 
> Hm, why does the 'encode' call complain about decoding?

Because it tries to print it out to your console and fail. While writing 
to the console it tries to convert to ascii.

Beside, you should write:

u"ä".encode("latin-1") to get a latin-1 encoded string.


-- 

hilsen/regards Max M, Denmark

http://www.mxm.dk/
IT's Mad Science



More information about the Python-list mailing list