Max M <[EMAIL PROTECTED]> writes:

> 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.

Wrong, same error without trying to print something:

>>> x = "ä".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)
>>>

>
> Beside, you should write:
>
> u"ä".encode("latin-1") to get a latin-1 encoded string.

I know, but the question was: why does a unicode string has a encode
method, and why does it complain about decoding (which has already been
answered in the meantime).

Thomas
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to