Skip to content

Strings And Bytes

Strings are UTF-8 text values. Bytes are immutable binary buffers. Vela keeps the two categories separate so text APIs and binary APIs can have clear host and standard-library contracts.

Plain strings use "...", multiline strings use """...""", and interpolated strings must be explicitly prefixed with f. Plain strings never interpolate.

fn greeting(name: String) -> String {
return f"hello {name}"
}
fn template() -> String {
return """
line one
line two
"""
}

String methods cover predicates, transforms, search, split, parse helpers, and explicit traversal. len(), find(), and slice(start, end) are byte-indexed; chars() is UTF-8 character traversal.

fn parse_count(text: String) {
return text.trim().parse_i64()
}

Byte strings use b"...". Indexing a bytes value yields u8. Byte APIs should use explicit endian helpers rather than host-endian reads.

fn first_byte(packet: Bytes) -> u8 {
return packet[0]
}

Strings and bytes are heap-backed runtime values. Host APIs should declare whether they expect text or binary data; Vela will not silently convert between them.