subprocess decoding?

Leo Kislov Leo.Kislov at gmail.com
Mon Oct 30 02:34:07 EST 2006


MC wrote:
> Hi!
>
> On win-XP (french), when I read subprocess (stdout), I must use
> differents decoding (cp1252,cp850,cp437, or no decoding), depending of
> the "launch mode" of the same Python's script:
>   - from command-line
>   - from start+run
>   - from icon
>   - by Python-COM-server
>   - etc.
>
> (.py & .pyw can also contribute)
>
>
> How to know, on the fly, the encoding used by subprocess?

You can't. Consider a Windows equivalent of UNIX "cat" program. It just
dump content of a file to stdout. So the problem of finding out the
encoding of stdout is equal to finding out encoding of any file. It's
just impossible to do in general. Now, you maybe talking about
conventions. AFAIK since Windows doesn't have strong command line
culture, it doesn't such conventions.

  -- Leo




More information about the Python-list mailing list