fn calc_byte_position(text: &[char], pos: usize) -> usize