[issue1602] windows console doesn't print or input Unicode

Drekin report at bugs.python.org
Tue Sep 23 11:35:53 CEST 2014


Drekin added the comment:

Stefan Champailler:

The crash you see is maybe not a crash at all. First it has nothing to do with printing, the problem is reading of your input line. That explains why Python exited even before printing the traceback of the SyntaxError. If you try to read input using `sys.stdin.buffer.raw.read(100)` and type Unicode characters, it returns just empty bytes `b''`. So maybe Python REPL then thinks the input just ended and so standardly exits the interpreter.

Why are you using chcp 65001? As far as I know, it doesn't give you the ability to use Unicode in the console. It somehow helps with printing, but there are some issues. `print("\N{euro sign}")` prints the right character, but it prints additional blank line. `sys.stdout.write("\N{euro sign}")` and `sys.stdout.buffer.write("\N{euro sign}".encode("cp65001"))` does the same, but `sys.stdout.buffer.raw.write("\N{euro sign}".encode("cp65001"))` works as expected.

If you want to enter and display Unicode in Python on Windows console, try my package `win_unicode_console`, which tries to solve the issues. See https://pypi.python.org/pypi/win_unicode_console.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue1602>
_______________________________________


More information about the Python-bugs-list mailing list