Skip to main content

normalize

Function normalize 

Source
pub fn normalize(s: &str) -> String
Expand description

Trim, lowercase, and strip diacritics.

Steps:

  1. Trim surrounding whitespace
  2. Lowercase (Unicode-aware)
  3. Decompose to NFD
  4. Drop combining marks (Unicode category Mn)
  5. Recompose to NFC

§Examples

use matchr::normalize;

assert_eq!(normalize("Café"), "cafe");
assert_eq!(normalize(" Hello "), "hello");