You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Dirk Henselin (JIRA)" <ji...@apache.org> on 2017/11/14 17:42:00 UTC

[jira] [Commented] (LANG-1282) StringUtils#normalizeSpace normalizeSpace should not replace non-breaking spaces with normal whitespace

    [ https://issues.apache.org/jira/browse/LANG-1282?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16251808#comment-16251808 ] 

Dirk Henselin commented on LANG-1282:
-------------------------------------

IMO StringUtils#normalizeSpace should be idempotent, i.e.
{code:java}
String s = "a\u00A0 b";
assertEquals(StringUtils.normalizeSpace(s), StringUtils.normalizeSpace(StringUtils.normalizeSpace(s)));
{code}
Hence non-breaking spaces should not be replaced by normal spaces. Simply remove the replacement in the following line
{code:java}
newChars[count++] = (actualChar == 160 ? 32 : actualChar);
{code}



> StringUtils#normalizeSpace normalizeSpace should not replace non-breaking spaces with normal whitespace
> -------------------------------------------------------------------------------------------------------
>
>                 Key: LANG-1282
>                 URL: https://issues.apache.org/jira/browse/LANG-1282
>             Project: Commons Lang
>          Issue Type: Bug
>    Affects Versions: 3.5
>            Reporter: Pascal Schumacher
>
> As of 3.4 StringUtils#normalizeSpace does not normalize non-breaking whitespace anymore. Therefore it shouldn't replace a non-breaking whitespace white breaking whitespace, but both assertions succeed:
> {code}
> assertEquals("a b", StringUtils.normalizeSpace("a\u00A0b"));
> assertEquals("a  b", StringUtils.normalizeSpace("a\u00A0 b"));
> {code}
> source: https://github.com/apache/commons-lang/pull/184



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)