Windows, subprocess.Popen & encodage

Méta-MCI enleverlesX.XmcX at XmclaveauX.com
Tue May 8 02:43:04 EDT 2007


Hi!

>From long time, I have problems with strings return, in Windows, by 
subprocess.Popen / stdout.read()

Last night, I found, by hazard, than if the second byte equal 0, it's, 
perhaps, the solution.
With a code like this:

     p=subprocess.Popen(u850("cmd /u/c ....
     tdata=p.stdout.read()
     if ord(tdata[1])==0:
         data=tdata.decode('utf-16')
     else:
         data=tdata.decode('cp850')

Diffrents scripts seem run OK. I had try with:
   - common dir
   - dir on unicode-named-files
   - ping
   - various commands


But, I don't found anything, in any documentations, on this.



Sombody can confirm?   Am I misled?  Am I right?



* sorry for my bad english*


@-salutations

Michel Claveau




More information about the Python-list mailing list