communicate with a process in utf-8 on a cp1252 consoless

Posted by Mapad on Stack Overflow See other posts from Stack Overflow or by Mapad
Published on 2009-11-26T13:31:19Z Indexed on 2010/03/16 23:01 UTC
Read the original article Hit count: 131

Filed under:
|
|
|

I need to control a program by sending commands in utf-8 encoding to its standard input. For this I run the program using subprocess.Popen():

proc = Popen("myexecutable.exe", shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)
proc.stdin.write(u'ééé'.encode('utf_8'))

If I run this from a cygwin utf-8 console, it works. If I run it from a windows console (encoding ='cp1252') this doesn't work. Is there a way to make this work without having to install a cygwin utf-8 console on each computer I want it to run from ? (NB: I don't need to output anything to console)

© Stack Overflow or respective owner

Related posts about python

Related posts about utf-8