Prev: python source code -> win/dos executable (on linux)
Next: Continuously running scripts question
From: Peter Kleiweg on 25 Jun 2010 11:13 How do I set the string encoding for os.system to anything other then UTF-8? (peter) ~ echo $LANG nl_NL(a)euro (peter) ~ python3 Python 3.1.1 (r311:74480, Oct 2 2009, 11:50:52) >>> '\N{EURO SIGN}' '�' >>> import os >>> os.system('echo \N{EURO SIGN}') �?� 0 >>> -- Peter Kleiweg
From: Martin v. Loewis on 27 Jun 2010 16:00 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
From: Peter Kleiweg on 27 Jun 2010 16:17 Martin v. Loewis schreef op de 27e dag van de zomermaand van het jaar 2010: > 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. That doesn't work Python 3.1.1 (r311:74480, Oct 2 2009, 11:50:52) >>> import os >>> os.system('echo \N{EURO SIGN}'.encode('iso-8859-15')) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: must be string, not bytes -- Peter Kleiweg L:NL,af,da,de,en,ia,nds,no,sv,(fr,it) S:NL,de,en,(da,ia) info: http://www.let.rug.nl/kleiweg/ls.html
From: Martin v. Loewis on 27 Jun 2010 17:05 >> For the moment, you can encode the string explicitly, and pass a byte >> string. > > 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
From: Lawrence D'Oliveiro on 29 Jun 2010 03:31 In message <alpine.DEB.1.10.1006251708470.3765(a)localhost>, Peter Kleiweg wrote: > How do I set the string encoding for os.system to anything other then > UTF-8? Works for me (on Debian Unstable): ldo(a)theon:~> echo $LC_ALL en_NZ.utf8 ldo(a)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. >>> import os >>> os.system('echo \N{EURO SIGN}') € 0 >>> '\N{EURO SIGN}' '€' >>>
|
Pages: 1 Prev: python source code -> win/dos executable (on linux) Next: Continuously running scripts question |