[Python-3000] Displaying strings containing unicode escapes
ishimoto at gembook.org
Sat Apr 19 04:35:19 CEST 2008
2008/4/17, Guido van Rossum <guido at python.org>:
> For those of us with less capable IO devices, setting the error flag
> for stdout and stderr to backslashreplace is probably the best
> solution (and it solves more problems than just repr()).
Some thought on Points I found while investigating further.
- A lot of people uses utf-8 for their encoding, such as de_DE.utf8.
In such case, backslashescape trick doesn't work.
I need to find a way to select an appropriate codec to render
unwanted characters as \uXXXX.
- io.TextIOWrapper doesn't provide interface to change encoding
and error-handler after it was created. This feature is supported
in PEP-3116, but isn't impletented at this time. Will it be
It would be nice if we have optional encoding and errors args for print()
and TextIOWrapper.write(), so people can write
print(repr(obj), 'koi8-r', 'backslashescape').
More information about the Python-3000