A string is an array of characters. Strings are used for many purposes in SXEmacs, as can be expected in a text editor; for example, as the names of Lisp symbols, as messages for the user, and to represent text extracted from buffers. Strings in Lisp are constants: evaluation of a string returns the same string.
The read syntax for strings is a double-quote, an arbitrary number of
characters, and another double-quote,
"like this". The Lisp
reader accepts the same formats for reading the characters of a string
as it does for reading single characters (without the question mark that
begins a character literal). You can enter a nonprinting character such
as tab or C-a using the convenient escape sequences, like this:
"\t, \C-a". You can include a double-quote in a string by
preceding it with a backslash; thus,
"\"" is a string containing
just a single double-quote character. (See Character Type, for a
description of the read syntax for characters.)
The printed representation of a string consists of a double-quote, the
characters it contains, and another double-quote. However, you must
escape any backslash or double-quote characters in the string with a
backslash, like this:
"this \" is an embedded quote".
An alternative syntax allows insertion of raw backslashes into a
string, like this:
#r"this \ is an embedded backslash". In such
a string, each character following a backslash is included literally in
the string, and all backslashes are left in the string. This means that
#r"\"" is a valid string literal with two characters, a backslash and a
double-quote. It also means that a string with this syntax cannot end
in a single backslash.
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.
"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."
A string can hold extents and properties of the text it contains, in addition to the characters themselves. This enables programs that copy text between strings and buffers to preserve the extents and properties with no special effort. See Extents, See Text Properties.
Note that FSF GNU Emacs has a special read and print syntax for
strings with text properties, but SXEmacs does not currently implement
this. It was judged better not to include this in SXEmacs because it
nil when passed a string with
text properties and the equivalent string without text properties, which
is often counter-intuitive.
See Strings and Characters, for functions that work on strings.