String library: the Str8 / StrUtf8 protocol classes and the byte accessors.
The string library is the protocol classes Str8 / StrUtf8, with Str naming the active protocol (StrUtf8 by default). Use (Str append a b), (Str length s), etc.; (help Str8 method) for per-method docs.
Byte accessors str-length, str-ref, substring, str=? are always byte-level.
str-lengthByte length (raw octets). For element count in the active protocol use (Str length s).
Parameters:
STRING — String to measureReturns: INT — Byte length of s
Examples:
(%str-length "$¢€") => 6str-refByte at offset i, UNCHECKED: an out-of-range offset reads out of bounds – use (Str8 ref i s) for the checked byte view. For the i-th code point use (StrUtf8 ref i s) or the bare (s i) – equivalent, including negative i counting from the end.
Parameters:
STRING — String to indexINT — Byte offset (negative counts from the end)Returns: CHAR — The byte at offset i, as a CHARACTER (0-255)
Examples:
(%str-ref "$¢€" 1) => #\ÂsubstringByte substring [start, end) – the byte-level slice-convention primitive. Always byte-level.
Parameters:
STRING — Source stringINT — Start byte offsetINT — End byte offset (exclusive)Returns: STRING — The bytes [start, end) of s
Examples:
(%substring "abcdef" 1 4) => "bcd"str=?String equality (byte-level; the same result as code-point equality).
Parameters:
STRING — First stringSTRING — Second stringReturns: BOOL — #t if a and b are equal
Examples:
(str=? "ab" "ab") => #t