expression

Compatibility normalization — NFKC and NFKD

Compatibility normalization can discard distinctions such as presentation forms or fullwidth variants. NFKC recomposes where possible; NFKD leaves the decomposed form. Choose deliberately for search and retain originals. Expected stdout (not executed): A1 A1 Common mistake: Treating compatibility normalization as lossless or a security sanitizer.

Formal Syntax & Structure

rust syntaxrust
text.nfkc(); text.nfkd();

Working Example

Example Snippetrust
fn main() {    use unicode_normalization::UnicodeNormalization;    let s = "A①";    let a: String = s.nfkc().collect();    let b: String = s.nfkd().collect();    println!("{a} {b}");}
Rust Reference