unicode encoding usablilty problem

Dieter Maurer dieter at handshake.de
Mon Feb 21 14:02:41 EST 2005


"Fredrik Lundh" <fredrik at pythonware.com> writes on Sat, 19 Feb 2005 18:44:27 +0100:
> "aurora" <aurora00 at gmail.com> wrote:
> 
> > I don't want to mix them. But how could I find them? How do I know this  statement can be 
> > potential problem
> >
> >   if a==b:
> >
> > where a and b can be instantiated individually far away from this line of  code that put them 
> > together?

I do understand aurora's problems very well.

Me, too, I had suffered from this occasionally:

   * some library decides to use unicode (without I had asked it to do so)

   * Python decides then to convert other strings to unicode
     and bum: "Unicode decode error".

I solve these issues with a "sys.setdefaultencoding(ourDefaultEncoding)"
in "sitecustomize.py".

I know that almost all the characters I have to handle
are encoded in "ourDefaultEncoding" and if something
converts to Unicode without being asked for, then this
is precisely the correct encoding.

I know that Unicode fanatists do not like "setdefaultencoding"
but until we will have completely converted to Unicode (which we probably
will do in the farer future), this is essential to keep sane...


Dieter



More information about the Python-list mailing list