From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Pascal Bourguignon Newsgroups: gmane.emacs.help Subject: Re: how to show ascii number of a character Date: 12 Jan 2003 23:33:20 +0100 Organization: informatimago.com Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <87k7ha6lsf.fsf@thalassa.informatimago.com> References: <87of6mmazt.fsf@orebokech.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1042411093 24911 80.91.224.249 (12 Jan 2003 22:38:13 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sun, 12 Jan 2003 22:38:13 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18Xqk7-0006Tf-00 for ; Sun, 12 Jan 2003 23:38:12 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18Xqhg-00060b-00 for gnu-help-gnu-emacs@m.gmane.org; Sun, 12 Jan 2003 17:35:40 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!cyclone.bc.net!newsfeed.media.kyoto-u.ac.jp!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!fu-berlin.de!uni-berlin.de!thalassa.informatimago.COM!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 37 Original-NNTP-Posting-Host: thalassa.informatimago.com (212.87.205.57) Original-X-Trace: fu-berlin.de 1042410801 19187825 212.87.205.57 (16 [41911]) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Original-Xref: shelby.stanford.edu gnu.emacs.help:108881 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:5410 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:5410 Romain FRANCOISE writes: > Zimmen Gnauh 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