How to iterate over characters

Iterate over characters in a Rust string using the .chars() method to handle UTF-8 encoding correctly.

Use the .chars() method on a String to iterate over its characters, which handles UTF-8 encoding correctly.

let text = "Hello, δΈ–η•Œ!";
for c in text.chars() {
    println!("Character: {}", c);
}

This loop prints each character individually, including multi-byte Unicode characters like "δΈ–" and "η•Œ".