Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'debug': 0.03; 'cpython': 0.05; 'python': 0.08; 'garbage': 0.09; 'utf-8': 0.09; 'am,': 0.12; 'py3k,': 0.16; 'stdout': 0.16; 'subject:unicode': 0.16; 'utf8': 0.16; 'subject:Windows': 0.17; 'wrote:': 0.18; '3.2': 0.18; 'bytes': 0.18; 'received:209.85.210.174': 0.21; 'received:mail- iy0-f174.google.com': 0.21; "doesn't": 0.22; 'header:In-Reply- To:1': 0.22; 'module,': 0.23; 'string': 0.24; 'fix': 0.25; 'convert': 0.25; 'windows': 0.26; '(in': 0.26; 'not.': 0.28; "i'm": 0.28; 'problem': 0.29; 'print': 0.29; '(and': 0.30; 'admit': 0.30; 'differently': 0.30; 'least': 0.30; 'pretty': 0.31; 'message-id:@gmail.com': 0.31; 'does': 0.32; 'supposed': 0.32; "isn't": 0.33; 'there': 0.33; "can't": 0.33; 'header:User- Agent:1': 0.33; 'handled': 0.34; 'to:addr:python-list': 0.35; 'things': 0.35; 'encoding': 0.37; 'but': 0.37; 'received:google.com': 0.37; 'another': 0.37; 'received:209.85': 0.38; 'received:192': 0.38; 'could': 0.38; 'some': 0.38; 'received:192.168.1': 0.39; 'received:209': 0.39; 'point': 0.40; 'to:addr:python.org': 0.40; 'below': 0.62; 'demo': 0.80; 'encoding,': 0.84; 'subject:printing': 0.84; 'tricky': 0.84; '3.3': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; bh=fOy5cwSfv72ME5UQhEloa53BXgmB/5NqVh4AJvpY6Is=; b=tyaCa6dEhkzZbIRhEtyBZZwpWfSg6Xj404hm/93ca+rn2qIXE6w5gdjPaOFvd0cj4J MBHQ2u6a1AKziw40hv84Vf1uEOgj/rDxrzx6W05HIv2oXEVKTsih96gG9qziBdih2n// fZ2j4+2GYaXfKKt+1jN59zqTOygqJf3uA+1Lo= Date: Thu, 09 Feb 2012 05:19:10 -0600 From: Andrew Berg User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0) Gecko/20111220 Thunderbird/9.0 MIME-Version: 1.0 To: "comp.lang.python" Subject: Re: unicode printing on Windows References: <4f625c3f-77b0-410a-ad63-4acd1a6f1f44@hs8g2000vbb.googlegroups.com> In-Reply-To: <4f625c3f-77b0-410a-ad63-4acd1a6f1f44@hs8g2000vbb.googlegroups.com> X-Enigmail-Version: 1.3.5 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1328786372 news.xs4all.nl 6900 [2001:888:2000:d::a6]:53008 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:20066 On 2/9/2012 4:46 AM, BlueBird wrote: > Does anybody know how to fix problem 1 ? That way, I could at least > deal with programs that print UTF8 on stdout. I'm pretty sure there isn't a way. cp65001 is supposed to be UTF-8, but it doesn't work in my experience (I fed it some UTF-8 demo text and I got garbage and beeping). Python 3.3 will support cp65001, 3.2 and below do not. > Regarding point 2, I must admit even when I am the author of the > program, printing debug information (in unicode) on the stdout is a > really really tricky thing. Is there a recommendation on how to do > that properly ? Use the logging module, perhaps? It has handled encoding issues automatically, at least in my experience. In Python 3, you can convert a string to bytes from one encoding, then convert to another encoding, but Python 2 has things set up very differently (and my experience is with py3k, so I can't help much). -- CPython 3.2.2 | Windows NT 6.1.7601.17640