Y
yc
I have a encoding problem during using of subprocess. The input is a
string with UTF-8 encoding.
the code is:
tokenize =
subprocess.Popen(tok_command,stdin=subprocess.PIPE,stdout=subprocess.PIPE,close_fds=True,shell=True)
(tokenized_text,errs) = tokenize.communicate(t)
the error is:
File "/usr/local/python/lib/python2.5/subprocess.py", line 651, in
communicate
return self._communicate(input)
File "/usr/local/python/lib/python2.5/subprocess.py", line 1115, in
_communicate
bytes_written = os.write(self.stdin.fileno(), input[:512])
UnicodeEncodeError: 'ascii' codec can't encode character u'\xa9' in
position 204: ordinal not in range(128)
How I change the default encoding from "ascii" to "utf-8"?
Ying Chen
string with UTF-8 encoding.
the code is:
tokenize =
subprocess.Popen(tok_command,stdin=subprocess.PIPE,stdout=subprocess.PIPE,close_fds=True,shell=True)
(tokenized_text,errs) = tokenize.communicate(t)
the error is:
File "/usr/local/python/lib/python2.5/subprocess.py", line 651, in
communicate
return self._communicate(input)
File "/usr/local/python/lib/python2.5/subprocess.py", line 1115, in
_communicate
bytes_written = os.write(self.stdin.fileno(), input[:512])
UnicodeEncodeError: 'ascii' codec can't encode character u'\xa9' in
position 204: ordinal not in range(128)
How I change the default encoding from "ascii" to "utf-8"?
Ying Chen