[Python-ideas] Unicode stdin/stdout (was: Re: python 3.3repr)
drekin at gmail.com
drekin at gmail.com
Sat Nov 16 13:17:00 CET 2013
Hello.
> Of course, the real solution to this issue is to replace sys.stdout on windows with an object that can handle Unicode directly with the WriteConsoleW function - the problem there is that it will break code that expects to be able to use sys.stdout.buffer for binary I/O. I also wasn't able to get the analogous stdin replacement class to work with input() in my attempts.
You can look on the result of ReadConsoleW function call as on sequence of bytes encoding a string in utf-16-le. So the call can be made in custom raw io object and standard hierarchy text io –> buffered io –> raw io can be formed. See http://bugs.python.org/file31756/streams.py . It works also for stdin and input(). Only problem is that Python interactive REPL doesn't use sys.stdin object for input. See http://bugs.python.org/issue1602 and http://bugs.python.org/issue17620 for details.
Regards, Drekin
More information about the Python-ideas
mailing list