From: Teemu Likonen <tlikonen@iki.fi>
To: help-gnu-emacs@gnu.org
Subject: Re: How do I convert hex numbers to decimal ?
Date: Mon, 07 Sep 2009 09:38:32 +0300 [thread overview]
Message-ID: <871vmjp8d3.fsf@iki.fi> (raw)
In-Reply-To: aa95df29-fccb-444d-9e24-c7fab2462758@o9g2000yqj.googlegroups.com
On 2009-09-06 22:52 (-0700), bolega wrote:
> What I want is a function like this:
>
> (function "%1F)
Where that "%" comes from? Do you want your function to require it?
Here's an example:
(defun my-hex-to-int (hexstring)
(car (read-from-string (replace-regexp-in-string
"\\`%" "#x" hexstring))))
(my-hex-to-int "%1F")
=> 31
Or without the % prefix:
(defun my-hex-to-int2 (hexstring)
(car (read-from-string (concat "#x" hexstring))))
(my-hex-to-int2 "1F")
=> 31
> what I want is a function like this:
>
> (function "%3F") and it converts it and returns or
> prints ? either an existing facility or combination thereof.
Do you mean like this?
(format "%c" (my-hex-to-int "%3F"))
=> "?"
It returns a string containing that character.
next prev parent reply other threads:[~2009-09-07 6:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-07 1:03 How do I convert hex numbers to decimal ? bolega
2009-09-07 1:11 ` Janis Papanagnou
2009-09-07 14:44 ` Wang Lei
2009-09-07 2:56 ` Eli Zaretskii
[not found] ` <mailman.6147.1252292305.2239.help-gnu-emacs@gnu.org>
2009-09-07 5:52 ` bolega
2009-09-07 6:38 ` Teemu Likonen [this message]
2009-09-07 7:12 ` Pascal J. Bourguignon
2009-10-05 7:05 ` josephoswald+gg@gmail.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871vmjp8d3.fsf@iki.fi \
--to=tlikonen@iki.fi \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.