Strings
The Quick Tour already introduced String: immutable Utf-8 text, ASCII-7 as a proper subset, and the caution that str::len is a byte length, not a character count. Literals (quoted, raw, and rune ticks) are covered under Interpreter. Comparison of two Strings uses Utf-8 byte ordering (Basic Operators).
This section is the day-to-day API for working with text:
| Page | Contents |
|---|---|
| Unicode and Utf-8 | How Utf-8 is coded, why finds stay unambiguous, and why that does not slow ordinary string work |
| String Operators | The full str:: family: length, trim, case, concat, probes, split/join |
| Iterating Runes | foreach over a String (code points as Int) plus a worked census example |
| StringBuilder | Mutable accumulation when many concatenations would be costly |
A few design points that shape every API below:
- Immutability — every
str::“mutation” returns a new String; the inputs are unchanged. - Stack operators, not instance methods — text helpers are the
str::…words (same family style as other axiom groups). Park a String on ts only when you need several rooted object ops around it; for pure string transforms, keep values on DS. - No byte-indexed substring — cutting at an arbitrary byte offset can split a multi-byte character. Build pieces with
StringBuilder, usestr::indexOf/str::sub/str::split, or iterate runes (this section and TextReader). - Truthy —
""is false; any non-empty String is true (Basic Types).
For line-oriented or file-backed text, prefer Text and Byte Streams. For pattern matching, see Regex (later in the survey).