Skip to main content

split_graphemes

Function split_graphemes 

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

Segment a UTF-8 string into Unicode UAX #29 Extended Grapheme Clusters.

Keeps together:

  • CRLF (\r\n)
  • Base characters + combining marks, variation selectors, and enclosing marks
  • Emoji skin-tone modifiers (\u{1F3FB}..=\u{1F3FF})
  • Zero-Width Joiner (\u{200D}) emoji sequences (e.g. "๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ", "๐Ÿ‘ฉโ€๐Ÿš€")
  • Regional Indicator flag pairs (\u{1F1E6}..=\u{1F1FF} in pairs, e.g. "๐Ÿ‡ฆ๐Ÿ‡บ")