encoding of sys.argv ?

Neil Cerutti horpner at yahoo.com
Mon Oct 23 13:43:22 EDT 2006


On 2006-10-23, Jiba <jibalamy at free.fr> wrote:
> Hi all,
>
> I am desperately searching for the encoding of sys.argv.
>
> I use a Linux box, with French UTF-8 locales and an UTF-8
> filesystem. sys.getdefaultencoding() is "ascii" and
> sys.getfilesystemencoding() is "utf-8". However, sys.argv is
> neither in ASCII (since I can pass French accentuated
> character), nor in UTF-8. It seems to be encoded in "latin-1",
> but why ?

It will most likely be in the encoding of the terminal from which
you call Python, in other words, sys.stdin.encoding.  Your only
hope of accepting non-US-ASCII command line arguments in this
manner is that sys.stdin.encoding is divined correctly by Python.

-- 
Neil Cerutti
Facts are stupid things. --Ronald Reagan



More information about the Python-list mailing list