From: Khaled Hosny <khaledhosny@eglug.org>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: bug with numeral conversion function
Date: Mon, 1 Sep 2008 19:26:43 +0200 [thread overview]
Message-ID: <20080901172643.GA32000@khaled-laptop> (raw)
In-Reply-To: <20080822214647.GB25071@khaled-laptop>
[-- Attachment #1.1.1: Type: text/plain, Size: 1211 bytes --]
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
[-- Attachment #1.1.2: core-con.lua.diff --]
[-- Type: text/x-diff, Size: 321 bytes --]
--- 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 #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
[-- Attachment #2: Type: text/plain, Size: 487 bytes --]
___________________________________________________________________________________
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
___________________________________________________________________________________
next prev parent reply other threads:[~2008-09-01 17:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-22 21:46 Khaled Hosny
2008-09-01 17:26 ` Khaled Hosny [this message]
2008-09-02 10:33 ` Khaled Hosny
2008-09-02 18:25 ` Hans Hagen
2008-09-02 19:42 ` Khaled Hosny
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080901172643.GA32000@khaled-laptop \
--to=khaledhosny@eglug.org \
--cc=ntg-context@ntg.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).