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


Groups > comp.lang.python > #60598 > unrolled thread

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

Started byHoàng Tuấn Việt <vietht2@viettel.com.vn>
First post2013-11-27 15:31 +0700
Last post2013-11-27 15:31 +0700
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  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

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

FromHoàng Tuấn Việt <vietht2@viettel.com.vn>
Date2013-11-27 15:31 +0700
SubjectRE: UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 0: ordinal not in range(128)
Message-ID<mailman.3292.1385555518.18130.python-list@python.org>

[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

 

 

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web