Unicode string output

Boudewijn Rempt boud at rempt.xs4all.nl
Thu Jan 25 17:36:09 EST 2001


On Thu, 25 Jan 2001, M.-A. Lemburg wrote:
> 
> Well, you can manage multi-user settings easily by providing
> a special sitecustomize.py module, so I guess that's a non-issue.
> 

Perhaps - but it is often the application, not the user that
knows about encodings. I can easily imagine my small Chinese
editor to work in Big5 for someone from Taiwan, but in Unicode
for me - an application-level default, and if we use the same
computer, a user-level default. 

> The problem with having a per application setting for the
> default encoding is that this would cause code to be written which
> may rely on one specific default encoding. It is much better
> to write such assumption into the code itself than to rely on
> default settings.
> 

But setting an application-level default _is_ putting the assumption
in the code, instead of in the system. Now you get apps that count
on the system default being us-ascii...

> I agree though, that we will need to put some more work into
> making streams and other interfaces more Unicode aware and to
> simplify those interfaces. In theory you could e.g. redirect
> stdin and stdout through codecs, but in practice this currently
> doesn't work well together with "print" due to the complicated
> machinery in the Python interpreter.
> 

One other example is PyQt - the conversion between QString (Unicode
in itself) and Python strings goes via the default codec, meaning
us-ascii for most installations. Again, technical details seem
to make it impossible or at least difficult to alter that, but setting
an application level default makes it easy to work with.


> The same goes for making the Python standard lib more Unicode
> aware. There's still a lot to do ... we could need some sponsors :)
> 

I'd help if I could, but currently I'm a bit overworked as it is,
with completing Kura, writing something publicable on Jython, and
of course, coding Java for a living. On the whole, though, I'm pretty
content with the Python Unicode support - and I've never had a 
problem with my sitecustomize.py file and the saved copy of
setdefaultencoding. But then, I don't switch encodings during the
lifetime of the application.

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





More information about the Python-list mailing list