Function cesu8::cesu8_len[][src]

pub fn cesu8_len(str: &str) -> usize
Expand description

Returns how many bytes in CESU-8 are required to encode a string slice.

Examples

Basic usage:

use cesu8::cesu8_len;

// Any codepoint below or equal to U+FFFF is the same length as it is in
// UTF-8.
assert_eq!(3, cesu8_len("\u{FFFF}"));

// Any codepoint above U+FFFF is stored as a surrogate pair.
assert_eq!(6, cesu8_len("\u{10000}"));