OxL Справочник OxL
РусскийEnglish

data Utf8

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

Example:

oxl✓ проверяется в CI
fn main() io {
  let b = Utf8.encode("héllo")
  print("{b.len()} {Utf8.decode(b)!}")
}
Вывод
6 héllo
pub(api) data Utf8

Потокобезопасность. a namespace without state; safe from any task.

С версии. 1.0.0-beta

Методы

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.

Определено в: std/core/text.oxl:1036

См. также