Is Java a “normal” space like a space for Character.isWhitespace purposes?

At first glance, this may seem unimaginable. Perhaps this is so, but I have something that I can miss something. The first Java documentation for Character.isWhitespace seems to exclude it. The definition of what is and is not allowed as a space seems very definite ("if and only if"), and the first line does not mean inextricable space.

I always thought of the usual "space" - this is what you get when you press the spacebar - as inextricable space .

So where does it fit on the list? The list is considered final in the highest ranking answer to this question - am I just reading it wrong? Also, the first commenter on the top answer on this question seems to be in doubt (in a different context). However, when I create a simple bit of code for testing, it indicates that normal space is an instance of spaces, as you would expect.

import static java.lang.Character.isWhitespace; public class WhitespaceCheck { public static void main(String[] args) { Character test = ' '; if (Character.isWhitespace(test)) { System.out.println("Is whitespace!" ); } else { System.out.println("Is not whitespace!" ); } } } 

So, am I reading the first item in the list incorrectly, is it somewhere else in the list, or is the list itself simply wrong?

+5
source share
1 answer

You are wrong; non-breaking space prevents line breaks. This is a special type of space, not "normal", which allows you to break the line. If the "normal" space was inextricable, then the lines will never end when you reach the edge of the screen, if you did not press return manually each time.

The very first line says:

This is a space character in Unicode (SPACE_SEPARATOR, LINE_SEPARATOR or PARAGRAPH_SEPARATOR), but is also not inextricable space ('\ u00A0', '\ u2007', '\ u202F')

A list of unicode spaces covered by SPACE_SEPARATOR can be found here:

https://en.wikipedia.org/wiki/Whitespace_character

The documentation for SPACE_SEPARATOR says that it belongs to the Unicode character category, and not to a specific character. A “normal” namespace (which is usually created by a space) is included in this category.

+12
source

Source: https://habr.com/ru/post/1236374/


All Articles