getdefaultencoding - how to change this?

Philip Semanchuk philip at semanchuk.com
Thu Jan 20 10:47:54 EST 2011


On Jan 20, 2011, at 10:39 AM, Helmut Jarausch wrote:

> On Thu, 20 Jan 2011 14:31:09 +0000, Helmut Jarausch wrote:
> 
>> Hi,
>> I've searched the net but didn't find the information I need. Using
>> Python-2.7.1, I know, I can't modify defaultencoding at run time. Python
>> even ignores
>> export PYTHONIOENCODING=ISO8859-1
>> 
>> locale.getdefaultlocale()[1]
>> returns
>> 'ISO8859-1'
>> 
>> still sys.stdout is using the ascii codec. How can I recompile Python
>> (itself) to change this to iso8859-1 ? (My favourite editor cannot be
>> told to use unicode.)
>> 
> 
> Sorry for answering myself. One last trial did succeed.
> My locale as root differed from my locale as non-root user.
> After changing the root locale and recompiling Python, it works now.

I'm glad that worked for you. Alternatively, it seems like you can set the default encoding in site.py which sounds easier than recompiling Python.


Cheers
Philip


More information about the Python-list mailing list