manpagez: man pages & more
info guile
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.6.5.1 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, 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).

\a

Bell character (ASCII 7).

\f

Formfeed character (ASCII 12).

\n

Newline character (ASCII 10).

\r

Carriage return character (ASCII 13).

\t

Tab character (ASCII 9).

\v

Vertical tab character (ASCII 11).

\b

Backspace character (ASCII 8).

\0

NUL character (ASCII 0).

\ 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"
⇒ "foo  bar"
(read-enable 'hungry-eol-escapes)
"foo\
  bar"
⇒ "foobar"
\xHH

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

\uHHHH

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

\UHHHHHH

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

The following are examples of string literals:

"foo"
"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 section Reading Scheme Code.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on April 20, 2013 using texi2html 5.0.

© manpagez.com 2000-2024
Individual documents may contain additional copyright information.