[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Converting UTF-8 strings to hex in Emacs
From: |
Harald Hanche-Olsen |
Subject: |
Re: Converting UTF-8 strings to hex in Emacs |
Date: |
Wed, 03 Mar 2010 10:08:00 -0500 (EST) |
+ 白い熊 <address@hidden>:
> I'm looking for the Emacs way to convert UTF-8 strings to Hex, so they
> can be sent as hex codes to modem AT commands.
This is the emacs developer list; I think such questions are not too
welcome here. Still, I'll risk the ire of the regulars by responding.
> There's uni2ascii which does this, and I can call it via a call-process,
> however would like to do it in elisp.
Something along the lines of
(defun string-to-numeric (string)
(let (nums)
(dotimes (n (length string) (apply #'concat (nreverse nums)))
(setq nums (cons (format "%d;" (aref string n))
nums)))))
might work; you'll have to adjust the format string to give the
desired format (I haven't the foggiest notion what uni2ascii
produces). Warning: This only works on modern emacsen for which
unicode is the internal encoding. for compatibility with older ones,
an extra function call will be needed (but I don't know which).
- Harald