use unicode_normalization::UnicodeNormalization;
use unicode_normalization::char::is_combining_mark;
pub fn fold_text(input: &str) -> String {
input
.nfd()
.filter(|c| !is_combining_mark(*c))
.flat_map(|c| c.to_lowercase())
.collect()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn folds_case_and_accents() {
assert_eq!(fold_text("Müller"), "muller");
assert_eq!(fold_text("MÜLLER"), "muller");
assert_eq!(fold_text("muller"), "muller");
assert_eq!(fold_text("Café"), "cafe");
assert_eq!(fold_text("naïve"), "naive");
assert_eq!(fold_text("ÀÉÎÕÜ"), "aeiou");
}
#[test]
fn leaves_plain_ascii_unchanged_except_case() {
assert_eq!(fold_text("Smith"), "smith");
assert_eq!(fold_text("smith"), "smith");
}
}