Language reference
Strings and Unicode
Work with immutable UTF-8 text and scalar-based indexes.
String is immutable, well-formed UTF-8 text. Use double-quoted literals and + for concatenation. Numbers and Boolean values are not implicitly formatted as Strings.
fn greeting(name: String) -> String:
"Hello, " + name
fn main() -> String:
greeting("Kalandra") This returns Hello, Kalandra. The executable displays the String contents without source-code quotes.
Length is measured in Unicode scalars
length(text) returns a count of Unicode scalar values; byteLength(text) counts UTF-8 bytes. Neither is a count of user-perceived grapheme clusters. Combining marks can contribute additional scalars.
fn main() -> int:
text = "سلام"
length(text) + byteLength(text) This returns 12: four Unicode scalars encoded in eight UTF-8 bytes.
Index and slice
fn main() -> String:
text = "Kalandra"
slice(text, 0, 3) + text[7] This returns Kala: slice(text, 0, 3) is Kal, and text[7] is a. Indexes are zero-based scalar indexes. slice uses a half-open start/end range, with both endpoints checked; it does not clamp or wrap. An indexed scalar is returned as a String, not a separate Char type.
Equality and lifetime
== and != compare exact scalar sequences. No normalization or locale-dependent collation is inserted. Strings can be used in CPU workers, closures, arrays and supported record or enum fields. Their text remains valid while those values need it. GPU numerical functions do not accept Strings.
Escapes include a quoted double quote, a backslash, newline, carriage return, tab, zero and Unicode-scalar escapes. Invalid UTF-8 and invalid escapes are diagnosed. String interpolation, raw multiline strings and general text parsing are not supported.