Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #60598

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

Date 2013-11-27 15:31 +0700
From Hoàng Tuấn Việt <vietht2@viettel.com.vn>
Subject RE: UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 0: ordinal not in range(128)
References
Newsgroups comp.lang.python
Message-ID <mailman.3292.1385555518.18130.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

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

 

 

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

RE: UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 0: ordinal not in range(128) Hoàng Tuấn Việt <vietht2@viettel.com.vn> - 2013-11-27 15:31 +0700

csiph-web