From: David Lim
Subject: Newbie question: How do I output a CR (carraige-return ascii code 13)?
Date: 
Message-ID: <s47mu1k6ro.fsf@surf.jpl.nasa.gov>
This is a stupid newbie question:

I'm running ACL/Win version 3.0. I want to send a CR (carraige-return 
ascii code 13) to a socket. How do I create a character in lisp that 
corresponds to carraige return?

I tried the following:
	(format hifsock "~A" #\return)
and
	(format hifsock "~A" #\newline)
and they both emit ascii code 10 for linefeed. In fact,
	#\return
or
	#\newline
both return
	#\Newline

I also tried:
	(code-char 10)
which returns NIL

From: Robert Munyer
Subject: Newbie question: How do I output a CR (carraige-return ascii code 13)?
Date: 
Message-ID: <4ojv5e$8hj@Mercury.mcs.com>
In article <··············@surf.jpl.nasa.gov>,
David Lim <···@telerobotics.jpl.nasa.gov> wrote:

> This is a stupid newbie question:
>
> I'm running ACL/Win version 3.0. I want to send a CR (carraige-return
> ascii code 13) to a socket. How do I create a character in lisp that
> corresponds to carraige return?
>
> I tried the following:
> 	(format hifsock "~A" #\return)
> and
> 	(format hifsock "~A" #\newline)
> and they both emit ascii code 10 for linefeed. In fact,
> 	#\return
> or
> 	#\newline
> both return
> 	#\Newline
>
> I also tried:
> 	(code-char 10)
> which returns NIL

#\Return should always be a carriage return, ASCII code 13, on any
Common Lisp system that's based on any kind of ASCII (i. e., pretty
much anything that's not using EBCDIC on an IBM mainframe).  You
can verify this by evaluating (= (char-code #\return) 13).  If this
returns nil, there is probably a bug in the implementation of Common
Lisp that you are using.  You might want to contact the implementors.

Meanwhile, (code-char 13) will do what you want.

-- Robert

P. S.  If you want to send a carriage return to a stream, the TERPRI
function (an abbreviation for "terminate printing") will generally
do what you want, on a system where #\return and #\newline are the
same character.  Or you can use "~%" as a format code.
From: Carl L. Gay
Subject: Re: Newbie question: How do I output a CR
Date: 
Message-ID: <CGAY.96Jun1010409@ix.cs.uoregon.edu>
   From: ······@MCS.COM (Robert Munyer)
   Date: 30 May 1996 06:01:02 -0500

   David Lim <···@telerobotics.jpl.nasa.gov> wrote:

   > This is a stupid newbie question:
   >
   > I'm running ACL/Win version 3.0. I want to send a CR (carraige-return
   > ascii code 13) to a socket. How do I create a character in lisp that
   > corresponds to carraige return?

   #\Return should always be a carriage return, ASCII code 13, on any
   Common Lisp system that's based on any kind of ASCII (i. e., pretty
   much anything that's not using EBCDIC on an IBM mainframe).  You

That's not quite true.  CLtL2
(http://www.cs.cmu.edu/Web/Groups/AI/html/cltl/cltl2.html) sez that
#\Return is "semi-standard" and implementations need not support it.
Apparently ACL/Win and MCL both make #\Return synonymous with
#\Newline.  It seems the implementation is supposed to Do The Right
Thing to produce a line division when a #\Newline is output.  On Unix
this might mean CRLF.  What it means when doing output to a network
stream seems to me a little problematical since the remote system or
the protocol may want something different than the local system.

   Meanwhile, (code-char 13) will do what you want.

If it doesn't return NIL.
From: Robert Munyer
Subject: Re: Newbie question: How do I output a CR
Date: 
Message-ID: <4oum6p$5b1@Mars.mcs.com>
In article <·················@ix.cs.uoregon.edu>,
Carl L. Gay <····@ix.cs.uoregon.edu> wrote:
> > From: ······@MCS.COM (Robert Munyer)
> > Date: 30 May 1996 06:01:02 -0500
> > David Lim <···@telerobotics.jpl.nasa.gov> wrote:
> > >
> > > This is a stupid newbie question:
> > >
> > > I'm running ACL/Win version 3.0. I want to send a CR (carraige-return
> > > ascii code 13) to a socket. How do I create a character in lisp that
> > > corresponds to carraige return?
> >
> > #\Return should always be a carriage return, ASCII code 13, on any
> > Common Lisp system that's based on any kind of ASCII (i. e., pretty
> > much anything that's not using EBCDIC on an IBM mainframe).  You
>
> That's not quite true.  CLtL2
> (http://www.cs.cmu.edu/Web/Groups/AI/html/cltl/cltl2.html) sez that
> #\Return is "semi-standard" and implementations need not support it.

Actually I said "should," not "must."  CLtL2 says this also.

> Apparently ACL/Win and MCL both make #\Return synonymous with
> #\Newline.  It seems the implementation is supposed to Do The Right
> Thing to produce a line division when a #\Newline is output.  On
> Unix this might mean CRLF.

On Unix a newline is just a linefeed.  No carriage return needed.

> What it means when doing output to a network stream seems to me a
> little problematical since the remote system or the protocol may
> want something different than the local system.

If there's any mismatch, probably the best thing would be to treat
it as a binary stream so that the end of line issues do not apply.

> > Meanwhile, (code-char 13) will do what you want.
>
> If it doesn't return NIL.

It should not return NIL in an ASCII based Common Lisp system.
And remember that Mr. Lim said that #\Return was recognized as a
character on his system.  It would be thoroughly perverse for
(code-char 13) to return NIL on an ASCII based system where Return
is a valid character name.

-- Robert