Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #20065 > unrolled thread
| Started by | BlueBird <phil@freehackers.org> |
|---|---|
| First post | 2012-02-09 02:46 -0800 |
| Last post | 2012-02-09 13:21 -0500 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.lang.python
unicode printing on Windows BlueBird <phil@freehackers.org> - 2012-02-09 02:46 -0800
Re: unicode printing on Windows Andrew Berg <bahamutzero8825@gmail.com> - 2012-02-09 05:19 -0600
Re: unicode printing on Windows Terry Reedy <tjreedy@udel.edu> - 2012-02-09 13:21 -0500
| From | BlueBird <phil@freehackers.org> |
|---|---|
| Date | 2012-02-09 02:46 -0800 |
| Subject | unicode printing on Windows |
| Message-ID | <4f625c3f-77b0-410a-ad63-4acd1a6f1f44@hs8g2000vbb.googlegroups.com> |
Hi, The question is not totally related to Python but there is a strong connection. Everytime that I try to debug some python programs under Windows, I encounter the issue that things printed on the console simply break the program because : 1. My windows console does not support UTF8 2. Things printed by the program on the stdout / stderr do not necessarily use sys.getpreferredencoding() so break with UnicodeError. Does anybody know how to fix problem 1 ? That way, I could at least deal with programs that print UTF8 on stdout. 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 ? Important information : I am using Python 2.5 cheers, Philippe
[toc] | [next] | [standalone]
| From | Andrew Berg <bahamutzero8825@gmail.com> |
|---|---|
| Date | 2012-02-09 05:19 -0600 |
| Message-ID | <mailman.5579.1328786372.27778.python-list@python.org> |
| In reply to | #20065 |
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
[toc] | [prev] | [next] | [standalone]
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2012-02-09 13:21 -0500 |
| Message-ID | <mailman.5601.1328811743.27778.python-list@python.org> |
| In reply to | #20065 |
On 2/9/2012 5:46 AM, BlueBird wrote: > Hi, > > The question is not totally related to Python but there is a strong > connection. Everytime that I try to debug some python programs under > Windows, I encounter the issue that things printed on the console > simply break the program because : > 1. My windows console does not support UTF8 The IDLE shell (now) is friendlier to unicode, supporting the entire BMP. So you may have more success loading into an IDLE editor and running from there with F5. Or perhaps execfile in the shell (I never tried this). Of course, import and pdb in the shell work. This all depends on what 'debugging' means to you. > Important information : I am using Python 2.5 I don't know if IDLE was different then. -- Terry Jan Reedy
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web