[Zope] problem with input elements and unicode/utf-8

Daryl Daly daryld at norco.com
Thu Feb 15 14:40:49 EST 2007


Zope: 2.10.2
Python: 2.4.4

I am not sure if this is a zope problem or a browser problem or a lack of
my understanding of webservers and/or utf-8 & unicode but here it is:

I have a page template with a form and a textarea input element. The value
for the element comes from a database (MySQL) field. The database field
contains utf-8 encoded text (includes the bullet and registered
characters). When the page is displayed in Firefox (version 1.5.0.9) it
displays fine. However when the page is displayed in IE 6 (or 7), it shows
garbage characters for the bullet and registered characters.

What I find as strange is that if the same field is displayed as just text
(i.e. just in a td element rather than in an input element) it displays
fine in IE.

My page template has the following headers:
<html metal:define-macro="page"
  tal:define="dummy python:request.RESPONSE.setHeader('Content-Type',
'text/html;; charset=utf-8');" >
  <head>
   <meta http-equiv="content-type" content="text/html; charset=utf-8">

Firefox reports the page encoding as UTF-8 with meta:
content-type text/html; charset=utf-8

Input element:
            <textarea cols="50" name="detail_desc" rows="10"
                      tal:content="record/detail_desc |
nothing"></textarea><br>

I have also tried adding accept-charset="utf-8" to the form element

I have been able to fix the problem by adding this to my zope.conf:
<cgi-environment>
  HTTP_ACCEPT_CHARSET utf-8
</cgi-environment>

I don't understand why this "fixes" the problem or if it is the correct
way to resolve this.

Any comments would be appreciated

Thanks,
Daryl.
--
Daryl Daly, B.Sc.
Chief Programmer/Business Analyst
daryld at norco.com

Norco Products Ltd.                 Really Cool Bikes!!!

    Norco            __O            Tel:   604-552-2930 ext 205
 Performance        =\ \            Fax:   604-552-2948
    Bikes         (=)/(=)                  www.norco.com

1465 Kebet Way, Port Coquitlam, British Columbia, V3C 6L3


More information about the Zope mailing list