emacs-devel
[Top][All Lists]
Advanced

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

Re: Converting UTF-8 strings to hex in Emacs


From: Andreas Schwab
Subject: Re: Converting UTF-8 strings to hex in Emacs
Date: Wed, 03 Mar 2010 16:03:47 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

白い熊 <address@hidden> writes:

> For interactive mode hexl-mode lets you view strings and see their
> representation, however I need a way to do this in elisp, i.e. pass the
> UTF-8 string and receive back its hex representation.

(defun uni2ascii (s)
  (mapconcat (lambda (c) (format "%02X" c))
             (encode-coding-string s 'utf-8) ""))

Andreas.

-- 
Andreas Schwab, address@hidden
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




reply via email to

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