12

How to escape double quotes while concatenating a string? For example i hoped

(concatenate 'string "Mama said: " "\"Son, your life is an open book...\"")

to give:

"Mama said: "Son, your life is an open book...""

but instead returned it with backslashes as:

"Mama said: \"Son, your life is an open book...\""
oakenshield1
  • 851
  • 1
  • 11
  • 26

1 Answers1

17

The returned value is printed readably, that is, using a representation that can be parsed with READ into a CL object. If you use a function like PRINC which prints a string as-is you will see that the quoting did what you wanted (the outer quotes are not part of the string):

CL-USER> (princ (concatenate 'string "Mama said: " "\"Son, your life is an open book...\""))
Mama said: "Son, your life is an open book..."
"Mama said: \"Son, your life is an open book...\""

The first line is the result of PRINC, the second one of the PRINT part of the READ-EVAL-PRINT-LOOP.

Ramarren
  • 2,510
  • 1
  • 15
  • 11