windows-1252 is based on iso-8859-1. Thus, I'd like to be able to chain
coders as follows:
bytes.decode("windows-1252-ext", else=lambda r: r.decode("iso-8859-1"))
What this "else" does is that it's a lambda, and it gets passed an
object with a decode method identical to the bytes decode method, except
that it doesn't affect already-decoded characters. In this case,
"windows-1252-ext" only includes things in the \x80-\x9F range, leaving
it up to "iso-8859-1" to handle the rest.
A similar process would happen for encoding: encode with
"windows-1252-ext", else = "iso-8859-1".
(Technically, "windows-1252-ext" isn't needed - you can use the existing
"windows-1252" and combine it with the "iso-8859-1" to get
"windows-1252-c1".)
This would be a novel way to think of encodings as not just flat
translation tables but highly composable translation tables. I have a
thing for composition.
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/