[Zope-dev] Character enconding problems in zope.formlib

Marius Gedminas mgedmin at b4net.lt
Thu Mar 13 07:18:02 EDT 2008


Hi,

On Wed, Mar 12, 2008 at 04:20:09PM -0300, Marcelo de Moraes Serpa wrote:
> I'm using zope.formlib to generate some HTML forms and I'm having some
> issues with character enconding.
> 
> The schema is like the followng:
> 
> class IBoletoBancarioPaymentOptions( IPaymentProcessorOptions ):
> 
> 
>     dias_de_prazo_para_pagamento  =  schema.Int(
>                                                title = _(u"Nosso número"),

You are using non-ASCII characters directly in the source code.  Do you
have a proper encoding declaration at the top of the file?

http://docs.python.org/ref/encodings.html

> Note that I'm actually using the u thing before the string, however, even
> so, the string is still incorrectly rendered.
> 
> The title and description strings get rendered like:
> 
> "Nosso número" (the ú char is not rendered correctly)

This certainly looks weird.  It seems to be incorrectly encoded *twice*.

> The browser is using UTF-8 enconding.
> 
> I should mention that I'm using Zope 3 formlib through Five in Plone 3.
> 
> How could I solve it? I have no idea where to start.

Specifying the source encoding correctly ought to work.

To help search for the cause of the bug (or bugs) you may want to
try title = _(u"Nosso n\u00FAmero") temporarily.

FWIW the usual way is to use English titles in the source code and
provide a .po file with translations.  I'm not sure how to hook that up
through Five.

Marius Gedminas
-- 
As an aside, UPnP's implementation (which features SOAP, HTTP over
multicast/broadcast UDP, and extremely odd XML) is a must-read for fans of
unnatural and baroque network protocols.
        -- Anthony Baxter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mail.zope.org/pipermail/zope-dev/attachments/20080313/165a63e3/attachment.bin


More information about the Zope-Dev mailing list