popen and unicode
Stuart McGraw
smcg4191 at frii.RemoveThisToReply.com
Wed May 26 18:13:38 EDT 2004
Thanks for the info, Neil.
I tried using spawnv too, with slightly different but still
unsuccessful results. With spawn, the spawned program
is receiving unicode characters, but non-ascii range
characters have been converted to unicode "?" before
the spawned program receives them. .
I looked into calling the Windows API using Ctypes but how
to convert a C *File pointer returned by Windows' popen()
to something that Python could use, was not at all clear to
me. I guess it would be fairly simple with a C extension, but
that is a bit beyond me at this point.
So, to my surprise, I conclude that it is not currently feasible
to work with the process stuff and unicode file names on a
Windows machine with Python. I would still love to find out
I am wrong though. And I think this info should be in the
documentation. It would have saved me a couple day's
work.
"Neil Hodgson" <nhodgson at bigpond.net.au> wrote in message news:X6Psc.10837$L.2358 at news-server.bigpond.net.au...
> Stuart McGraw:
>
> > Does os.popen() work with unicode strings containing characters outside
> > the ASCII range? (I think I answered my own question, above.)
>
> There is no Unicode support in the current implementation of popen. This
> could be added in a similar way to the Unicode file name support but it is
> more work than I currently have time for. If you are interested in fixing
> this, the code is in dist/src/Modules/posixmodule.c _PyPopenCreateProcess.
>
> > How can I call popen to process non-ascii filenames on a Windows box?
> > Is there anything else I could use (e.g. spawn) that will work with
> unicode
> > filnames?
>
> You can use ctypes to call the underlying platform APIs.
>
> Neil
>
>
More information about the Python-list
mailing list