Changing the (codec) error handler for the stdout/stderr streams in Python 3.0

2008-09-02 Thread Jukka Aho
Just a tip for those who are only just cutting their teeth on Python 3.0 and might have encountered the same problem as I did: When a Python (3.x) program is run on a terminal that only supports a legacy character encoding - such as Latin 1 or Codepage 437 - all characters printed to stdout wi

Re: Python 3.0b2 cannot map '\u12b'

2008-09-02 Thread Jukka Aho
Terry Reedy wrote: If the terminal expects cp437 then displaying utf-8 might give some problems. My screen displays whatever Windows tells the graphics card to tell the screen to display. In OpenOffice, I can select a unicode font that displays at least everything in the BasicMultilingualPla

Re: Changing the (codec) error handler for the stdout/stderr streams in Python 3.0

2008-09-02 Thread Jukka Aho
John Nagle wrote: Python 5 is even stricter. Only ASCII (chars 0..127) can be sent to standard output by default. Python 5? (I guess I haven't been following these things enough...) Well, I would sure hope not. -- znark -- http://mail.python.org/mailman/listinfo/python-list

Customizing character set conversions with an error handler

2006-03-12 Thread Jukka Aho
When converting Unicode strings to legacy character encodings, it is possible to register a custom error handler that will catch and process all code points that do not have a direct equivalent in the target encoding (as described in PEP 293). The thing to note here is that the error handler it

Re: Customizing character set conversions with an error handler

2006-03-14 Thread Jukka Aho
Serge Orlov wrote: >> # So the question becomes: how can I make this work >> # in a graceful manner? > change the return statement with this code: > > return (substitution.encode(error.encoding,"practical").decode( >error.encoding), error.start+1) Thanks, that was a quite neat re