Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32
bit (Intel)] on win32
>>> print sys.getdefaultencoding()
ascii
Regards.
The problem is this code:
# -*- coding: cp1252 -*-
>>> u'\xe0\xe8\xec\xf2\xf9'.decode('latin1')
Traceback (most recent call last):
File "<pyshell#15>", line 1, in ?
u'\xe0\xe8\xec\xf2\xf9'.decode('latin1')
UnicodeEncodeError: 'ascii' codec can't encode
characters in position 0-4: ordinal not in range(128)
I think this is a bug.
Indeed this is the behaviour of str.encode:
>>> '\xe0\xe8\xec\xf2\xf9'.encode('latin1')
Traceback (most recent call last):
File "<pyshell#12>", line 1, in ?
'\xe0\xe8\xec\xf2\xf9'.encode('latin1')
UnicodeDecodeError: 'ascii' codec can't decode byte
0xe0 in position 0: ordinal not in range(128)
But this makes no sense for Unicode strings!
I think unicode.decode should be a no-op.
Manlio Perillo
|