"bruce.who.hk" wrote:

> I just donnot know why this is wrong, you can test it in python shell:
>
> class B:
>    def __str__(self):
>        return u'\u5929\u4e0b'
>
> b=B()
> str(b)
> Traceback (most recent call last):
>  File "<input>", line 1, in ?
> UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: 
> ordinal not in 
> range(128)

the str() function is supposed to return an 8-bit string, so when you return a
Unicode string instead, it attempts to convert it using the default encoding.

try using the unicode() function instead.

</F> 



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

Reply via email to