Function split_graphemes

Source
pub fn split_graphemes(s: &str) -> Vec<&str>
Expand description

Re-exports: Primary public API Returns all grapheme clusters in the input string as a vector of string slices.

This function uses Unicode text segmentation to split the input into grapheme clusters, which represent user-perceived characters. It correctly preserves multi-codepoint graphemes such as emoji with skin tone modifiers, ZWJ sequences, and composed Hangul.

Useful when you need to iterate over characters in a way that aligns with human perception.

ยงArguments

  • s - The input string to split

ยงReturns

A vector of &str, each representing a single grapheme cluster in order.

ยงExample

use runefix_core::split_graphemes;

let clusters = split_graphemes("Love๐Ÿ‘ฉโ€โค๏ธโ€๐Ÿ’‹โ€๐Ÿ‘จ็ˆฑ");
assert_eq!(clusters, vec!["L", "o", "v", "e", "๐Ÿ‘ฉโ€โค๏ธโ€๐Ÿ’‹โ€๐Ÿ‘จ", "็ˆฑ"]);