help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: compute ISBN-10, char-to-int?


From: Stefan Monnier
Subject: Re: compute ISBN-10, char-to-int?
Date: Sat, 07 Sep 2019 13:13:45 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

>> > [...] since chars in Emacs Lisp are simply integers, and since
>> > encoding is almost-UTF-8 which is basically ASCII [...]
>> Actually, encoding is not relevant here.  We are not talking about how
>> characters are stored in buffers and strings, we are talking about the
>> characters themselves.  A character is represented by an integer whose
>> value is that character's Unicode codepoint.
> Well, if it's always Unicode code point, then we can make the above
> "official".

(- c ?0) and (+ n ?0) work not just with Unicode code points, but with
code points in any character set that is sane enough to put the digits
from 0 to 9 consecutively in this order.  That's the case in ASCII,
EBCDIC, and all other charsets I know.

I think the main threat could come from a charset where digits appear
multiple times (e.g. some kind of iso-2022 system where some of the
sub-charsets also include digits), in which case (+ n ?0) would still
work but (- c ?0) could occasionally fail.  But, I don't know of such
a charset either.


        Stefan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]