Skip to main content

normalize_spaces

Function normalize_spaces 

Source
pub fn normalize_spaces(x: &str) -> Cow<'_, str>
Expand description

Folds every Unicode space separator (category Zs: NBSP U+00A0, U+1680, U+2000–U+200A, the narrow NBSP U+202F, U+205F, U+3000) to an ASCII space. The parser’s own whitespace handling is ASCII-only (Java parity: String.trim(), Character.isWhitespace, and the (?-u:\s) regexes all skip NBSP), so an NBSP left in place glues words together and hides keywords from every stage — Assimineidae\u{a0}incertae\u{a0}sedis read as a monomial with the author incertae sedis. Runs once on the raw input, before java_trim, so the guards and every later stage see plain spaces. Borrows when there is nothing to fold (the common case).