Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between BREAKING_WHITESPACE and WHITESPACE in Guava CharMatcher

In guava CharMatcher there are 2 inner class BREAKING_WHITESPACE and WHITESPACE, and the definition of BREAKING_WHITESPACE is : a whitespace which can be interpreted as a break between words for formatting purposes

What does it mean?

Can anyone answer this question ?

If you can provide an example for the diff it would be nice

Thx in advance

like image 382
Alexis Avatar asked Sep 29 '13 04:09

Alexis


1 Answers

This is fairly general character stuff, not Guava specific:
http://en.wikipedia.org/wiki/Non-breaking_space#Non-breaking_behavior
Actually the Javadoc says it all:

Determines whether a character is a breaking whitespace (that is, a whitespace which can be interpreted as a break between words for formatting purposes).

You put a non-breaking space in text between two words which must stay on the same line. Often it gets used for numbers with units like 123.456 MPa. In HTML you'd write  , ever seen it?

Out of all whitespace chars, there are some non-breaking, e.g. U+0202F and U+000A0.

like image 139
maaartinus Avatar answered Nov 06 '22 04:11

maaartinus