Kirill Simonov wrote:
> On Sun, Nov 19, 2006 at 03:27:32AM -0800, Leo Kislov wrote:
> > IDLE on Windows works fine for your example in interactive console:
> >
> > >>> name = raw_input("What's your name? ")
>
> Have you tried to use cyrillic characters in a Python string in
> interactive console? When I do it, I get the "Unsupported characters in
> input" error. For instance,
>
> >>> print "Привет"  # That's "Hi" in Russian.
> Unsupported characters in input

That works for me in Win XP English, with Russian locale and Russian
language for non-unicode programs. Didn't you say you want to avoid
unicode? If so, you need to set proper locale and language for
non-unicode programs.

>
> > And another question: are you aware of the fact that recommended way to
> > handle non-ascii characters is to use unicode type? Most of IDEs should
> > work fine with unicode.
>
> Usually using unicode type gives you much more headache than benefits
> unless you are careful enough to never mix unicode and str objects.

For a professional programmer life is full of headaches like this :)
For high school students it could be troublesome and annoying, I agree.


> Anyway, I just want the interactive console of an IDE to behave like a
> real Python console under a UTF-8 terminal (with sys.stdout.encoding ==
> 'utf-8').

Do you realize that utf-8 locale makes len() function and slicing of
byte strings look strange for high school students?

hi = u"Привет".encode("utf-8")
r = u"р".encode("utf-8")
print len(hi)        # prints 12
print hi[1] == r   # prints False
for char in hi:
    print char      # prints garbage

As I see you have several options:
1. Set Russian locale and Russian language for non-unicode programs on
Windows.
2. Introduce students to unicode.
3. Wait for python 3.0
4. Hack some IDE to make unicode friendly environment like unicode
literals by default, type("Привет") == unicode, unicode
stdin/stdout, open() uses utf-8 encoding by default for text files,
etc...

   -- Leo

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

Reply via email to