How does Python get the value for sys.stdin.encoding?
Anssi Saari
as at sci.fi
Thu Aug 12 09:42:17 EDT 2010
Benjamin Kaplan <benjamin.kaplan at case.edu> writes:
> Sys.stdin and stdout are files, just like any other. There's nothing
> special about them at compile time. When the interpreter starts, it
> checks to see if they are ttys. If they are, then it tries to figure
> out the terminal's encoding based on the environment.
Just a related question, is looking at sys.stdin.encoding the proper
way of doing things? I've been working on a script to display some
email headers, some of which are encoded in MIME to various charsets.
Until now I have used whatever locale.getdefaultlocale() returns as
the target encoding, since "it seemed to work". Although on one
computer the call returns ISO-8859-15 even though I don't quite
understand why.
More information about the Python-list
mailing list