Re: problem with input elements and unicode/utf-8
I have experienced on my installation that Zope decides that the character set should be iso-8859-1 for IE7 even no HTTP_ACCEPT_CHARSET is sent from IE7 and preferred charset is utf-8. Firefox submits HTTP_ACCEPT_CHARSET and Zope handles that OK. http://www.zope.org/Collectors/Zope/2280 <http://www.zope.org/Collectors/Zope/2280> I'm wondering what the correct way to set up Zope to use utf-8? Have set sys.setdefaultencoding('utf-8') in /usr/local/lib/python2.4/site.py. Have set management_page_charset='utf-8' as property of / in ZMI. Have set default-zpublisher-encoding utf-8 in etc/zope.conf. After the comments in the Collector above I'm wondering what to do if I should not set the sys.setdefaultencoding()? Not changing the default encoding I always get a decode error when trying to save a page template with non-ascii characters. Regards Jost
On Sun, February 18, 2007 1:29 pm, Jostein Leira wrote:
After the comments in the Collector above I'm wondering what to do if I should not set the sys.setdefaultencoding()? Not changing the default encoding I always get a decode error when trying to save a page template with non-ascii characters.
From the Collector: Correction: I can save page templates containing non-ascii characters, but > not like this:
<tal:block tal:content="python:'æøå'"/>
Try: tal:content="python: unicode('æøå','utf8')" I have had to do this on some of my templates after moving to 2.10.2 Daryl.
--On 18. Februar 2007 16:29:43 -0500 Jostein Leira <jostein.leira@snapper.no> wrote:
Have set sys.setdefaultencoding('utf-8') in /usr/local/lib/python2.4/site.py. Have set management_page_charset='utf-8' as property of / in ZMI. Have set default-zpublisher-encoding utf-8 in etc/zope.conf.
Changing the default encoding is *not* the solution. Did you read this carefully? <http://www.zope.org/Products/Zope/2.10.2/Zope-2.10.2_released>
After the comments in the Collector above I'm wondering what to do if I should not set the sys.setdefaultencoding()? Not changing the default encoding I always get a decode error when trying to save a page template with non-ascii characters.
I would really love to see a *clear* and *detailed* description how this issue can be reproduced with a bare Zope installation in order to fix the issues (if there is one). -aj
Jostein Leira wrote at 2007-2-18 16:29 -0500:
I have experienced on my installation that Zope decides that the character set should be iso-8859-1 for IE7 even no HTTP_ACCEPT_CHARSET is sent from IE7 and preferred charset is utf-8. Firefox submits HTTP_ACCEPT_CHARSET and Zope handles that OK.
It is new for me that Zope treats "Accept-Charset" in any way (but I may be wrong). Usually, browsers respect the charset used when a form was delivered and submit the form in the same charset. As Zope has meanwhile forgotten which charset it used for the form delivery, you must tell it about the encoding using the magic conversion suffixes for request parameters. If you have an "utf8" encoded value, you can append ":utf8" to the parameter name and have it converted to a unicode string. This, you can then transform into any encoding you like. Beside "utf8", you can use any encoding registered with "codecs". -- Dieter
participants (4)
-
Andreas Jung -
Daryl Daly -
Dieter Maurer -
Jostein Leira