🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #90

Re: converting Arabic numbers from String format to Number format

#90
From: jongware
Date: Sun, 29 Mar 2009 16:00
9 lines
2330 bytes
You might find: that there is no '1' at all.
There are two ways of putting Arabic digits in fonts. The first is pretty naive and old-fashioned: replacing the glyphs representing '0'..'9' with ones in a suitable Arabic style. It's pretty naive, because the same has been done with, for example, Greek fonts -- 'a' becomes 'alpha', 'b' becomes 'beta', 'c' ... now, wait ...
The 21st century solution is to use Unicode coding for Arabic digits -- moving them from code points U+0030..U+0039 to U+0660..U+0669. That means you can happily use both western and arabic digits in the same font and document. It also means that to enter Arabic digits, your software must be smart 'nuff to check the language (I expect that in an Arabic OS, the OS will take care of that).

Now what number do you get when you inspect the character code? If the used font was a 'hack' one, you will get the code for a '1' (U+0030). But since the Number function relies on that code, and it apparently fails, I'm betting you get the code for a '١' -- the Arabic '1', U+0661.

If you need to convert the string to a real number, inspect the string one charcode at a time, making no assumptions about the coding. If its code is inbetween 48 and 57 (inclusive), it's a roman digit; subtract 48 from it to get the numerical value. If it is between 1632 and 1641 (the decimal value of the hex-based U+ codes), simply subtract 1632 to get this numerical value. Any other values could be considered 'end-of-number' -- or, well, except if you have used 'extended Arabic' (U+6F0..U+6F9), 'Devanagari' (U+0966..U+096F), 'Bengali', or any other script system digits as well.

Reconstructing the entire number from these is basic math.
Technical Details
Message-ID: <59b8718b.1@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!newshub.sdsu.edu!webcrossing
References: <59b8718b.-1@webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,e56a497d48c5d
X-Google-Attributes: gidf939a,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: jongware@adobeforums.com
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!newshub.sdsu.edu!webcrossing
Newsgroups: adobe.scripting.indesign
Subject: Re: converting Arabic numbers from String format to Number format
Message-ID: <59b8718b.1@webcrossing.la2eafNXanI>
Date: Sun, 29 Mar 2009 09:00:32 -0700
References: <59b8718b.-1@webcrossing.la2eafNXanI>
Lines: 33
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit