package wax-lib
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=41b580846af8d41bdf6c3f005f62e38feda3e60fe2e9e4aa440db34ce515a153
sha512=4b3a181fcc7d743194a8647260870fb5190770066a197bcc48104c2b77fd40c643228b795c2bcd6b29a120820e969eb42a37a9bcec98b3f608d13f152d9f6579
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).