2.4.8.1 Syntax for Strings

The read syntax for a string is a double-quote, an arbitrary number of characters, and another double-quote, "like this". To include a double-quote in a string, precede it with a backslash; thus, "\"" is a string containing just one double-quote character. Likewise, you can include a backslash by preceding it with another backslash, like this: "this \\ is a single embedded backslash".

Since a string is an array of characters, you can specify the string characters using the read syntax of characters, but without the leading question mark. This is useful for including in string constants characters that don’t stand for themselves. Thus, control characters can be specified as escape sequences that start with a backslash; for example, "foo\r" yields ‘foo’ followed by the carriage return character. See Basic Char Syntax, for escape sequences of other control characters. Similarly, you can use the special read syntax for control characters (see Control-Character Syntax), as in "foo\^Ibar", which produces a tab character embedded within a string. You can also use the escape sequences for non-ASCII characters described in General Escape Syntax, as in "\N{LATIN SMALL LETTER A WITH GRAVE}" and "\u00e0" (however, see a caveat with non-ASCII characters in Non-ASCII Characters in Strings).

The newline character is not special in the read syntax for strings; if you write a new line between the double-quotes, it becomes a character in the string. But an escaped newline—one that is preceded by ‘\’—does not become part of the string; i.e., the Lisp reader ignores an escaped newline while reading a string. An escaped space ‘ is likewise ignored.

"It is useful to include newlines
in documentation strings,
but the newline is \
ignored if escaped."
     ⇒ "It is useful to include newlines
in documentation strings,
but the newline is ignored if escaped."