How to Normalize Unicode Strings in Rust

Normalize Unicode strings in Rust by adding the unicode-normalization crate and calling the nfc() method on your string.

Use the unicode-normalization crate to convert strings into a standard form like NFC or NFD. Add the dependency to your Cargo.toml and call normalize on your string.

[dependencies]
unicode-normalization = "0.1"
use unicode_normalization::UnicodeNormalization;

let s = "café";
let normalized = s.nfc().collect::<String>();