Copilot commented on code in PR #1809:
URL: https://github.com/apache/commons-lang/pull/1809#discussion_r4264896114


##########
src/main/java/org/apache/commons/lang3/StringUtils.java:
##########
@@ -5524,7 +5524,7 @@ public static String normalizeSpace(final String str) {
                 whitespacesCount++;
             } else {
                 startWhitespaces = false;
-                newChars[count++] = actualChar == 160 ? 32 : actualChar;
+                newChars[count++] = actualChar;

Review Comment:
   This changes the long-standing behavior of `normalizeSpace` by no longer 
converting U+00A0 to ASCII space. To make the behavioral contract clear for API 
consumers, please update the `normalizeSpace` Javadoc (and/or the user-facing 
release notes if applicable in this project) to explicitly state that 
non-breaking spaces are preserved.



##########
src/test/java/org/apache/commons/lang3/StringUtilsTest.java:
##########
@@ -1410,6 +1410,8 @@ void testLowerCase() {
     void testNormalizeSpace() {
         // Java says a non-breaking whitespace is not a whitespace.
         assertFalse(Character.isWhitespace('\u00A0'));
+        assertEquals("a\u00A0b", StringUtils.normalizeSpace("a\u00A0b"));
+        assertEquals("a\u00A0 b", StringUtils.normalizeSpace("a\u00A0 b"));

Review Comment:
   The new behavior is specifically about preserving NBSP, but the added tests 
only cover the in-string cases. Consider adding assertions for leading/trailing 
NBSP (e.g., \"\\u00A0a\\u00A0\", \" \\u00A0 \") to ensure trimming/collapsing 
logic doesn’t accidentally remove or alter NBSP at boundaries.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to