Michael Ströder wrote:
> [EMAIL PROTECTED] wrote:
> >
> > print 'K\xc3\xb6ni'.decode('utf-8')
> >
> > and this line raised a UnicodeDecode exception.
>
> Works for me.
>
> Note that 'K\xc3\xb6ni'.decode('utf-8') returns a Unicode object. With
> print this is implicitly converted to string. The char set used depends
> on your console

And that was the problem. I'm developing with eclipse (PyDev). The
console is integrated in the development environment. As I print out an
unicode string python tries to encode it to ASCII. And since the string
contains non ASCII characters it fails. That is no problem if you are
aware of this.

My mistake was that I thought the exception was raised by my call to
decode('UTF-8') because print and decode were on the same line and I
thought print could never raise an exception. Seems like I've learned
something today.

Best regards,
Noel

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

Reply via email to