Warning: This is the manual of the legacy Guile 2.0 series. You may want to read the manual of the current stable series instead.

Next: , Up: Strings   [Contents][Index] String Read Syntax

The read syntax for strings is an arbitrarily long sequence of characters enclosed in double quotes (").

Backslash is an escape character and can be used to insert the following special characters. \" and \\ are R5RS standard, \| is R7RS standard, the next seven are R6RS standard — notice they follow C syntax — and the remaining four are Guile extensions.


Backslash character.


Double quote character (an unescaped " is otherwise the end of the string).


Vertical bar character.


Bell character (ASCII 7).


Formfeed character (ASCII 12).


Newline character (ASCII 10).


Carriage return character (ASCII 13).


Tab character (ASCII 9).


Vertical tab character (ASCII 11).


Backspace character (ASCII 8).


NUL character (ASCII 0).


Open parenthesis. This is intended for use at the beginning of lines in multiline strings to avoid confusing Emacs lisp modes.

\ followed by newline (ASCII 10)

Nothing. This way if \ is the last character in a line, the string will continue with the first character from the next line, without a line break.

If the hungry-eol-escapes reader option is enabled, which is not the case by default, leading whitespace on the next line is discarded.

⇒ "foo  bar"
(read-enable 'hungry-eol-escapes)
⇒ "foobar"

Character code given by two hexadecimal digits. For example \x7f for an ASCII DEL (127).


Character code given by four hexadecimal digits. For example \u0100 for a capital A with macron (U+0100).


Character code given by six hexadecimal digits. For example \U010402.

The following are examples of string literals:

"bar plonk"
"Hello World"
"\"Hi\", he said."

The three escape sequences \xHH, \uHHHH and \UHHHHHH were chosen to not break compatibility with code written for previous versions of Guile. The R6RS specification suggests a different, incompatible syntax for hex escapes: \xHHHH; – a character code followed by one to eight hexadecimal digits terminated with a semicolon. If this escape format is desired instead, it can be enabled with the reader option r6rs-hex-escapes.

(read-enable 'r6rs-hex-escapes)

For more on reader options, See Scheme Read.

Next: , Up: Strings   [Contents][Index]