default setting of unicode set

Boudewijn Rempt boud at valdyas.org
Mon Jul 29 10:04:49 EDT 2002


Martin v. Löwis wrote:

> mathias palm <mathias.palm at gmx.net> writes:
> 
>> Is there a possibility to set a unicode default later on?
> 
> No. Just don't use the default. Be explicit about your encodings in
> your program. Use the user's preference where appropriate - only the
> application programmer can know whether using the user's preference
> *is* appropriate (for example, some data formats may require a fixed
> encoding, such as UTF-8, independent of the user's preference).
> 

This question comes up so often that I'm more and more convinced that
the argument for deleting sys.setdefaultencoding() is flawed. Calling
sys.setdefaultencoding("utf-8"), _is_ rather explicit, and beats having to 
add .encode()'s to all string handling. There exists a class of application 
that want to use unicode irrespective of any settings the user might have 
decided upon(1).

My default way of coding around this inconvenience is to add a 
site-customize.py file that saves the setdefaultencoding under another
name, like setappdefaultencoding().


(1)It's still very inconvenient to live with a default LC_CTYPE=en_US.UTF-8. 
For one thing, it messes up motif so the motif open file dialog can't
select strings. For another thing, javac can't handle it... 

-- 
Boudewijn Rempt | http://www.valdyas.org



More information about the Python-list mailing list