A string is delimited by either " or '. The closing delimiter must match the opening one, so an unescaped quote of the other kind is just a literal character.

The library remembers nothing about which quote character was used on read; strings are always written back double-quoted, escaping only the mandatory set (", \, control characters — with \b \f \n \r \t shorthands, \u00XX otherwise). All other bytes pass through as raw UTF-8.

Escape sequences

The escape set is:

  • the named escapes \" \' \ \/ \b \f \n \r \t \v \0;
  • \xXX — two hex digits;
  • \uXXXX — a UTF-16 code unit; surrogate pairs combine to encode characters beyond U+FFFF. \uXXXX decodes to UTF-8 in String::getValue(); a lone or invalid surrogate is reported and becomes U+FFFD;
  • a line continuation — a line-terminator sequence right after the backslash. The break is removed from the decoded string, letting a quoted literal span source lines;
  • any other character after \ is simply itself, with no error. This is a deliberate FSON simplification of the stricter JSON5 rule.

Raw U+2028 (LINE SEPARATOR) and U+2029 (PARAGRAPH SEPARATOR) may also appear unescaped inside a string.

Multi-line strings

The third form in the string diagram is the |-block — a value written as a run of |-lines instead of a quoted literal. It has its own page: Multi-line |-blocks.