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§
- UtfIndex
Clamp - 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.