Whoops...
I see that (1) seems that you really do want to test for base
direction (missed that substr 0,1 in the php code...), so my examples
were really irrelevant.
(2) Meir had already made it quite explicit (providing actual code).
Conclusion:
I should never post after midnight, especially when I did not read
all the thread carefuly.
Oh well, at least I got an excuse for my fribidi-py plug (even if that
excuse was irrelevant)...
Apologies, and good night,
Amit
On Sun, Jan 4, 2009 at 1:40 AM, Amit Aronovitch <[email protected]> wrote:
> On Sat, Jan 3, 2009 at 11:11 PM, Dotan Cohen <[email protected]> wrote:
>> 2009/1/3 Meir Kriheli <[email protected]>:
>>> In that case he can use pygtk's pango module with the function Ori
>>> pointed to:
>>>
>
> 1) Let us make things more explicit:
>
> From the original regex, I guess you want to find whether the string
> contains any RTL characters, which is different than the question of
> finding the base direction (English text with some Hebrew words in the
> middle still has LTR direction).
>
> In that case, the relevant function is pango_unichar_direction, and
> from python it would look something like this:
>
>>>> has_rtl = pango.DIRECTION_RTL in map(pango.unichar_direction,
>>>> text.decode("utf-8"))
>
> (If you wish to find the base direction, the code would be something like:
>
>>>> has_rtl = pango.DIRECTION_RTL == pango.find_base_dir(text, len(text))
> )
>
> 2) Plug: reviving my abended fribidi-py code...
>
_______________________________________________
Python-il mailing list
[email protected]
http://hamakor.org.il/cgi-bin/mailman/listinfo/python-il