From b62302cc0732e6d83871f5a7b90b278719f3cda5 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Thu, 24 Sep 2020 17:44:09 -0400 Subject: [PATCH] remove zero width no-break space (U+FEFF) character with trim() --- core/src/processing/core/PApplet.java | 6 ++++-- core/todo.txt | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index 1a388aeea..1ea5711c4 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -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(); } diff --git a/core/todo.txt b/core/todo.txt index 73bbe2b37..ee0693656 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -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)