byte_index_for_char

Function byte_index_for_char 

Source
pub fn byte_index_for_char(s: &str, ci: usize) -> usize
Expand description

What: Convert a character index to a byte index for slicing.

Input: s source string; ci character index Output: Byte index into s corresponding to ci

Details: Returns 0 for ci==0; returns s.len() when ci>=char_count(s); otherwise maps the character index to a byte offset via char_indices().