[Python-Dev] Python 3.0.1 (io-in-c)

Steven Bethard steven.bethard at gmail.com
Wed Jan 28 19:40:22 CET 2009


On Wed, Jan 28, 2009 at 10:29 AM, "Martin v. Löwis" <martin at v.loewis.de> wrote:
> Notice that the determination of the specific encoding used is fairly
> elaborate:
> - if IO is to a terminal, Python tries to determine the encoding of
>  the terminal. This is mostly relevant for Windows (which uses,
>  by default, the "OEM code page" in the terminal).
> - if IO is to a file, Python tries to guess the "common" encoding
>  for the system. On Unix, it queries the locale, and falls back
>  to "ascii" if no locale is set. On Windows, it uses the "ANSI
>  code page". On OSX, it uses the "system encoding".
> - if IO is binary, (clearly) no encoding is used. Network IO is
>  always binary.
> - for file names, yet different algorithms apply. On Windows, it
>  uses the Unicode API, so no need for an encoding. On Unix, it
>  (again) uses the locale encoding. On OSX, it uses UTF-8
>  (just to be clear: this applies to the first argument of open(),
>   not to the resulting file object)

This a very helpful explanation. Is it in the docs somewhere, or if it
isn't, could it be?

Steve
-- 
I'm not *in*-sane. Indeed, I am so far *out* of sane that you appear a
tiny blip on the distant coast of sanity.
        --- Bucky Katt, Get Fuzzy


More information about the Python-Dev mailing list