{
  "id": 17300088,
  "title": "How hard is it to check for whitespace?",
  "url": "https://urgent.news/2026/10/30/how-hard-is-it-to-check-for-whitespace",
  "topic": "world",
  "section": "World",
  "published": "2026-10-30T22:25:49.000Z",
  "source": {
    "name": "Lobsters",
    "slug": "lobsters",
    "url": "https://serce.me/posts/2026-10-30-how-hard-is-it-to-check-for-whitespace"
  },
  "original_language": "en",
  "account": "A seemingly simple Java method from the popular Guava library, which checks if a character is a whitespace character, is actually more complex than a straightforward c == check. This complexity arises from the wide variety of whitespace characters defined by Unicode. While the common SPACE character (U+0020) is the most well-known, there are 25 other whitespace characters, each serving a different purpose. These include the non-breaking space (U+00A0), tab (U+0009), and newline (U+000A) characters, as well as format characters like ZERO WIDTH SPACE (U+200B) and OGHAM SPACE MARK (U+1680).\n\nThe issue of what constitutes whitespace becomes even more complicated when considering different programming languages. For instance, Java's Character.isWhitespace() method excludes the NO-BREAK SPACE (U+00A0) but Python's str.isspace() method includes it. JavaScript, on the other hand, recognizes ZERO WIDTH NO-BREAK SPACE (U+FEFF) as whitespace, but not NEXT LINE (U+0085).\n\nFurthermore, these definitions are not static, as Unicode, the organization responsible for standardizing these characters, regularly updates its list. A recent update from Unicode 6.3 removed the MONGOLIAN VOWEL SEPARATOR (U+180E) from the set of whitespace characters, changing the count from 26 to 25. This constant evolution poses challenges for runtimes and libraries that aim for backwards compatibility, as they must adapt to these changes while maintaining stability.\n\nTo efficiently check for these characters, Guava uses a perfect hash function. This involves creating a table (an array) with a fixed number of slots (32 in this case) that map each index to a character. The index is calculated using a specific mathematical formula involving the character's Unicode code point. This method ensures no hash collisions for the known set of whitespace characters, thus providing an efficient and reliable way to check for whitespace.",
  "summary": null,
  "key_points": [
    "Guava library's whitespace check method is more complex than simple character check",
    "25 Unicode-defined whitespace characters, including SPACE, tab, newline",
    "Backwards compatibility challenges due to Unicode's evolving whitespace list"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}