pub fn utf16_to_utf8_offset(text: &str, utf16_offset: usize) -> usizeExpand description
Converts a UTF-16 code-unit offset into a UTF-8 byte offset.
The reverse of utf8_to_utf16_offset. Use it on ranges that the platform
sends, before slicing a String. An offset past the end returns the UTF-8
length of text. An offset inside a surrogate pair returns the offset of the
end of that character.
§Examples
use gpui::utf16_to_utf8_offset;
assert_eq!(utf16_to_utf8_offset("A😀B", 3), 5);
assert_eq!(utf16_to_utf8_offset("A😀B", 100), 6);