remove zero width no-break space (U+FEFF) character with trim()

This commit is contained in:
Ben Fry
2020-09-24 17:44:09 -04:00
parent e9baaf2a71
commit b62302cc07
2 changed files with 5 additions and 2 deletions
+4 -2
View File
@@ -8943,7 +8943,8 @@ public class PApplet implements PConstants {
*
* Removes whitespace characters from the beginning and end of a String. In
* addition to standard whitespace characters such as space, carriage
* return, and tab, this function also removes the Unicode "nbsp" character.
* return, and tab, this function also removes the Unicode "nbsp" (U+00A0)
* character and the zero width no-break space (U+FEFF) character.
*
* @webref data:string_functions
* @webBrief Removes whitespace characters from the beginning and end of a String.
@@ -8955,7 +8956,8 @@ public class PApplet implements PConstants {
if (str == null) {
return null;
}
return str.replace('\u00A0', ' ').trim();
// remove nbsp *and* zero width no-break space
return str.replace('\u00A0', ' ').replace('\uFEFF', ' ').trim();
}
+1
View File
@@ -1,6 +1,7 @@
1272 (4.0a3)
X loadJSONObject/Array() now return null if the given file was not found
X https://github.com/processing/processing/pull/6081
X remove zero width no-break space (U+FEFF) character with trim()
fixed in 4.x (close/lock these with final 4.0 release)