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.6 KiB
1.6 KiB
When To Use std.ascii
In Zerolang, use std.ascii when a program needs byte-level ASCII predicates, case
conversion, or digit values without Unicode normalization.
Runnable today:
| API | Return | Notes |
|---|---|---|
std.ascii.isDigit(byte) |
Bool |
Checks 0 through 9. |
std.ascii.isAlpha(byte) |
Bool |
Checks A through Z or a through z. |
std.ascii.isAlnum(byte) |
Bool |
Checks ASCII alphabetic or digit bytes. |
std.ascii.isWhitespace(byte) |
Bool |
Checks space, tab, line feed, and carriage return. |
std.ascii.isLower(byte) / std.ascii.isUpper(byte) |
Bool |
Checks ASCII case ranges. |
std.ascii.isHexDigit(byte) |
Bool |
Checks decimal digits and a-f / A-F. |
std.ascii.toLower(byte) / std.ascii.toUpper(byte) |
u8 |
Converts ASCII letters and leaves other bytes unchanged. |
std.ascii.digitValue(byte) |
Maybe<u8> |
Converts an ASCII decimal digit to 0..9. |
std.ascii.hexValue(byte) |
Maybe<u8> |
Converts an ASCII hexadecimal digit to 0..15. |
Example
pub fn main(world: World) -> Void raises {
let digit: Maybe<u8> = std.ascii.digitValue(55_u8)
let hex: Maybe<u8> = std.ascii.hexValue(70_u8)
if std.ascii.isAlpha(65_u8) && std.ascii.toLower(90_u8) == 122_u8 && digit.has && digit.value == 7_u8 && hex.has && hex.value == 15_u8 {
check world.out.write("ascii ok\n")
}
}
Effects: none.
Allocation behavior: no allocation.
Error behavior: value helpers return null when the byte is outside the accepted range.
Target support: current compiler targets.