[Zope3-Users] Zope and UTF-8 accentuated characters

Stéphane Brault stephane_brault at yahoo.fr
Mon Aug 28 05:05:37 EDT 2006

Thanks Marius.
  My data is stored in a MySQL database (charset utf-8), which I access through sqlos.
  My string data are stored in a unicodeCol (a sqlos object which manages unicode data). 
  The browser's page charset is UTF-8, so I gess there lies the problem.
 I generate pages through ajax via the jsonserver package. My request passes the request
 to the server, which generates HTML with pages templates and sends back
 the HTML, wich is used to update the page (via innerHTML). The fact is this problem
 is a bit random, sometimes the accents are well displayed, sometimes not.
 It also seems that there is a slight behaviour difference between linux (debian 3.1) and

----- Message d'origine ----
De : Marius Gedminas <mgedmin at b4net.lt>
À : zope3-users at zope.org
Envoyé le : Samedi, 26 Août 2006, 2h58mn 48s
Objet : Re: [Zope3-Users] Zope and UTF-8 accentuated characters

On Sat, Aug 26, 2006 at 02:34:55PM +0200, Stéphane Brault wrote:
>  I have a lot of unicode data with accentuated characters. The trouble
>  is that it is sometimes displayed the right way (in combo boxes,
>  lists,.. ) and sometimes not, especially in text inputs.

I use Unicode data in my Zope 3 applications extensively, and usually
there are no problems.

>  The input data is saved correctly but not displayed correctly (é is
>  saved the following the utf-8 format and displayed as é, which
>  corresponds the utf-8 encoding).

It is customary to store Unicode data in Python's unicode strings rather
than in UTF-8 encoded 8-bit strings.

Can you check what your web browser thinks about the page's charset?  If
it selects ISO-8859-1, then your data is presented correctly, but the
server did not specify the correct Content-Type header.  If the browser
thinks the page is in UTF-8, then the server mishandled the data.

Zope 3 automatically converts Unicode to UTF-8 and adds 'charset=UTF-8'
to the Content-Type header when a view returns a Unicode string.  This
is the recommended way of handling Unicode data in Zope 3, and this is
what happens by default if your views render page templates.

>  I tried defining my templates' charset as utf-8, but that generates lots 
>  of errors. Has anyone an idea on how to solve this problem.

You have not told us enough to diagnose the problem.  Can you reproduce
it with a shortest possible test case?

Marius Gedminas
Woe unto them that rise up early in the morning -- Isaiah 5:11

Zope3-users mailing list
Zope3-users at zope.org

More information about the Zope3-users mailing list