Faulty encoding settings

"Martin v. Löwis" martin at v.loewis.de
Tue Oct 17 20:17:09 CEST 2006


Neil Cerutti schrieb:
> The Cygwin binary I have (2.4.3) reports sys.stdin.encoding as
> 'US-ASCII', which is quite wrong. A Cygwin terminal uses, as far
> as I can tell, iso-8859-1. This renders the above construction
> useless if the user enters any character codes above 128.
> Using raw_input instead of readline addresses the problem by making
> it impossible to enter non-ascii text.
> 
> Please advise.

In principle, setting the LANG environment variable should help.
Unfortunately, Cygwin doesn't implement locales correctly (neither
in the Unix way, nor in the Windows way), hence Python's machinery
fails.

If you believe that a Cygwin terminal always uses Latin-1 (try
entering €, though  - it could be windows-1252 instead), you should
be able to hard-code that, by determining that it is a Cygwin
Python, or that you are running in a Cygwin terminal.

Regards,
Martin



More information about the Python-list mailing list