Magic UTF-8/Windows-1252 encodings

Random832 random832 at fastmail.com
Mon Aug 29 11:28:18 EDT 2016


On Mon, Aug 29, 2016, at 11:14, Chris Angelico wrote:
> Please don't. :) This is something that belongs in the application;
> it's somewhat hacky, and I don't see any benefit to it going into the
> language. For one thing, I could well imagine making the fallback
> encoding configurable (it isn't currently, but it could easily be),
> and that doesn't really fit into the Python notion of error handler.

Well, yeah, if anything implementing it as an error handler is a hack, I
just meant it's just the least hacky way I can think that fits in the
size "half a dozen lines".

> For another, this is a fairly rare concept - I don't see dozens of
> programs out there using the exact same strange logic, and even if
> there were, there'd be small differences

That is actually an argument in favor of putting it in the stdlib,
assuming few of those small differences are truly considered and
intentional. The main thrust of my post was that this is one of the
things that's harder than it sounds to get right due to edge cases, just
like the clip/clamp function being discussed last month.

> (eg whether or not the
> fallback is applied line-by-line). This was intended as an example of
> something that does NOT belong in the core language, and while I
> appreciate the offer of help, it's not something I'd support polluting
> the language with :)
> 
> (Plus, my server's not written in Python. Nor is the client that this
> started in, although I have considered writing a version of it in
> Python, which would in theory benefit from this.)



More information about the Python-list mailing list