What encoding is used when initializing sys.argv?

Tim Roberts timr at probo.com
Sun Oct 2 08:15:48 CEST 2005


Neil Hodgson <nyamatongwe+thunder at gmail.com> wrote:
>
>Petr Prikryl:
>
>> ... I have discovered that
>> I do not understand what encoding should be used
>> to convert the sys.argv into unicode.
>
>    Martin mentioned CP_ACP. In Python on Windows, this can be accessed 
>as the "mbcs" codec.
>
>import sys
>print repr(sys.argv[1])
>print repr(unicode(sys.argv[1], "mbcs"))
>
>C:\bin>python glurp.py abcß•
>'abc\xdf\x95'
>u'abc\xdf\u2022'

There's another entry in my "keep this post forever" file.
-- 
- Tim Roberts, timr at probo.com
  Providenza & Boekelheide, Inc.



More information about the Python-list mailing list