Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Escaping in strings
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Thomas Strathmann  
View profile  
 More options Nov 11 2001, 5:50 pm
Newsgroups: comp.lang.lisp
From: Thomas Strathmann <tho...@tstrathmann.de>
Date: Sun, 11 Nov 2001 23:45:50 +0100
Local: Sun, Nov 11 2001 5:45 pm
Subject: Escaping in strings
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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
hading  
View profile  
 More options Nov 11 2001, 6:08 pm
Newsgroups: comp.lang.lisp
From: had...@worldnet.att.net
Date: Sun, 11 Nov 2001 23:08:49 GMT
Local: Sun, Nov 11 2001 6:08 pm
Subject: Re: Escaping in strings

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
had...@worldnet.att.net
http://math.sunysb.edu/~hading  http://thunder.prohosting.com/~hading


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kaz Kylheku  
View profile  
 More options Nov 11 2001, 6:21 pm
Newsgroups: comp.lang.lisp
From: k...@ashi.footprints.net (Kaz Kylheku)
Date: Sun, 11 Nov 2001 23:21:12 GMT
Local: Sun, Nov 11 2001 6:21 pm
Subject: Re: Escaping in strings

In article <slrn9utvsr.fv4.tho...@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.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Erik Naggum  
View profile  
 More options Nov 11 2001, 10:49 pm
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.net>
Date: Mon, 12 Nov 2001 03:49:05 GMT
Local: Sun, Nov 11 2001 10:49 pm
Subject: Re: Escaping in strings
* 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.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas Strathmann  
View profile  
 More options Nov 12 2001, 10:38 am
Newsgroups: comp.lang.lisp
From: Thomas Strathmann <tho...@tstrathmann.de>
Date: Mon, 12 Nov 2001 10:07:54 +0100
Local: Mon, Nov 12 2001 4:07 am
Subject: Re: Escaping in strings
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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »