24.9 · Unicode equivalence, word boundaries and regional defaults

Text is not a sequence of characters you can slice and compare byte by byte, and regions differ in far more than strings. These checks show what Swift and Foundation do for you.

Mental model. Compare with canonical equivalence, split with a language-aware tokenizer, and read regional defaults from the Locale.

Text

Unicode, tokenizing, regional defaults.

  1. Why can two visually identical strings differ in bytes, and how do equality, normalisation and case conversion behave for international text? 24.9.1 · L3
    Unicode lets the same text be written in different ways. “é” can be one scalar (U+00E9) or an “e” followed by a combining accent (U+0065 U+0301). The check…
  2. How do you split text into words, count words or search in languages that do not use spaces? 24.9.2 · L3
    Splitting on spaces works for English and fails for Chinese, Japanese and Thai, which write words without spaces between them. Use the NaturalLanguage…
  3. What regional defaults should you read from the Locale instead of assuming: units, 12 or 24 hours, ordinals and date order? 24.9.3 · L3
    The Locale carries decisions you would otherwise guess wrong. The check lists them for six locales: the measurement system (United States uses its own system…

More in Accessibility & localization