OxL Reference

data Utf8

UTF-8 text/bytes conversion (II.1 Utf8).

Example:

oxl✓ checked in CI
fn main() io {
  let b = Utf8.encode("héllo")
  print("{b.len()} {Utf8.decode(b)!}")
}
Output
6 héllo
pub(api) data Utf8

Thread safety. a namespace without state; safe from any task.

Since. 1.0.0-beta

Methods

encode(text: str) -> bytes
The UTF-8 bytes of a text.
isValid(b: bytes) -> bool
True when b is well-formed UTF-8.
decode(b: bytes) -> str | DecodeError
The text of well-formed UTF-8 bytes, else DecodeError.

Defined in: std/core/text.oxl:1036

See also