Skip to main content

Characters and Strings

Construction

TypeDescription
"a"charA single character.
"abc"stringA single-line string.
"""abc"""stringA multiline string.
char(<int>)charTakes an integer and returns the character with the corresponding Unicode code point.
string(<char>)stringConstructs a string of length 1 with the single character.

Strings or characters can include the following special characters:

  • the escaped special characters \0 (null character), \ (backslash), \t (horizontal tab), \n (line feed), \r (carriage return), \” (double quote) and \’ (single quote)
  • an arbitrary Unicode scalar, written as \u{n}, where n is a 1-8 digit hexadecimal number with a value equal to a valid Unicode code point.

Operations

Comparisons

Strings

Comparison binary operators e.g. =, <>, >, <, …, do a lexicographical string comparison.

Example
"A" > "a" // true
"aab" > "aaa" // true
"a" > null // null

Characters

Character type supports the comparison binary operators, which compares the underlying Unicode code point value:

'b' > 'a' // true
null > 'a' // null

Casts

Strings can be casted to:

  • number types. In the case of decimal this can be used to convert a user constant (string) into a lossless number.
  • temporal types.

Characters can be casted to strings, which creates a string with a single character.