From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/43597 Path: news.gmane.org!not-for-mail From: Khaled Hosny Newsgroups: gmane.comp.tex.context Subject: Re: bug with numeral conversion function Date: Mon, 1 Sep 2008 19:26:43 +0200 Message-ID: <20080901172643.GA32000@khaled-laptop> References: <20080822214647.GB25071@khaled-laptop> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0873897129==" X-Trace: ger.gmane.org 1220290112 2800 80.91.229.12 (1 Sep 2008 17:28:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 1 Sep 2008 17:28:32 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Mon Sep 01 19:29:26 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 1KaDDL-0002sD-T3 for gctc-ntg-context-518@m.gmane.org; Mon, 01 Sep 2008 19:29:19 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 496AF1FC5A; Mon, 1 Sep 2008 19:28:18 +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 04297-01-6; Mon, 1 Sep 2008 19:27:31 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 9625A1FC61; Mon, 1 Sep 2008 19:27:31 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 363C01FC5A for ; Mon, 1 Sep 2008 19:27:30 +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 04298-01-6 for ; Mon, 1 Sep 2008 19:26:54 +0200 (CEST) Original-Received: from fg-out-1718.google.com (fg-out-1718.google.com [72.14.220.153]) by ronja.ntg.nl (Postfix) with ESMTP id EE1FD1FB30 for ; Mon, 1 Sep 2008 19:26:53 +0200 (CEST) Original-Received: by fg-out-1718.google.com with SMTP id l26so1256210fgb.8 for ; Mon, 01 Sep 2008 10:26:53 -0700 (PDT) Original-Received: by 10.86.94.11 with SMTP id r11mr4814200fgb.0.1220290013350; Mon, 01 Sep 2008 10:26:53 -0700 (PDT) Original-Received: from localhost ( [41.234.92.72]) by mx.google.com with ESMTPS id e20sm5972739fga.1.2008.09.01.10.26.49 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 01 Sep 2008 10:26:51 -0700 (PDT) In-Reply-To: <20080822214647.GB25071@khaled-laptop> User-Agent: Mutt/1.5.18 (2008-05-17) 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:43597 Archived-At: --===============0873897129== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="0ntfKIWw70PvrIHh" Content-Disposition: inline --0ntfKIWw70PvrIHh Content-Type: multipart/mixed; boundary="+HP7ph2BbKc20aGI" Content-Disposition: inline --+HP7ph2BbKc20aGI Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Aug 23, 2008 at 12:46:47AM +0300, Khaled Hosny wrote: >=20 > 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 =3D n + 1 -- to get the correct key if n > max then do_alphabetic(floor((n-1)/max),max,chr) n =3D (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. --=20 Khaled Hosny Arabic localizer and member of Arabeyes.org team --+HP7ph2BbKc20aGI Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="core-con.lua.diff" Content-Transfer-Encoding: quoted-printable --- 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 =20 local function do_alphabetic(n,max,chr) + n =3D n + 1 -- to get the correct key if n > max then do_alphabetic(floor((n-1)/max),max,chr) n =3D (n-1)%max+1 --+HP7ph2BbKc20aGI-- --0ntfKIWw70PvrIHh Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAki8JdIACgkQRoqITGOuyPJt/QCfUGokt74yqUickiby3Ryom0FA u2YAniNyItl67pA/xePGFoL2O3m7SNDY =8/Rv -----END PGP SIGNATURE----- --0ntfKIWw70PvrIHh-- --===============0873897129== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ___________________________________________________________________________________ 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 ___________________________________________________________________________________ --===============0873897129==--