UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 0: ordinal not in range(128)

Hoàng Tuấn Việt vietht2 at viettel.com.vn
Wed Nov 27 03:31:31 EST 2013


Hi Fabio,

 

I cannot see your reply in python-list until I search this question on Internet again.

 

I try (username.encode('utf-8') + '\r') and the problem is fixed.

 

Thank you very much.

 

Viet

 

>You should be able to reproduce the same behavior on PyDev if in your run configuration you select the encoding of the console to be ascii (run > run configurations > select run configuration > common > set >encoding to us-ascii).

> 

>My guess is that you have the problem because the username has non-ascii chars -- and you're receiving it as an unicode and not a string... so, you have to do encode it properly to a string before writing to the >connection (i.e.: username.encode('utf-8') + '\r' -- although the encoding may have to be a different one and not utf-8).

> 

>Cheers,

> 

>Fabio

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20131127/6f7cdd82/attachment.html>


More information about the Python-list mailing list