fn utf16_to_utf8(&self, utf16_range: Range<usize>) -> usize {
        if utf16_range.is_empty() {
            return 0;
        }
        let doc_range = 0..self.len();
        let text = self.slice(doc_range);
        //FIXME: we can do this without allocating; there's an impl in piet
        let utf16: Vec<u16> = text
            .encode_utf16()
            .skip(utf16_range.start)
            .take(utf16_range.end)
            .collect();
        String::from_utf16_lossy(&utf16).len()
    }
/// Returns the number of UTF-8 code units in the provided UTF-16 range.
///
/// Converts the document into UTF-16, looks up the range specified by
/// `utf16_range` (in UTF-16 code units), reencodes that substring into
/// UTF-8, and then returns the number of UTF-8 code units in that
/// substring.
///
/// This is automatically implemented, but you can override this if you have
/// some faster system to determine string length.
Returns the number of UTF-8 code units in the provided UTF-16 range.
Converts the document into UTF-16, looks up the range specified by
`utf16_range` (in UTF-16 code units), reencodes that substring into
UTF-8, and then returns the number of UTF-8 code units in that
substring.

This is automatically implemented, but you can override this if you have
some faster system to determine string length.
Returns the number of UTF - 8 code units in the provided UTF - 16 range . Converts the document into UTF - 16 looks up the range specified by ` utf16_range ` ( in UTF - 16 code units ) reencodes that substring into UTF - 8 and then returns the number of UTF - 8 code units in that substring . This is automatically implemented but you can override this if you have some faster system to determine string length .
fn utf16_to_utf8(&self, utf16_range: Range<usize>) -> usize {
        if utf16_range.is_empty() {
            return 0;
        }
        let doc_range = 0..self.len();
        let text = self.slice(doc_range);
        //FIXME: we can do this without allocating; there's an impl in piet
        let utf16: Vec<u16> = text
            .encode_utf16()
            .skip(utf16_range.start)
            .take(utf16_range.end)
            .collect();
        String::from_utf16_lossy(&utf16).len()
    }
fn utf16_to_utf8 ( & self , utf16_range : Range < usize > ) -> usize { if utf16_range . is_empty ( ) { return 0 ; } let doc_range = 0 .. self . len ( ) ; let text = self . slice ( doc_range ) ; //FIXME: we can do this without allocating; there's an impl in piet let utf16 : Vec < u16 > = text . encode_utf16 ( ) . skip ( utf16_range . start ) . take ( utf16_range . end ) . collect ( ) ; String :: from_utf16_lossy ( & utf16 ) . len ( ) }
Returns the number of UTF-8 code units in the provided UTF-16 range.
Returns the number of UTF - 8 code units in the provided UTF - 16 range .
&self
utf16_range
Range<usize>
&self
utf16_range
Range<usize>