Rust 1.53 seems to handle these correctly - feedback welcome. let s = String::from("noël"); println!("Printable? {}", s); println!("Countable? {}", s.chars().count()); println!("Reversable? {}", s.chars().rev().collect:: ()); println!("First three characters? {}", s.chars().take(3).collect:: ()); Output: Printable? noël Countable? 4 Reversable? lëon First three characters? noë Repo for the "noël" example and "cats" e…
It does not. Your code is using precomposed instead of decomposed chars. Try: let s = String::from("noe\u{0308}l"); println!("Reversable? {}", s.chars().rev().collect:: ()); println!( "First three characters? {}", s.chars().take(3).collect:: () ); you get l̈eon which (according to the article) is wrong; likewise "noe" as the first three chars, dropping the diacritic.
There's no value in a String type if it doesn't behave for text. One can simply use a "Array" to convey proper semantic meaning.