Re: A python IDE for teaching that supports cyrillic i/o
- From: Kirill Simonov <xi@xxxxxxxxxxx>
- Date: Mon, 20 Nov 2006 13:29:44 +0200
On Sun, Nov 19, 2006 at 02:54:33PM -0800, Leo Kislov wrote:
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,
Unsupported characters in inputprint "Привет" # That's "Hi" in Russian.
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.
Thanks. After I set Russian language for non-unicode programs, the
`print "Привет"` expression started to work correctly.
On the other hand,
>>> print u"Привет"
doesn't display "Привет". The output looks like a CP1251-encoded string
was displayed using the latin1 character set.
It seems that the interactive interpreter in IDLE uses the CP1251
codepage.
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
No, it slipped off my mind...
As I see you have several options:
1. Set Russian locale and Russian language for non-unicode programs on
Windows.
I guess I will go this route. Looks that IDLE works reasonable well in
CP1251 locale.
Thanks,
Kirill
.
- References:
- A python IDE for teaching that supports cyrillic i/o
- From: Kirill Simonov
- Re: A python IDE for teaching that supports cyrillic i/o
- From: Leo Kislov
- Re: A python IDE for teaching that supports cyrillic i/o
- From: Kirill Simonov
- Re: A python IDE for teaching that supports cyrillic i/o
- From: Leo Kislov
- A python IDE for teaching that supports cyrillic i/o
- Prev by Date: Re: fileinput.input('test.txt') => ERROR: input() already active
- Next by Date: Re: a few extensions for the itertools
- Previous by thread: Re: A python IDE for teaching that supports cyrillic i/o
- Next by thread: Re: A python IDE for teaching that supports cyrillic i/o
- Index(es):
Relevant Pages
|
Loading