Function bytecount::naive_num_chars[][src]

pub fn naive_num_chars(utf8_chars: &[u8]) -> usize
Expand description

Count the number of UTF-8 encoded Unicode codepoints in a slice of bytes, simple

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::naive_num_chars(swordfish.as_bytes());
assert_eq!(char_count, 4);