Is there a way to change the default string encoding?
Peter Otten
__peter__ at web.de
Tue Aug 21 03:49:56 EDT 2007
Ron Garret wrote:
> In article <fadvvr$ogf$00$1 at news.t-online.com>,
> Peter Otten <__peter__ at web.de> wrote:
>
>> If all else fails there's
>>
>> >>> sys.setdefaultencoding("latin1")
>> >>> "Andre\xe9 Ramel".decode()
>> u'Andre\xe9 Ramel'
>>
>> but that's an evil hack, you should rather talk to the maintainer of the
>> offending code to update it to accept unicode.
>
> Yes, but I need to hack around it until I can get it fixed.
Oops, the snippet above omits the actual hack. It should be
>>> import sys
>>> reload(sys)
<module 'sys' (built-in)>
>>> sys.setdefaultencoding("latin1")
>>> "Andre\xe9 Ramel".decode()
u'Andre\xe9 Ramel'
Peter
More information about the Python-list
mailing list