[Zope-dev] Urgent: zope cvs not accept Chinese any more

Toby Dickenson tdickenson@geminidataloggers.com
Tue, 07 May 2002 10:52:45 +0100


On Sun, 5 May 2002 06:59:53 -0400, "Andreas Jung"
<andreas@andreas-jung.com> wrote:

>I think this behaviour is caused by Toby unicode patches
>that were merged into the trunk some time ago. Maybe Toby
>can give an explanation for this behaviour.

Maybe. It would help if the original poster included a traceback to
explain *where* this error was raised. I assume it is line 465 of
ZPublisher/HTTPRequest.py?

The best reference for these changes is currently
http://www.zope.org/Members/htrd/howto/unicode

>> I just check out the zope from cvs. Then I receive
>> error when update properties.

>>It seems the property
>> menager now try to re-code into unicode, but thinking
>> the input is just latin-1.

Yes. The 'Properties' management page now uses UTF-8, therefore
browsers submit the form response using UTF-8 too. For a 'string'
property, ZPublisher encodes the unicode value that you type as
latin-1.

You will get this error if you type non-latin-1 characters as the
value of a property of type a 'string', 'int', 'float', 'lines', etc.

>> Actually, I have just add
>> to the root of my site the property
>> management_page_charset as utf-8 which the manage page
>> correctly default to utf-8 encoding now.

The default in Zope cvs today is for the majority of management pages
to use "Content-Type;text/html", meaning the browser has to guess at
characer encoding. This is the same as all previous versions of Zope.
We chose this conservative default because some management pages are
not ready to work with unicode. Some management pages (notably
'Properties') override this default by setting a
management_page_charset name in the namespace stack before rendering
<dtml-var manage_page_header>.

Yes, it is possible to add this property to the root of your folder
and override the default for all management pages. I dont recommend
it.

>> But obviously
>> it does not accept chinese. I have also try to add a
>> new property as ustring but also fail.

'ustring' means unicode string. 'ustring' values are *never* latin-1
encoded, so I can not explain this problem.

Hmmm. 'ustring' means you can use non-latin-1 characters in the
property value, but *not* in the property name. Is that a possible
misunderstanding?

>> Should I need to add chinese / Japanese encoding to
>> python?

No. use 'ustring' and it should 'just work'.



Toby Dickenson
tdickenson@geminidataloggers.com