unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Char Printing
@ 2005-05-25 17:31 Ryan Bowman
  2005-05-25 18:05 ` Drew Adams
  2005-05-25 18:21 ` Kevin Rodgers
  0 siblings, 2 replies; 5+ messages in thread
From: Ryan Bowman @ 2005-05-25 17:31 UTC (permalink / raw)


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"?

----
Ryan Bowman

All truth can be reduced to a Seinfeld episode.

----


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new Resources site
http://smallbusiness.yahoo.com/resources/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: Char Printing
  2005-05-25 17:31 Ryan Bowman
@ 2005-05-25 18:05 ` Drew Adams
  2005-05-25 18:21 ` Kevin Rodgers
  1 sibling, 0 replies; 5+ messages in thread
From: Drew Adams @ 2005-05-25 18:05 UTC (permalink / raw)


    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"?
    
(char-to-string 10) -> "\n"

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Char Printing
  2005-05-25 17:31 Ryan Bowman
  2005-05-25 18:05 ` Drew Adams
@ 2005-05-25 18:21 ` Kevin Rodgers
  1 sibling, 0 replies; 5+ messages in thread
From: Kevin Rodgers @ 2005-05-25 18:21 UTC (permalink / raw)


Ryan Bowman wrote:
 > Suppose I have an integer, say 10.  If I (format "%c" 10)
 > it prints a newline.

No, it returns a string containing just a linefeed character.

 > If I do (text-char-description 10) it prints "^J".

No, it returns a string containing two characters, caret and capital J.

 > Is there a function that will take an int (10) and print "\n"?

If you want to print a newline, use (terpri).  If you want to insert a
newline, use (insert ?\n).

-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Char Printing
@ 2005-05-25 19:39 Ryan Bowman
  0 siblings, 0 replies; 5+ messages in thread
From: Ryan Bowman @ 2005-05-25 19:39 UTC (permalink / raw)



--- Kevin Rodgers <ihs_4664@yahoo.com> wrote:
> Ryan Bowman wrote:
>  > Suppose I have an integer, say 10.  If I (format
> "%c" 10)
>  > it prints a newline.
> 
> No, it returns a string containing just a linefeed
> character.
> 
>  > If I do (text-char-description 10) it prints
> "^J".
> 
> No, it returns a string containing two characters,
> caret and capital J.
> 
>  > Is there a function that will take an int (10)
> and print "\n"?
> 
> If you want to print a newline, use (terpri).  If
> you want to insert a
> newline, use (insert ?\n).
> 
> -- 
> Kevin Rodgers

Sorry I wasn't precise enough, I want something that
it returns a string containing the chars \ and n,  I
can use text-char-description if I have to, but I'm
more use to \n than ^J.

----
Ryan Bowman

All truth can be reduced to a Seinfeld episode.

----

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Char Printing
       [not found] <mailman.1788.1117043746.25862.help-gnu-emacs@gnu.org>
@ 2005-05-25 20:31 ` Pascal Bourguignon
  0 siblings, 0 replies; 5+ messages in thread
From: Pascal Bourguignon @ 2005-05-25 20:31 UTC (permalink / raw)


Ryan Bowman <ryanlbowman@yahoo.com> 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/

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-05-25 20:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.1788.1117043746.25862.help-gnu-emacs@gnu.org>
2005-05-25 20:31 ` Char Printing Pascal Bourguignon
2005-05-25 19:39 Ryan Bowman
  -- strict thread matches above, loose matches on Subject: below --
2005-05-25 17:31 Ryan Bowman
2005-05-25 18:05 ` Drew Adams
2005-05-25 18:21 ` Kevin Rodgers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).