title: Why is non-breaking space not a whitespace character in Java?
body: <p>While searching for a proper way to trim non-breaking space from parsed HTML, I've first stumbled on Java's spartan definition of <code>String.trim()</code> which is at least properly documented. I wanted to avoid explicitly listing characters eligible for trimming, so I assumed that using Unicode backed methods on the <em>Character</em> class would do the job for me.</p>
  <p>That's when I discovered that <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Character.html#isWhitespace%28char%29" rel="nofollow noreferrer">Character.isWhitespace(char)</a> explicitly excludes non-breaking spaces:</p>
  <blockquote>
  <p>It is a Unicode space character (<code>SPACE_SEPARATOR</code>, <code>LINE_SEPARATOR</code>, or <code>PARAGRAPH_SEPARATOR</code>) <strong>but is not also a non-breaking space</strong> (<code>'\u00A0'</code>, <code>'\u2007'</code>, <code>'\u202F'</code>).</p>
  </blockquote>
  <p>Why is that?</p>
  <p>The implementation of <a href="http://msdn.microsoft.com/en-us/library/t809ektx.aspx" rel="nofollow noreferrer">corresponding .NET equivalent</a> is less discriminating.</p>