[Python-3000] Console encoding detection broken

"Martin v. Löwis" martin at v.loewis.de
Sat Aug 11 16:46:29 CEST 2007


> Feel free to add code that implements this. I suppose it would be a
> good idea to have a separate function io.guess_console_encoding(...)
> which takes some argument (perhaps a raw file?) and returns an
> encoding name, never None. This could then be implemented by switching
> on the platform into platform-specific functions and a default.

I've added os.device_encoding, which returns the terminal's encoding
if possible. If the device is not a terminal, it falls back to
locale.getpreferredencoding().

Regards,
Martin



More information about the Python-3000 mailing list