[Zope-dev] fmt=structured-text doesn't work with accented chars

Leonardo Rochael Almeida leo@hiper.com.br
Wed, 12 Sep 2001 20:36:24 -0300


Got it!

StructuredText is setting locale back to C, during initialization, withou=
t setting it back to
whatever it was before, in 'STletters.py'. I think it is wrong not only f=
or
this unilateral choice of locale :-), but also for trying to ignore pytho=
n's
notion of what the locale is when trying to calculate letters.=20

The patch below fix both my 'Script (Python)' and the parsing problem wit=
h
StructuredText. I took the liberty of removing the spurious 'import strin=
g'.


--- lib/python/StructuredText/STletters.py.orig	Wed Sep 12 20:00:52 2001
+++ lib/python/StructuredText/STletters.py	Wed Sep 12 20:23:24 2001
@@ -1,8 +1,8 @@
-import string
+
 try:
     del string
     import locale
-    locale.setlocale(locale.LC_ALL,"")
+#    locale.setlocale(locale.LC_ALL,"")
 except:
     pass   =20


Is there anywhere else I should submit it?

   Cheers, Leo

PS: BTW, I'm still trying to figure out how to correctly set the locale o=
n
Windows, if anyone knows... :-)

On Wed, Sep 12, 2001 at 06:49:21PM -0300, Leonardo Rochael Almeida wrote:
> Hi,
>=20
> I tried using structured text for some documentation I wrote in portugu=
ese,
> but the accented characters like =E9, =E1, =E3, or =E7 break the parsin=
g of markups
> like *emphasis*, 'code' or _underline_, and in portuguese we get a bunc=
h of
> those with every sentence, you know... :-)
>=20
> The result is the literal apearance of some characters that should be m=
arkup
> and some opening and closing mismatch of markup when there are more tha=
n one
> occurrence of the same markup, like when you try to *emphasize* twice i=
n the
> *same* paragraph.
>=20
> This is probably due to parsing with python's
> string.letters which doesn't include accented letters unless you set th=
e
> locale. Now the funny thing is that even when I set -L to, say, pt_BR a=
t Zope
> start (and my glibc has correctly configured locales for pt_BR),
> structured-text still doesn't parse accented letters correctly.
>=20
> Investigating that, I found out that if you put, in a 'Script (Python)'=
 the
> following::
>=20
>   import string
>   return string.lowercase
>=20
> it will print 'abcdefghijklmnopqrstuvwxyz' instead of
> 'abcdefghijklmnopqrstuvwxyz=B5=DF=E0=E1=E2=E3=E4=E5=E6=E7=E8=E9=EA=EB=EC=
=ED=EE=EF=F0=F1=F2=F3=F4=F5=F6=F8=F9=FA=FB=FC=FD=FE=FF'
>=20
> Which is what you get in a python interpreter if you type::
>=20
>   import locale
>   locale.setlocale(locale.LC_ALL, "pt_BR")
>   import string
>   print string.lowercase
>=20
> Assuming you have a correctly configured pt_BR locale in a Linux machin=
e.
> This exercise also gives the same results with a correctly configured e=
n_US
> locale.
>=20
> Has anyone else stumbled onto this?
>=20
> Speaking of locales, how do I set locale for Zope in a WinNT/2000
> environment? It seems like posix locale strings aren't valid strings fo=
r
> locale.setlocale() in Windows.
>=20
>   Cheers, Leo
>=20
> _______________________________________________
> Zope-Dev maillist  -  Zope-Dev@zope.org
> http://lists.zope.org/mailman/listinfo/zope-dev
> **  No cross posts or HTML encoding!  **
> (Related lists -=20
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope )
>=20
>=20