help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Char Printing


From: Pascal Bourguignon
Subject: Re: Char Printing
Date: Wed, 25 May 2005 22:31:46 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

Ryan Bowman <address@hidden> writes:

> Suppose I have an integer, say 10.  If I (format "%c"
> 10) it prints a newline.  If I do
> (text-char-description 10) it prints "^J".  Is there a
> function that will take an int (10) and print "\n"?

(defun char-to-escape (ch)
  (let ((a (assoc ch '((7 . "\\a")(8 . "\\b")(9 . "\\t")(10 . "\\n")
                       (11 . "\\v")(12 . "\\f")(13 . "\\r")(27 . "\\e")
                       (34 . "\\\"")(92 . "\\\\")(127 . "^?")))))
     (cond 
       (a (cdr a))
       ((< ch 32) (format "^%c" (+ 64 ch)))
       (t  (format "%c" ch)))))


(dotimes (i 128) (insert (char-to-escape i) " "))

^@ ^A ^B ^C ^D ^E ^F \a \b \t \n \v \f \r ^N ^O ^P ^Q ^R ^S ^T ^U ^V
^W ^X ^Y ^Z \e ^\ ^] ^^ ^_   ! \" # $ % & ' ( ) * + , - . / 0 1 2 3 4
5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W
X Y Z [ \\ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z
{ | } ~ ^? 


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/


reply via email to

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