"Martin v. Löwis" martin at
Tue Aug 28 19:13:31 CEST 2007

> Is there a way to allow the process to specify that unicode-->str should
> use 'utf8' rather than 'ascii' in all non-specific cases?

No. Things might break if you change the default encoding to anything
but ASCII, and more so if you do that "at runtime". For example,
dictionaries with Unicode keys may stop working, and the cached
byte-oriented version of a Unicode string may become incorrect.

In general, programs and libraries should not rely on the default
encoding for anything. Instead, they should convert explicitly,
either from an explicitly specified encoding, or one derived from
the context. Experience has shown that this is possible in nearly
every case (and in all cases if an appropriate refactoring is made).


More information about the Python-list mailing list