package wax-lib
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=4361e1324b7754a4c08ab5b505df32061f3ce0cea60443fd0d3699e0fa796b32
sha512=fcc756d2f160ba90a9aa1131f2ab22ed7f45466ccd658c21cf9df6868a6aab0cee7f404719d698a379958802f9820398f2fe0685ecc4dda018ca4f653294e39b
doc/wax-lib.utils/Wax_utils/Unicode/index.html
Module Wax_utils.UnicodeSource
terminal_width s returns the width of the string s when displayed in a terminal.
The optional argument offset (default 0) specifies the starting column position, which is used to correctly calculate the width of tab characters.
expand_tabs s returns a copy of s where tab characters are replaced by spaces, assuming a tab width of 8.
The optional argument offset (default 0) specifies the starting column position.
utf16_code_units s is the sequence of UTF-16 code units (each a 16-bit value) encoding the valid-UTF-8 string s; a scalar outside the basic multilingual plane becomes a surrogate pair (two units).
utf16_length s is the number of UTF-16 code units that encode s (equivalently List.length (utf16_code_units s), without building the list). Editors such as VS Code count character positions in these units.
utf16_offset_to_byte s n is the byte offset in s just after its first n UTF-16 code units — the inverse of utf16_length for a prefix. Clamped to String.length s; if n falls inside a surrogate pair the offset is past that whole scalar.
utf16_decode units is the UTF-8 string the UTF-16 units (each a 16-bit value) encode — the inverse of utf16_code_units — pairing surrogates. None if a surrogate is unpaired.
scalar_of_hex s decodes the hex digits s (the payload of a \u{...} escape) to a Unicode scalar value. None if s is not valid hex, overflows a native int, or is out of the scalar range (above U+10FFFF or a surrogate).
escape_string s returns a pair (len, escaped) where escaped is the escaped version of s suitable for WAT/Wax string literals, and len is its display length.
Byte escapes are written \HH by default; hex_prefix is inserted after the backslash, so ~hex_prefix:"x" produces Rust-style \xHH escapes for Wax.
has_hex_escape s is true if s contains a control character that requires a hex escape in WAT (e.g. below U+0020 other than tab/cr/nl, or U+007F).
char_width pos u returns the display width of the Unicode character u, accounting for tabs assuming starting position pos.
first_confusable s is the first "confusing" bidirectional control character in s, if any — the Unicode text-direction overrides and isolates of the "Trojan Source" class (U+202A/B/D/E, U+2066/7/8, U+206C, U+2069), which can make displayed text read differently from its bytes. The set matches what wasm-tools rejects in string literals.