Skip to main content

count_code_points

Function count_code_points 

Source
pub fn count_code_points(text: &str) -> u32
Expand description

Counts the number of Unicode code points in a string

§Arguments

  • text - The text to count code points in

§Returns

The number of Unicode code points in the text

§Examples

use dom_content_extraction::unicode::count_code_points;

let text = "café"; // 4 letters, 5 bytes in UTF-8
assert_eq!(count_code_points(text), 4); // Not 5 bytes