From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Freeman Gilmore Newsgroups: gmane.lisp.guile.user Subject: Re: Unicode numeric value Date: Fri, 4 Jan 2019 20:07:34 -0500 Message-ID: References: <87pnu199cm.fsf@netris.org> <87bm5kxae3.fsf@netris.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1546650368 19119 195.159.176.226 (5 Jan 2019 01:06:08 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 5 Jan 2019 01:06:08 +0000 (UTC) Cc: guile-user@gnu.org To: Mark H Weaver Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sat Jan 05 02:06:04 2019 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gfaPb-0004qY-LT for guile-user@m.gmane.org; Sat, 05 Jan 2019 02:06:03 +0100 Original-Received: from localhost ([127.0.0.1]:42192 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gfaRi-0004fh-Cg for guile-user@m.gmane.org; Fri, 04 Jan 2019 20:08:14 -0500 Original-Received: from eggsout.gnu.org ([209.51.188.92]:33823 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gfaRK-0004fb-PE for guile-user@gnu.org; Fri, 04 Jan 2019 20:07:52 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gfaRI-00082z-Jk for guile-user@gnu.org; Fri, 04 Jan 2019 20:07:50 -0500 Original-Received: from mail-oi1-x22b.google.com ([2607:f8b0:4864:20::22b]:36694) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gfaRH-000827-V6 for guile-user@gnu.org; Fri, 04 Jan 2019 20:07:48 -0500 Original-Received: by mail-oi1-x22b.google.com with SMTP id x23so31805448oix.3 for ; Fri, 04 Jan 2019 17:07:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=H1JRiXZTWh7vR6HgkbJDqEKrwKiegmv2GJV9PqIs5Yo=; b=qDblwGnZQBZC6Sz578j/oZkGvfffoaya6GhdSLNKjlmhCXtGbRITX53uBUHl6dLoqB dniiOpzlBtOuQVDYCOffm18hpKkW915Th/1qUj9q8PaYupLsb/+c8rsuuioMnsrX2Oa3 SZ5nY/iGGsC6l/qf0ZW0fkJTPhGtLJohTVDHCn/C3cOTTCTiBZC+/DTEAYLk0vyXmUb4 FwMcRhoYuk4Y4uFRaC98l+/c5ZpP3eHUwn3IrKOmBvge8vxQe5stZRsQrg6FdniWwUI/ l9lgA8CKfEHYoc5ftZKWDdkCJGSj0+nEyQePjQb+UiJfxBg0fPi28C4Mua7wcpKIjo8e LzMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=H1JRiXZTWh7vR6HgkbJDqEKrwKiegmv2GJV9PqIs5Yo=; b=U/po4B1bPihkGci0+d7a4pYS+LBt27dXt3gi6t8xBHqtcfWLOW+ghSGjL821mybY/w HJGs1hCyqqbde2HD+G//X9oaQZLlxp6DGUi0rCByFwhIVANmpaYkSeZjX/NYV2DwFMtU KgXD+jB26UUwM2AzMRZnPr4dX5woql8hCNpAn8etrPpyublWtC2QBfzGVl3EyrINmzd9 8EH5ZI627XMhHX9mRAG62DB0DONV7cBrfx3WApSHaI7abB3B/hxge1NRUWvIxgarJbTz Llf6qklPoMThzpHhW3I5FdXJ9Pg+ZHKIDFUnM8s2GrPmT4vnTIWcAQvggWpJ8s6/13SW ZqMA== X-Gm-Message-State: AJcUukeBQfW0KXcmPIqQpGBKX7QrMkGE5BwXrT2FGhH+oWSLLITlMOwJ w4QLBbWpRWufEyczjcj5wBMVC7eVidNqu0IHtTs= X-Google-Smtp-Source: ALg8bN6rXiHTwJesSZ/Q6/olcjYSgqG2W5Y8ifV8yOmIjtlUUDhyXGRLiYwM+ysw78QOujKSVHjuOT+cdB01vnnVGTQ= X-Received: by 2002:aca:b9d6:: with SMTP id j205mr2388120oif.294.1546650464554; Fri, 04 Jan 2019 17:07:44 -0800 (PST) In-Reply-To: <87bm5kxae3.fsf@netris.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::22b X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:15197 Archived-At: Mark: I have been away and just getting back to email. Thank you for replying. So it looks like the library is just a lookup table. I though it was more complicated than that, reading from a Unicode data file. The hash table may be better and more portable. I could also change the numeric value for the given code points as needed. I do not know what " SRFI-4 homogeneous numeric vector" is, but I did google it, a lot there. I am to new to this but I did copy your hash table that you made for me and added the correction. Thanks for your time here. I will probably be using it (if I learn enough). You all have a good year. =C6=92g On Mon, Dec 17, 2018 at 1:43 PM Mark H Weaver wrote: > Hi, > > Freeman Gilmore writes: > > > On Sun, Dec 16, 2018 at 3:15 AM Mark H Weaver wrote: > > > > Freeman Gilmore writes: > > > > > I am looking for a procedure that will read the numeric value, field > 8, of > > > an Unicode numeric character. Has anyone written this procedure or > know > > > where I can find it? > > > > The 'r7rs-wip' branch of the Guile git repository contains a procedure > > that does this, with a lookup table derived from Unicode 6.3.0. > > > > > https://git.savannah.gnu.org/cgit/guile.git/tree/module/scheme/char.scm?h= =3Dr7rs-wip > > > > The file is written as an R7RS library form, which won't work on curre= nt > > releases of Guile, but for now you could simply extract the > > 'digit-value' procedure from it, provided that you preserve the > > copyright notice. > > > > Mark > > > > Thank you Mark: > > > > That is only half the battle, let me explain. I do not want to read > > the standard Unicode table. I want to directly read field 8 of a > > numeric character in the privet use area of the Unicode. > > > > This is not part of scheme. The other half, I need to finger out how > > to put the numeric values in field 8 for the characters I want to use. > > If the mapping from code points to numeric values is static, then you > could simply modify the lookup table in the code I suggested above. > > If the mapping is dynamic, then you'll need a different strategy. One > simple approach would be to use a hash table mapping from characters to > digit values: > > (define digit-value-table (make-hash-table)) > > (define (set-digit-value! char value) > (hashv-set! digit-value-table char value)) > > (define (digit-value char) > (hashv-ref digit-value-table char #f)) > > If the range of relevant code points is small enough, another approach > would be to use a vector: > > (define private-code-point-start #xE000) > (define private-code-point-end #xF900) > > (define (code-point-in-range? cp) > (<=3D private-code-point-start > cp > private-code-point-end)) > > (define digit-value-table > (make-vector (- private-code-point-end > private-code-point-start) > #f)) > > (define (set-digit-value! char value) > (let ((cp (char->integer char))) > (unless (code-point-in-range? cp) > (error "set-digit-value!: code point out of range:" cp)) > (vector-set! digit-value-table > (- cp private-code-point-start) > value))) > > (define (digit-value char) > (let ((cp (char->integer char))) > (and (code-point-in-range? cp) > (vector-ref digit-value-table > (- cp private-code-point-start))))) > > For a more compact representation, you could use a SRFI-4 homogeneous > numeric vector instead, although you'd need to designate a special > numeric value to represent "not a digit". > > Regards, > Mark >