From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/43657 Path: news.gmane.org!not-for-mail From: Hans Hagen Newsgroups: gmane.comp.tex.context Subject: Re: bug with numeral conversion function Date: Tue, 02 Sep 2008 20:25:38 +0200 Message-ID: <48BD8522.2060404@wxs.nl> References: <20080822214647.GB25071@khaled-laptop> <20080901172643.GA32000@khaled-laptop> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1220381732 20063 80.91.229.12 (2 Sep 2008 18:55:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 2 Sep 2008 18:55:32 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Tue Sep 02 20:56:23 2008 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from ronja.vet.uu.nl ([131.211.172.88] helo=ronja.ntg.nl) by lo.gmane.org with esmtp (Exim 4.50) id 1Kab38-00064S-Bs for gctc-ntg-context-518@m.gmane.org; Tue, 02 Sep 2008 20:56:22 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 4954A1FD09; Tue, 2 Sep 2008 20:55:19 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 15256-02-3; Tue, 2 Sep 2008 20:54:21 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id DF5CB1FD72; Tue, 2 Sep 2008 20:26:19 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 615F71FD72 for ; Tue, 2 Sep 2008 20:26:15 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 07241-01-12 for ; Tue, 2 Sep 2008 20:25:38 +0200 (CEST) Original-Received: from mail.pragma-ade.net (dsl-083-247-100-017.solcon.nl [83.247.100.17]) by ronja.ntg.nl (Postfix) with ESMTP id A252C1FCBB for ; Tue, 2 Sep 2008 20:25:38 +0200 (CEST) Original-Received: from [10.100.1.100] (unverified [10.100.1.100]) by controller-1 (SurgeMail 3.9e) with ESMTP id 16180-1840426 for ; Tue, 02 Sep 2008 20:25:38 +0200 User-Agent: Thunderbird 2.0.0.16 (Windows/20080708) In-Reply-To: <20080901172643.GA32000@khaled-laptop> X-Originating-IP: 10.100.1.100 X-Authenticated-User: hagen@controller-1 X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.9 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl X-Virus-Scanned: amavisd-new at ntg.nl Xref: news.gmane.org gmane.comp.tex.context:43657 Archived-At: Khaled Hosny wrote: > 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) we cannot change that function without breaking other things there are several ways to convert, one is using the languages.counters table and i don't know if the arabic entries in it are right (i just found out that the greek vector is uppercase while it should be lowercase but i'll make a fix for that) >rgrep arabicn *.tex core-con.tex 671: \defineconversion [arabicnumerals] [\arabicnumerals] core-con.tex 672: \defineconversion [persiannumerals] [\arabicnumerals] >rgrep arabicn *.mkiv core-con.mkiv 20: \def\abjadnumerals #1{\ctxlua{converters.arabicnumerals(\number#1)}} core-con.mkiv 21: \def\abjadnodotnumerals #1{\ctxlua{converters.arabicnodotnumerals(\number#1)}} core-con.mkiv 22: \def\abjadnaivenumerals #1{\ctxlua{converters.arabicnaivenumerals(\number#1)}} core-con.mkiv 87: \def\arabicnumerals #1{\ctxlua{converters.alphabetic(\number#1,"arabic")}} core-con.mkiv 99: \defineconversion [arabicnumerals] [\arabicnumerals] > the abjad number converters are definied differently (based on specs by idris) so, if the 0/1 offset is a problem then we need to fix the tables, not the function (unless arabic follows a different logic, as chinese does) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl ----------------------------------------------------------------- ___________________________________________________________________________________ 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 ___________________________________________________________________________________