From: Thomas Strathmann
Subject: Escaping in strings
Date: 
Message-ID: <slrn9utvsr.fv4.thomas@adams.pdp7.org>
Hello,

First of all, forgive me, if this is a trivial and stupid question but I am
really stuck at this point (just in the process of learning things):
I need to pass the string "\304" but the \ is just left out by the reader.
\\ like in C does not have the desired effect and everything else does not
do anything useful either... Please help me.


Regards,
Thomas

-- 
Thomas S. Strathmann			http://pdp7.org
Lisp - Because today is the car of the cdr of your life

From: ······@worldnet.att.net
Subject: Re: Escaping in strings
Date: 
Message-ID: <3BEF0527.4BD93A75@worldnet.att.net>
Thomas Strathmann wrote:

> First of all, forgive me, if this is a trivial and stupid question but I am
> really stuck at this point (just in the process of learning things):
> I need to pass the string "\304" but the \ is just left out by the reader.
> \\ like in C does not have the desired effect and everything else does not
> do anything useful either... Please help me.

I think "\\304" is what you really want.  Remember when you type it into
a listener, the response you get is going to be readable, hence will
still look like "\\304".  However, this is because you're still seeing
the extra \ that is doing the escaping.

Mayb the following little dialog with my listener will  make things
clearer:

CL-USER 9 > (setf str "\\304")
"\\304"

CL-USER 10 > (length str)
4

CL-USER 11 > (loop for i below (length str) collecting (char str i))
(#\\ #\3 #\0 #\4)


-- 
Howard Ding
······@worldnet.att.net
http://math.sunysb.edu/~hading  http://thunder.prohosting.com/~hading
From: Kaz Kylheku
Subject: Re: Escaping in strings
Date: 
Message-ID: <IJDH7.34895$Ud.1521120@news1.rdc1.bc.home.com>
In article <·····················@adams.pdp7.org>, Thomas Strathmann wrote:
>Hello,
>
>First of all, forgive me, if this is a trivial and stupid question but I am
>really stuck at this point (just in the process of learning things):
>I need to pass the string "\304" but the \ is just left out by the reader.
>\\ like in C does not have the desired effect and everything else does not
>do anything useful either... Please help me.

In Common Lisp, which I assume you are using, \\ does in fact have the
right effect. It specifies a single backslash character so that

	"\\304"

is a four-character string object consisting of the characters  

	#\\ #\3 #\0 #\4.

However, perhaps you are being confused by the printed representation
of that string which the Lisp system is producing back to you.  If you
print the string like this:

	(prin1 "\\304")

then you will get the output

	"\\304"

quotes, double backslash and all. That's simply because the prin1 function
produces a representation of an object in a form that can be read back
to reproduce that object.

Try:

	(princ "\\304")(terpri)

or

	(format t "~a~%" "\\304")

Also, try experimenting with setting the *print-escape* variable to nil:

	(setf *print-escape* nil)

Hope that helps.
From: Erik Naggum
Subject: Re: Escaping in strings
Date: 
Message-ID: <3214525744108869@naggum.net>
* Thomas Strathmann
| First of all, forgive me, if this is a trivial and stupid question but I am
| really stuck at this point (just in the process of learning things):
| I need to pass the string "\304" but the \ is just left out by the reader.
| \\ like in C does not have the desired effect and everything else does not
| do anything useful either... Please help me.

  If you want to write in C, I think actually writing in C is your best bet
  for the "desired effect".  If you want to know what the "desired effect"
  _should_ be when you are writing in _any_ programming language, you need
  to be looking for that rules of that language, not some other.  E.g., if
  a language decides to mimic C in some ways, it is a rule of that language.

  In Common Lisp, a string is delimited by "", within which a \ will escape
  the following \ or ".  A symbol name may be delimited by || within which
  a \ will escape the following \ or |.  Outside of either, a \ will cause
  the next character to be considered a constituent character of a symbol
  name regardless of any other traits it might have had.  That is all.
  
///
-- 
  Norway is now run by a priest from the fundamentalist Christian People's
  Party, the fifth largest party representing one eighth of the electorate.
-- 
  Carrying a Swiss Army pocket knife in Oslo, Norway, is a criminal offense.
From: Thomas Strathmann
Subject: Re: Escaping in strings
Date: 
Message-ID: <slrn9uv4ba.h59.thomas@adams.pdp7.org>
Hello,

and thank you all for your great help. I really appreciate it and now it
works. As I suspected I was the one that was wrong... ;-)

Regards,
Thomas


PS: I must really say this is the first newsgroup I really enjoy because
    you people really care about CL and spreading knowlegde. Most of the
    longer threads have been very enlightening for me and the length and
    detail of many of the answers here clearly show that Lispers are
    something "special". ;-) Thanks again.

-- 
Thomas S. Strathmann			http://pdp7.org
Lisp - Because today is the car of the cdr of your life