◐ Shell
clean mode source ↗

Message 134948 - Python tracker

> On a Western Windows, I suggest
>    PYTHONIOENCODING=cp1252:backslashreplace

Why using this very small charset whereas a web server can use UTF-8?

I don't think that using backslashreplace on stdout is a good idea.

> But 
>    PYTHONIOENCODING=mbcs
> is also OK, except that characters outside the Windows code
> page will be replaced with '?'

Starting at Python 3.2, you should use mbcs:replace to replace unencodable characters by '?'. The strict error handler is now strict: it raises a UnicodeEncodeError if a character is not encodable to mbcs.

Note: mbcs is the ANSI code page.

--

Using device_encoding.patch, I suppose that sys.std* streams will use the ANSI code page (mbcs, which is the code page 1252 on a Western Windows setup) in grahamd's usecase (Python program running in Apache).