Class UnicodeWhitespace
This is a static, immutable table of the 25 code points that carry the Unicode
White_Space property, and the related 6 code points that are commonly mistaken
for whitespace but carry White_Space=no (zero-width and other format characters).
The data mirrors the tables in
Whitespace character
and the Unicode Character Database (PropList.txt).
The membership test is deliberately built from this explicit table rather than from
Character.isWhitespace(int) or Character.isSpaceChar(int), both of which
disagree with the Unicode White_Space property. Character.isWhitespace
excludes the non-breaking spaces and NEL but includes the information-separator
controls U+001C-U+001F; Character.isSpaceChar excludes tab, newline,
and the other line breaks. isWhitespace(int) matches the standard exactly.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumLine-breaking behavior, mirroring the "Notes" column of the reference table.static enumUnicode general category for a whitespace or related code point.static final recordOne related code point that is commonly confused with whitespace but is not (White_Space=no).static final recordOne Unicode whitespace code point and its reference attributes. -
Method Summary
Modifier and TypeMethodDescriptionall()Returns the25Unicode whitespace characters, in ascending code point order.byCodePoint(int codePoint) Looks up the reference entry for a whitespace code point.static int[]Returns the whitespace code points, in ascending order.static booleanisLookalike(int codePoint) Tests whether a code point is one of the related, non-whitespace look-alike format characters.static booleanisWhitespace(int codePoint) Tests whether a code point carries the UnicodeWhite_Spaceproperty.Returns the whitespace characters that force a line or paragraph break.Returns the related, non-whitespace look-alike format characters.Returns the non-breaking whitespace characters.
-
Method Details
-
isWhitespace
public static boolean isWhitespace(int codePoint) Tests whether a code point carries the UnicodeWhite_Spaceproperty.- Parameters:
codePoint- The code point to test. Out-of-range values (negative or beyondCharacter.MAX_CODE_POINT) simply returnfalse.- Returns:
trueif the code point is one of the25Unicode whitespace characters.
-
isLookalike
public static boolean isLookalike(int codePoint) Tests whether a code point is one of the related, non-whitespace look-alike format characters.- Parameters:
codePoint- The code point to test.- Returns:
trueif the code point is in thelook-alikeset.
-
byCodePoint
Looks up the reference entry for a whitespace code point.- Parameters:
codePoint- The code point.- Returns:
- The
UnicodeWhitespace.WhitespaceCharacter, orOptional.empty()if it is not whitespace.
-
all
Returns the25Unicode whitespace characters, in ascending code point order.- Returns:
- the
25Unicode whitespace characters, in ascending code point order
-
lookalikes
Returns the related, non-whitespace look-alike format characters.- Returns:
- the related, non-whitespace look-alike format characters
-
lineBreaks
Returns the whitespace characters that force a line or paragraph break.- Returns:
- the whitespace characters that force a line or paragraph break
-
nonBreaking
Returns the non-breaking whitespace characters.- Returns:
- the non-breaking whitespace characters
-
codePoints
public static int[] codePoints()Returns the whitespace code points, in ascending order.- Returns:
- the whitespace code points, in ascending order
-