[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fwd: Hebrew list-style-type in khtml?



On Mon, 5 Nov 2001, Herouth Maoz wrote:

> The following message has been forwarded to the linux-il mailing
> list, and I took it upon myself to answer you as I was dealing with
> this exact issue a couple of days ago, and I solved it for myself
> using PHP.
>
> - - - Forwarded message - - -
>
> >From the KDE-Mailing-List I conclude, that you are a hebrew speaking
> person.
> I?m currently considering implementing Hebrew list-style-type in khtml
>
> http://www.w3.org/TR/REC-CSS2/generate.html#propdef-list-style-type
>
> but I?m not sure wether this is used at all in Hebrew-isch pages.
>
> As it`s not straight forward to implement (you have a complicated way
> of
> counting :) ), what is your opinion on that?
>
> Andreas
>
> - - - End of forwarded message - - -
>
> Actually, as far as implementing it is concerned, it's certainly not
> too hard. At least, the basic algorithm for translating a number to a
> Hebrew numeral is easy. Here is how I did it in PHP:
>
> You use a small table (a hash table in PHP), to connect each letter
> to its numeric value. In non-PHP languages, this would be a simple
> array, with each entry having two members - a char and a short int.
> Oh, and order it in descending order (tav first, aleph last).
>
> The letters aleph (iso8859-8 character 224 decimal) to tet (232) have
> the values 1-9 respectively.
>
> The letters yod (233) to zadik (246) have the values 10-90
> respectively. Note that here there are certain letters which won't be
> in the table, so you actually have character codes 233, 235, 236,
> 238, 240, 241, 242, 244, 246.
>
> The letters kof (247) to Tav (250) have the values 100-400
> respectively.
>
> Assume the numeric value you have to translate to Hebrew is N, and
> the string where you want to store the value is S, which is initially
> empty.
>
> loop on each of the entries in the value table. Let C and V be the
> members of the current entry in each iteration:
>
> - - while ( N >= V ) do
> - - - - S = S concatenated to C
> - - - - N -= V
>
> That's it... Of course, this algorithm always has 22 iterations in
> the outer loop. The inner loop will actually iterate once for each of
> the letters aleph (224) to shin (249). For Tav (250), it will iterate
> N/400 times. So you may make it more efficient by simply
> concatenating N/400 instances of Tav first, and then doing this
> algorithm from shin downwards, which will give you a constant time
> for your algorithm. (well, not exactly, the N/400 loop will just move
> elsewhere).

Two corrections:

1. There is the case of 15 and 16 (and every 15,16 modulu 100: 115, 116,
215, 216, etc.) which are written as Tet-Vav (232,229) and Tet-Zayin
(232,230).

2. The proper algorithm should also call itself again for every part that
is larger than 1000: 1002 is Alef-apostrophe-Beit . Alef is for 1,
apostrophe serves as a "thousand seperator", and Beit is for 2. I'm not
entirely sure you'll run into such large numbers in daily numbering life.

(If you're interested in TeX implementation of this algorithm, look in the
archives of the ivritex list, as this was dicussed there in the last
month.)

Is there any formal definition of Hebrew numbering?

>
> Sorry for not giving the unicode values of the letters - I use
> ISO8859-8 more than I do unicode.

-- 
Tzafrir Cohen
mailto:tzafrir@technion.ac.il
http://www.technion.ac.il/~tzafrir


=================================================================
To unsubscribe, send mail to linux-il-request@linux.org.il with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail linux-il-request@linux.org.il