[RELEASED] Python 3.1 final
benjamin at python.org
Sun Jun 28 17:25:13 EDT 2009
Nobody <nobody <at> nowhere.com> writes:
> On Sun, 28 Jun 2009 19:21:49 +0000, Benjamin Peterson wrote:
> >> Yes, but do you get back the original byte strings? Maybe I'm missing
> >> something, but my impression is that this is still an issue for the email
> >> module as well as command-line arguments and environment variables.
> > The email module is, yes, broken. You can recover the bytestrings of
> > command-line arguments and environment variables.
> 1. Does Python offer any assistance in doing so, or do you have to
> manually convert the surrogates which are generated for unrecognised bytes?
fs_encoding = sys.getfilesystemencoding()
bytes_argv = [arg.encode(fs_encoding, "surrogateescape") for arg in sys.argv]
> 2. How do you do this for non-invertible encodings (e.g. ISO-2022)?
What's a non-invertible encoding? I can't find a reference to the term.
More information about the Python-list