Skip to content
Konjure / spatial intelligence

Str

← Builtin reference

Immutable UTF-8 text with canonical language type Str (String is an alias).

Signature

Clones share an Arc allocation. Concatenation creates a new value without implicit conversion. len, indexing, and slices count Unicode scalar values, while allocation limits count UTF-8 bytes. utf8 encodes to Bin and decode validates Bin as UTF-8. Text is the separate visible scene component.

Methods

len

len() -> f64

Returns the receiver's element, byte, or Unicode scalar count.

utf8

utf8() -> Bin

Encodes text as immutable UTF-8 bytes.

get

get(f64) -> Opt[Str]

Returns Some(value) for a valid index and None otherwise.

Examples

Join and measure text

The accented character counts as one scalar value even though it uses two UTF-8 bytes.

Tick 0 · 0.00 s⌘ / Ctrl + EnterThis device
main.kj
Loading the language runtime…
Output 0
No output.
Expected output
hello café
4

Rust definition

Value::Text(konjure_sdk::data::Str); shared immutable UTF-8 text.

See also