LEARN VOID / DATA & BEHAVIOR

Strings & Unicode

Use one text type throughout ordinary code.

strings.voidDownload source ↓
const greeting = "Hello, "
const target = greeting + "世界"

value struct label:
    text: string

struct message:
    title: string = "untitled"
    payload: label

func echo(const text: string) -> string:
    return text

func entry(value: i32) -> i32:
    var empty: string
    var m = message(payload = label(text = target))
    const snapshot = echo(m.payload.text)
    var changed = snapshot
    changed += "!"
    if empty == "" and snapshot == "Hello, 世界" and changed != snapshot and m.title == "untitled":
        return value + 1
    return -100
Input 5Expected result 6

Write UTF-8 text directly

string represents UTF-8 text. Double-quoted literals can contain text such as 世界 directly, and + concatenates strings. An uninitialized string in a defaultable field or local begins as the empty string.

Keep text values independent

The example keeps a readonly snapshot, copies it into a mutable local and appends an exclamation mark. The snapshot remains unchanged. A string field can also provide a default value such as untitled.

Understand the boundary

String equality does not automatically normalize Unicode representations. The language also supports documented escape sequences. Do not assume every proposed text API or interpolation example is available; this guide demonstrates the implemented literal, concatenation and copy behavior.