Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder3.xlned.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'binary': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'sys,': 0.09; 'sfxlen:2': 0.11; 'assume': 0.14; 'windows': 0.15; 'codecs': 0.16; 'expects': 0.16; 'garbage': 0.16; 'hacked': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:Unicode': 0.16; 'sys.stderr': 0.16; 'sys.stdout': 0.16; 'writable': 0.16; 'wrote:': 0.18; 'import': 0.22; 'cc:addr:python.org': 0.22; 'installation': 0.23; 'header:User- Agent:1': 0.23; 'replace': 0.24; 'unicode': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'subject:/': 0.26; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; "doesn't": 0.30; 'code': 0.31; 'that.': 0.31; 'class': 0.32; 'quite': 0.32; 'could': 0.34; 'problem': 0.35; 'but': 0.35; 'there': 0.35; 'virtual': 0.37; 'handle': 0.38; 'to:addr:python- list': 0.38; 'issue': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'skip:u 10': 0.60; 'break': 0.61; 'real': 0.63; 'received:109': 0.72 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Robin Becker Subject: Re: Unicode stdin/stdout Date: Mon, 18 Nov 2013 11:47:56 +0000 References: <5286054F.6000707@chamonix.reportlab.co.uk> <1384539385.17784.47988289.02AE655C@webmail.messagingengine.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: 109.174.168.73 User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 In-Reply-To: <1384539385.17784.47988289.02AE655C@webmail.messagingengine.com> Cc: python-ideas@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1384775291 news.xs4all.nl 15957 [2001:888:2000:d::a6]:56840 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:59855 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