Skip to main content

Module utf

Module utf 

Source
Expand description

UTF-8 / UTF-16 index conversion helpers.

These utilities are primarily intended for platform bridges (e.g. wasm DOM IME/text input), where selection and composition ranges are typically expressed in UTF-16 code unit offsets.

Conversions are deterministic and clamp to valid UTF-8 char boundaries.

Enums§

UtfIndexClamp
Clamp strategy when converting an offset that may land inside a multi-unit character.

Functions§

utf8_byte_offset_to_utf16_offset
Convert a UTF-8 byte offset into a UTF-16 code unit offset.
utf8_byte_range_to_utf16_range
Convert a UTF-8 byte range to a UTF-16 range.
utf16_offset_to_utf8_byte_offset
Convert a UTF-16 code unit offset into a UTF-8 byte offset.
utf16_range_to_utf8_byte_range
Convert a UTF-16 range to a UTF-8 byte range.