Use the unicode_segmentation crate's Graphemes iterator to split a string into user-perceived characters, handling complex cases like emojis and combining marks correctly.
use unicode_segmentation::UnicodeSegmentation;
let text = "Hello 🌍!";
for grapheme in text.graphemes(true) {
println!("{grapheme}");
}
This code prints each grapheme cluster on a new line, ensuring that multi-byte characters like the globe emoji are treated as single units.