[Python-il] Determining if a string is RTL
Meir Kriheli
meir at mksoft.co.il
Sat Jan 3 22:52:05 IST 2009
Dotan Cohen wrote:
> Thanks, Ori. The information regarding soft characters such as
> whitespace is especially important. I will forward this info to the
> developer. The program in question is a Python GTK application:
> http://zim-wiki.org/
>
> The website says it's Perl, but it is being recoded in Python.
>
In that case he can use pygtk's pango module with the function Ori
pointed to:
$ python
Python 2.5.2 (r252:60911, Nov 14 2008, 19:46:32)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pango
>>> a = ' .. . שלום'
>>> b = 'Hello שלום'
>>> pango.find_base_dir(a, len(a))
<enum PANGO_DIRECTION_RTL of type PangoDirection>
>>> pango.find_base_dir(b, len(b))
<enum PANGO_DIRECTION_LTR of type PangoDirection>
>>> pango.find_base_dir(a, 4)
<enum PANGO_DIRECTION_NEUTRAL of type PangoDirection>
Cheers
--
Meir Kriheli
More information about the Python-il
mailing list