4.24.2 White space normalization
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
      • Built-in Predicates
        • Character properties
          • White space normalization
            • normalize_space/2
    • Packages
Availability:built-in
normalize_space(-Out, +In)
Normalize white space in In. All leading and trailing white space is removed. All non-empty sequences of white space characters are replaced by a single space (\u0020) character. Out uses the same conventions as with_output_to/2 and format/3.

A character counts as white space if it satisfies code_type(Code, space), i.e., the C library function iswspace(). This depends on the locale. Using a Unicode locale this includes the Unicode separator characters such as \u00a0 (no-break space) and \u3000 (ideographic space), while in the C locale only the ASCII white space characters are recognised. Note that the bidi format characters \u200e and \u200f are not white space and are thus preserved.