On Sat, Aug 23, 2008 at 12:46:47AM +0300, Khaled Hosny wrote:
> 
> It seems that there is a bug in converters.alphabetic function,
> converters.alphabetic(0,"arabic") returns the western 0 (no matter what
> is the selected language) while converters.alphabetic(1,"arabic") gives
> the Arabic 0 not 1 and so one i.e. it looks like as if it starts
> counting from zero.

I finally got myself to understand some lua code.

I think the problem is that lua tables start counting from 1 not 0,
getting the value of key 0 from code table will give nil while 1 will
give the value of 0 (first key), so the solution would be incrementing n
by 1 in:

local function do_alphabetic(n,max,chr)
    n = n + 1 -- to get the correct key
    if n > max then
        do_alphabetic(floor((n-1)/max),max,chr)
        n = (n-1)%max+1
    end
    characters.flush(chr(n))
end

This does work for the case of Arabic, but I don't know about others
(especially greek and slovenian which look different)

Now, I think I discovered another bug (or feature?), the function will
ignore any zeros at the left which isn't what one expects.

-- 
 Khaled Hosny
 Arabic localizer and member of Arabeyes.org team
--- core-con.lua~	2008-09-01 19:24:44.000000000 +0200
+++ core-con.lua	2008-09-01 19:23:31.000000000 +0200
@@ -103,6 +103,7 @@
 end
 
 local function do_alphabetic(n,max,chr)
+    n = n + 1 -- to get the correct key
     if n > max then
         do_alphabetic(floor((n-1)/max),max,chr)
         n = (n-1)%max+1

Attachment: signature.asc
Description: Digital signature

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to