Skip to main content

utf16_offset

Function utf16_offset 

Source
pub fn utf16_offset(s: &str, cp: usize) -> Option<usize>
Expand description

The UTF-16 offset (in 16-bit units, as JavaScript counts) in s of code point index cp; None beyond the end.

// The emoji is one code point and two UTF-16 units.
assert_eq!(keyhammer::text::utf16_offset("a😀b", 2), Some(3));