Is there a way to change the default string encoding?

Ron Garret rNOSPAMon at flownet.com
Mon Aug 20 21:44:39 EDT 2007


Is there a way to change the default string encoding used by the 
string.encode() method?  My default environment is utf-8 but I need it 
to be latin-1 to avoid errors like this:

>>> 'Andr\xe9 Ramel'.decode()         
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 4: 
ordinal not in range(128)

I can't change the code to pass an encoding argument to the decode 
method because it's someone else's code.

Thanks,
rg



More information about the Python-list mailing list