[Zope] html_quote, quoting accents

Troy Farrell troy@entheossoft.com
Mon, 05 May 2003 11:08:33 -0500


Ok.  We're going to trace this to the root.  The html_quote you are=20
using is in Products.PythonScripts.standard.html_quote() or so, which=20
points to DocumentTemplate.DT_Var.html_quote() which points to=20
DocumentTemplate.html_quote.html_quote() which points to cgi.escape().

The cgi.escape() docs say this:

escape(s[, quote])
Convert the characters "&", "<" and ">" in string s to HTML-safe=20
sequences. Use this if you need to display text that might contain such=20
characters in HTML. If the optional flag quote is true, the double-quote=20
character (""") is also translated; this helps for inclusion in an HTML=20
attribute value, as in <A HREF=3D"...">. If the value to be quoted might=20
include single- or double-quote characters, or both, consider using the=20
quoteattr() function in the xml.sax.saxutils module instead.

http://www.python.org/doc/current/lib/node300.html

All that being said, html_quote will not solve your problem.  One thing=20
you might try is messing with the character coding used on your html=20
pages.  The only other option I can see is writing your own convertor.

Troy

Jean-Francois.Doyon@CCRS.NRCan.gc.ca wrote:
> Troy,
>=20
> OK, well for the purpose of this example, and where I'm starting, is wi=
th
> CMF Metadata, such as the title.
>=20
> A user enters the metadata using their regular keyboards and so on, whi=
ch
> means the accented characters are typed in in ISO-8859-1, and stored as=
 such
> I guess? (since technically this value isn't HTML, it should be stored =
in
> it's native character set)
>=20
> Now when I output the Title, it comes out in ISO-8859-1 properly, but I=
'd
> like to force it encoded as an HTML entity, so when a user enters the w=
ord
> "r=E9gion" in the Title, it'll be entered/saved that way, and by defaul=
t be
> output that way, but ...
>=20
> My understanding was that uting html_quote would transform that into
> "r&eacute;gion" ... But it's not doing anything different for me.  Same=
 with
> entity notation, &dtml-Title; doesn't do the html_quoting either.
>=20
> This is using the default metadata templates, or close enough that chan=
ges I
> have made shouldn't matter (I've extended the metadata, but not modifie=
d the
> existing DC setup).
>=20
> Am I misunderstanding the purpose of this command? Or is there somethin=
g
> else I'm not getting?
>=20
> Thanks,
> J.F.
>=20
>=20
> -----Original Message-----
> From: Troy Farrell [mailto:troy@entheossoft.com]
> Sent: Friday, May 02, 2003 5:15 PM
> To: Jean-Francois.Doyon@CCRS.NRCan.gc.ca
> Subject: Re: [Zope] html_quote, quoting accents
>=20
>=20
> Bonjour Jean-Fran=E7ois.
>=20
> We need more information before we can help you.  Where is your user=20
> typing these characters?  In what forms?  In what type of objects are=20
> you storing this information?  We'll try to help you, but we need more=20
> information first.
>=20
> Troy
>=20
> Jean-Francois.Doyon@CCRS.NRCan.gc.ca wrote:
>=20
>>Hello,
>>
>>I have french content on my site, which means accents and other high-bi=
t
>>type characters.
>>
>>For the first time a user actually ran into the problem of the characte=
rs
>>coming out wrong on his screen, so now I have to fix it :P
>>
>>I tried using html_quote without success, and also using the &dtml-Titl=
e;
>>type syntax (Which apparently is auto-quoted) but in both cases my acce=
nts
>>are still coming out in raw latin-1 instead of something like &eacute; =
...
>>
>>Of course in the case of the metadata, I don't want to html encode the
>>characters since technically it's not HTML just yet :)
>>
>>Help ?
>>
>>Thanks,
>>
>>Jean-Fran=E7ois Doyon
>>Internet Service Development and Systems Support / Soutien de syst=E8me=
s et
>>developement de services Internet
>>GeoAccess Division / Division G=E9oAcc=E8s
>>Canada Center for Remote Sensing / Centre canadien de t=E9l=E9d=E9tecti=
on
>>Natural Resources Canada /  Ressources naturelles Canada
>>Phone / T=E9l=E9phone: (613) 992-4902
>>Fax / T=E9l=E9copieur: (613) 947-2410
>>http://atlas.gc.ca
>>
>>
>>_______________________________________________
>>Zope maillist  -  Zope@zope.org
>>http://mail.zope.org/mailman/listinfo/zope
>>**   No cross posts or HTML encoding!  **
>>(Related lists -=20
>> http://mail.zope.org/mailman/listinfo/zope-announce
>> http://mail.zope.org/mailman/listinfo/zope-dev )
>=20
>=20
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -=20
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )