pub fn to_byte_idx(text: &str, utf16_idx: usize) -> usize
Expand description

Converts from utf16-code-unit-index to byte-index in a string slice.

If the utf16 index is in the middle of a char, returns the bytes index of the char that utf16 code unit belongs to.

Any past-the-end index will return the one-past-the-end byte index.

Runs in O(N) time.