""Martin v. Löwis"" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
LC_CTYPE=en_US.UTF-8 urxvt-X.exe&
perl -wle "binmode STDOUT, q[:utf8]; print chr() for 0x410 .. 0x430;"

Can someone help me translate it into python?

LC_CTYPE=en_US.UTF-8 urxvt-X.exe&
python -c 'for i in range(0x410, 0x431):print unichr(i),'

I would not expect it to work
from cmd.exe with python

It should work in cmd.exe, as long as the terminal's encoding supports
these characters in the first place. Use chcp.exe to find out what the
terminal's encoding is. The Python program is not completely equivalent,
as it leaves the output encoding to Python, rather than assuming a fixed
UTF-8 output encoding.

Regards,
Martin

Make sure you are using the Lucida Console font for the cmd.exe window and type the commands:

chcp 1251
python -c "print ''.join(unichr(i) for i in range(0x410,0x431))"

Output:

АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯа

UTF-8 encoding (chcp 65001) doesn't work (Python doesn't recognize it: "LookupError: unknown encoding: cp65001") and I couldn't get any Chinese code pages to work either. There is some trick I don't know, because Chinese versions of Windows can display Chinese. I have the East Asian languages installed and Chinese IME enabled, but it doesn't help for console apps.

--Mark

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

Reply via email to