Function bytecount::num_chars [−][src]
Expand description
Count the number of UTF-8 encoded Unicode codepoints in a slice of bytes, fast
This function is safe to use on any byte array, valid UTF-8 or not, but the output is only meaningful for well-formed UTF-8.
Example
let swordfish = "メカジキ";
let char_count = bytecount::num_chars(swordfish.as_bytes());
assert_eq!(char_count, 4);