Adding 00A0 to the list of whitespace characters per LANG-910

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1531643 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Henri Yandell 2013-10-13 09:02:07 +00:00
parent 439ee3bc05
commit f9b486a171
3 changed files with 8 additions and 3 deletions

View File

@ -22,6 +22,7 @@
<body>
<release version="3.2" date="TBA" description="Next release">
<action issue="LANG-910" type="update" due-to="Timur Yarosh">StringUtils.normalizeSpace now handles non-breaking spaces (Unicode 00A0)</action>
<action issue="LANG-804" type="update" dev="britter" due-to="Allon Mureinik">Redundant check for zero in HashCodeBuilder ctor</action>
<action issue="LANG-893" type="add" dev="oheger" due-to="Woonsan Ko">StrSubstitutor now supports default values for variables</action>
<action issue="LANG-913" type="add" dev="britter" due-to="Allon Mureinik">Adding .gitignore to commons-lang</action>

View File

@ -178,7 +178,7 @@ public class StringUtils {
* single space, thus matching the same would likely cause a great
* many noop replacements.
*/
private static final Pattern WHITESPACE_PATTERN = Pattern.compile("(?: \\s|[\\s&&[^ ]])\\s*");
private static final Pattern WHITESPACE_PATTERN = Pattern.compile("(?: |\\u00A0|\\s|[\\s&&[^ ]])\\s*");
/**
* <p>{@code StringUtils} instances should NOT be constructed in

View File

@ -47,11 +47,13 @@ public class StringUtilsTest {
static final String WHITESPACE;
static final String NON_WHITESPACE;
static final String HARD_SPACE;
static final String TRIMMABLE;
static final String NON_TRIMMABLE;
static {
String ws = "";
String nws = "";
String hs = String.valueOf(((char) 160));
String tr = "";
String ntr = "";
for (int i = 0; i < Character.MAX_VALUE; i++) {
@ -69,6 +71,7 @@ public class StringUtilsTest {
}
WHITESPACE = ws;
NON_WHITESPACE = nws;
HARD_SPACE = hs;
TRIMMABLE = tr;
NON_TRIMMABLE = ntr;
}
@ -2139,6 +2142,7 @@ public class StringUtilsTest {
assertEquals("a", StringUtils.normalizeSpace(" a "));
assertEquals("a b c", StringUtils.normalizeSpace(" a b c "));
assertEquals("a b c", StringUtils.normalizeSpace("a\t\f\r b\u000B c\n"));
assertEquals("a b c", StringUtils.normalizeSpace("a\t\f\r " + HARD_SPACE + HARD_SPACE + "b\u000B c\n"));
}
@Test