os.system: string encoding

P

Peter Kleiweg

How do I set the string encoding for os.system to anything other then UTF-8?


(peter) ~ echo $LANG
nl_NL@euro
(peter) ~ python3
Python 3.1.1 (r311:74480, Oct 2 2009, 11:50:52)
 
M

Martin v. Loewis

Am 25.06.2010 17:13, schrieb Peter Kleiweg:
How do I set the string encoding for os.system to anything other then UTF-8?

You shouldn't have to set it, as it should use your locale's encoding.
In 3.1.2, it will.

For the moment, you can encode the string explicitly, and pass a byte
string.

Regards,
Martin
 
P

Peter Kleiweg

Martin v. Loewis schreef op de 27e dag van de zomermaand van het jaar 2010:
Am 25.06.2010 17:13, schrieb Peter Kleiweg:

You shouldn't have to set it, as it should use your locale's encoding.
In 3.1.2, it will.

For the moment, you can encode the string explicitly, and pass a byte
string.

That doesn't work

Python 3.1.1 (r311:74480, Oct 2 2009, 11:50:52) Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: must be string, not bytes
 
M

Martin v. Loewis

For the moment, you can encode the string explicitly, and pass a byte
That doesn't work

I only have 3.1.2 to test at the moment. I suggest trying to use the
subprocess module instead.

Regards,
Martin
 
L

Lawrence D'Oliveiro

Peter Kleiweg said:
How do I set the string encoding for os.system to anything other then
UTF-8?

Works for me (on Debian Unstable):

ldo@theon:~> echo $LC_ALL
en_NZ.utf8
ldo@theon:~> python3.1
Python 3.1.2 (r312:79147, May 8 2010, 13:27:06)
[GCC 4.4.4] on linux2
Type "help", "copyright", "credits" or "license" for more information. €
0
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,172
Messages
2,570,933
Members
47,472
Latest member
blackwatermelon

Latest Threads

Top