[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to show ascii number of a character
From: |
Pascal Bourguignon |
Subject: |
Re: how to show ascii number of a character |
Date: |
12 Jan 2003 23:33:20 +0100 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 |
Romain FRANCOISE <romain@orebokech.com> writes:
> Zimmen Gnauh <yah00204052@yahoo.com> writes:
>
> > Is there any emacs function that can show a the ascii number of a
> > character? i.e. you enter a character, and it shows a number. For
> > example, enter character D, it will show 68, or in octal, binary or
> > other forms.
>
> Add this to your ~/.emacs:
>
> (defun zg-char-to-ascii ()
> "Show the ASCII number of a character."
> (interactive)
> (message (number-to-string
> (aref (read-from-minibuffer "Type a character: ") 0))))
>
> ... and do M-x zg-char-to-ascii.
>
> Cheers,
(defun show-ascii ()
(interactive)
(message "The code of the character at point is: %d" (char-after)))
In emacs, a character is an integer.
If you place the point at an ASCII character, you'll get an ASCII
code, but otherwise, it depends on the encoding currently used in the
buffer.
--
__Pascal_Bourguignon__ http://www.informatimago.com/
----------------------------------------------------------------------
There is a fault in reality. Do not adjust your minds. -- Salman Rushdie