Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #59855

Re: Unicode stdin/stdout

From Robin Becker <robin@reportlab.com>
Subject Re: Unicode stdin/stdout
Date 2013-11-18 11:47 +0000
References <5286054F.6000707@chamonix.reportlab.co.uk> <1384539385.17784.47988289.02AE655C@webmail.messagingengine.com>
Newsgroups comp.lang.python
Message-ID <mailman.2837.1384775291.18130.python-list@python.org> (permalink)

Show all headers | View raw


On 15/11/2013 18:16, random832@fastmail.us wrote:
> 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.
>
I started to use this on my windows installation


#c:\python33\lib\site-packages\sitecustomize.py
import sys, codecs
sys.stdout = codecs.getwriter("utf-8")(sys.stdout.detach())
sys.stderr = codecs.getwriter("utf-8")(sys.stderr.detach())

which makes them writable with any unicode; after many years I am quite used to 
garbage appearing in the windows console.

Unfortunately the above doesn't go into virtual environments, but I assume a 
hacked site.py could do that.
-- 
Robin Becker

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Unicode stdin/stdout Robin Becker <robin@reportlab.com> - 2013-11-18 11:47 +0000

csiph-web