Chinese language support of Python?

Martin v. Loewis martin at v.loewis.de
Sun Jul 7 04:08:17 EDT 2002


Boudewijn Rempt <boud at valdyas.org> writes:

> I don't think that's going to work (caveat: I use PyQt which has different
> conventions). If you absolutely want to have Chinese characters in your
> source files*, you can do something like the following**:
> 
> root.title(unicode('伱好?', 'utf-8')

The problem is that this won't work in IDLE.

> * Actually I still think it would be great to be able to have sourcefiles
> in utf-8, not limited to unicode strings. I want to type:

This can only happen after PEP 263 is adopted, otherwise, it will be
difficult to find out which bytes denote letters. Even then, it will
be difficult to find out when two identifiers are equal - __dict__
dictionaries would need to allow Unicode strings as keys.

Notice that this only a step towards what ChinesePython is doing,

http://www.python.org/doc/NonEnglish.html#chinese

which changes all the keywords to allow you to type Chinese-based
keywords instead of the traditional English-based keywords.

> That this would make my source code unreadable for a lot other people, tant
> pis, I still would like the power. Just as I want the power to do a quick
> sys.setAppDefaultEncoding('utf-8') to make sure this application sees all
> its strings as encoded in utf-8.

It could not guarantee this. If you read a byte string from some
external source, it might well not be UTF-8, and Python had no way to
find out.

Regards,
Martin




More information about the Python-list mailing list