Skip to content

Latest commit

 

History

History
21 lines (16 loc) · 805 Bytes

graphemes.zh.md

File metadata and controls

21 lines (16 loc) · 805 Bytes

收集 Unicode 字形

![unicode-segmentation-badge] [![cat-text-processing-badge]][cat-text-processing]

unicode-segmentation箱子的UnicodeSegmentation::graphemes函数,可用来,从 UTF-8 字符串中,收集单个 Unicode 字形。

#[macro_use]
extern crate unicode_segmentation;
use unicode_segmentation::UnicodeSegmentation;

fn main() {
    let name = "José Guimarães\r\n";
    let graphemes = UnicodeSegmentation::graphemes(name, true)
    	.collect::<Vec<&str>>();
	assert_eq!(graphemes[3], "é");
}