[Zope] SUMMARY: strange unicode behaviour, unicode and ZCTextIndex

Dieter Maurer dieter@handshake.de
Fri, 25 Jul 2003 20:29:46 +0200


Toby Dickenson wrote at 2003-7-25 12:32 +0100:
 > ...
 > ...
 > > That's true, but you will definitely need to set a default encoding if
 > > you are going to use python code. If not set, the default encoding is
 > > ascii and you will get the usual "encode error, ordinal not in range
 > > (128)" error when doing as a simple thing as
 > >     Print string_with_some_special_chars_inside.
 > ...
 > you wont get any error when doing....
 > print string_with_some_special_chars_inside
 > ... but you may if doing.....
 > print unicode_string_with_some_non_ascii_chars_inside
 > 
 > I find this inconvenient too, but that is the way that the Python language is 
 > defined. There is code inside Zope, and other libraries, that assumes Python 
 > behaves this way.

I do not want to believe this. Can you give an example?

What do these libraries do when they get a UnicodeError encoding exception?

 > Your call to sys.setdefaultencoding will break these 
 > libraries, because they change the Python language globally.

I live in the "iso-8859-1" area and have (accordingly) defined
the default encoding as "iso-8859-1".
I did not met any library that has had problems with this --
neither Zope nor any other Python library I am using.

Due to this default encoding, I save me from myriads of
encoding errors and make interactive debugging feasible.
Surely, you will understand, that I do not want to add
an "encode('iso-8859-1')" to any value I output with "print"
during interactive debugging.



Dieter