Skip to Content

String

Strings are written in double quotes and are UTF-8 text. The full set of forms is four, shown in the table below:

FormEscapesInterpolatesMultiline
"..."yes——
$"..."yesyes—
r"..." / r#"..."#——yes
r$"..." / r$#"..."#—yesyes

The full escape set

Plain strings and $ interpolation strings support the following escapes (the same table as char literals):

EscapeMeaning
\n \r \t \0newline, carriage return, tab, null
\ \" \'backslash, double quote, single quote
\xHHa code point of exactly two hex digits
\u{HEX}any number of hex digits in braces; beyond 10FFFF or into the surrogate range reports MS1004

An illegal escape reports MS1004 but is still consumed. Plain strings cannot span lines: a real newline in the source is treated as unterminated.

Raw strings

A raw string (the r prefix) honors no escapes and does no interpolation: what you write is what you get, and the literal segment can span lines directly. The # marks must close in matching pairs; an unmatched " is an ordinary character, so r#"..."# may contain ":

val path = r"C:\Users\Mushreb"; print(path); val poem = r#"first line second line "with quotes" third line"#; print(poem);
C:\Users\Mushreb first line second line "with quotes" third line

r only triggers a raw string when immediately followed by " or #"; otherwise it parses as an ordinary identifier. When a string needs escapes, multiline, and interpolation all at once, use r$#"..."# (see Interpolation).

Notes

  • Strings are immutable: no method can modify an existing string; every transformation produces a new string;
  • String length counts grapheme clusters: the length of "a🙂b" is 3; details on the Unicode and Grapheme Clusters page;
  • Searching, slicing, transforming, formatting, and the rest of the operation set are covered on the Text Processing page;
  • Parsing strings into numbers does not go through conversion; it goes through the T(v) parsing channel (int(s) and friends; see Type Conversions).
Last updated on October 11, 2026