e7738de6d2
CI / Deep Native Runtime Cases (1/6) (push) Has been skipped
CI / Native Preflight (push) Failing after 1s
CI / Native Runtime Cases (1/2) (push) Failing after 0s
CI / Native Runtime Cases (2/2) (push) Failing after 1s
CI / Native Metadata Reports (push) Failing after 0s
CI / Native Direct Backend Artifacts (push) Failing after 0s
CI / Native Sanitizer Smoke (push) Failing after 1s
CI / Command Contract Snapshots (push) Failing after 1s
CI / Deep Conformance Suite (push) Has been skipped
CI / Graph Build Perf (push) Failing after 1s
CI / Deep Native Preflight (push) Has been skipped
CI / Deep Native Runtime Cases (2/6) (push) Has been skipped
CI / Deep Native Runtime Cases (3/6) (push) Has been skipped
CI / Conformance Suite (push) Failing after 1s
CI / Workspace Checks (push) Failing after 0s
CI / Deep Native Runtime Cases (5/6) (push) Has been skipped
CI / Deep Native Runtime Cases (6/6) (push) Has been skipped
CI / Deep Native Runtime Cases (4/6) (push) Has been skipped
CI / Deep Graph Build Perf (push) Has been skipped
1.2 KiB
1.2 KiB
When To Use std.text
In Zerolang, use std.text for ASCII and UTF-8 byte-backed validation.
Runnable today:
std.text is for byte-backed text validation and counting. It does not imply
locale-aware case mapping, grapheme segmentation, normalization, or display-width
rules.
| API | Return | Notes |
|---|---|---|
std.text.isAscii(text) |
Bool |
Checks that every byte is below 0x80. |
std.text.utf8Valid(text) |
Bool |
Validates UTF-8 byte structure, rejecting overlong encodings, surrogate code points, and values above U+10FFFF. |
std.text.utf8Len(text) |
Maybe<usize> |
Counts Unicode scalar values when UTF-8 is valid; returns null on invalid input. |
Example
pub fn main(world: World) -> Void raises {
let valid: [2]u8 = [195_u8, 169_u8]
let invalid: [1]u8 = [128_u8]
let len: Maybe<usize> = std.text.utf8Len(valid)
if !std.text.isAscii(valid) && std.text.utf8Valid(valid) && !std.text.utf8Valid(invalid) && len.has && len.value == 1 {
check world.out.write("text ok\n")
}
}
Effects: none.
Allocation behavior: no allocation.
Error behavior: utf8Len returns null for invalid UTF-8.
Target support: current compiler targets.