On Sun, 19 Oct 2008 22:32:20 -0700, est wrote:

> On Oct 20, 10:48 am, Liang Chen <[EMAIL PROTECTED]> wrote:
>> Hope you all had a nice weekend.
>>
>> I have a question that I hope someone can help me out. I want to run a
>> Python program that uses Tkinter for the user interface (GUI). The
>> program allows me to type Chinese characters, but neverthelss is unable
>> to show them up on screen. The follow is some of the error message I
>> received after I logged off the program:
>>
>> "Could not write output: <type "exceptions: UnicodeEncodeError'>,
>> 'ascii' codec can't encode characters in position 0-1: ordinal not in
>> range (128)"
>>
>> Any suggestion will be appreciated.
>>
>> Sincerely,
>>
>> Liang
>>
>> Liang Chen,Ph.D.
>> Assistant Professor
>> University of Georgia
>> Communication Sciences and Special Education 542 Aderhold Hall
>> Athens, GA 30602
>>
>> Phone: 706-542-4566
> 
> Personally I call it a serious bug in python, but sadly most of python
> community members do not agree
> . It may be a internal str() that caused this issue.

No, it's not a bug, it's a correct behavior that is the most correct 
behavior, although some people might not be able to immediately grab the 
reasons why it is correct and why defining ascii as range(256) is plain 
wrong.

Anyway, if you haven't noticed, str() is capable of emitting all 
characters in range(256), e.g. str('\xff'). ascii though, doesn't allow 
that, as ascii is a 7-bit encoding, latin-1, ansi, and other ascii 
extensions are 8-bit encodings, but not ascii itself.

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

Reply via email to