[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: compute ISBN-10, char-to-int?
From: |
tomas |
Subject: |
Re: compute ISBN-10, char-to-int? |
Date: |
Thu, 5 Sep 2019 08:44:37 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Thu, Sep 05, 2019 at 03:32:55AM +0200, Emanuel Berg via Users list for the
GNU Emacs text editor wrote:
> Another quality release from
> uXu and THE SECRET EMPIRE [...]
> Anyway, questions:
>
> that `char-to-int' looks a bit strange...
[...]
> (defun char-to-int (c)
> (string-to-number (char-to-string c) ))
It looks a bit roundabout, sure. But how would you do it without
making any assumptions about the underlying encoding?
If you have no scruples, and since chars in Emacs Lisp are simply
integers, and since encoding is almost-UTF-8 which is basically
ASCII, you could do
(defun char-to-int (c)
(- c ?0))
but...
- it's ugly
- I don't know if that addresses your question
It would be faster, yes. But that will start to count once we
have ISBN-4294967296 or something. By then, you'll have a faster
computer, too ;-)
Cheers
-- t
signature.asc
Description: Digital signature
- compute ISBN-10, char-to-int?, Emanuel Berg, 2019/09/04
- Re: compute ISBN-10, char-to-int?,
tomas <=
- Re: compute ISBN-10, char-to-int?, Emanuel Berg, 2019/09/05
- Re: compute ISBN-10, char-to-int?, Eli Zaretskii, 2019/09/05
- Re: compute ISBN-10, char-to-int?, tomas, 2019/09/05
- Re: compute ISBN-10, char-to-int?, Emanuel Berg, 2019/09/05
- Re: compute ISBN-10, char-to-int?, Eli Zaretskii, 2019/09/06
- Re: compute ISBN-10, char-to-int?, tomas, 2019/09/06
- Re: compute ISBN-10, char-to-int?, Emanuel Berg, 2019/09/06
- Re: compute ISBN-10, char-to-int?, Eli Zaretskii, 2019/09/06
- Re: compute ISBN-10, char-to-int?, Stefan Monnier, 2019/09/07
- Re: compute ISBN-10, char-to-int?, Eli Zaretskii, 2019/09/07