From f1c93b8afb05167e4b09a274bd7d8aee727a4d99 Mon Sep 17 00:00:00 2001 From: Hannes Papenberg Date: Fri, 13 Nov 2026 01:21:41 +0100 Subject: [PATCH] Document the new default whitespace set of StringHelper trim methods Since 4.0, trim(), ltrim() and rtrim() without a character list use mb_trim() and friends, which also strip the form feed, U+0085 and the Unicode space separators such as the no-break space. The update guide did not mention this. Co-Authored-By: Claude Opus 5.5 --- docs/v3-to-v4-update.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/v3-to-v4-update.md b/docs/v3-to-v4-update.md index 5abbd7bd..2dd77e26 100644 --- a/docs/v3-to-v4-update.md +++ b/docs/v3-to-v4-update.md @@ -18,3 +18,20 @@ The following deprecated methods have been removed in this release: ### The `Inflector` class has been deprecated The `Inflector` class in this package does not provide benefits over the original `doctrine/inflector` package anymore and is currently only there to keep backwards compatibility with version 3. Use `doctrine/inflector` directly instead. This class will be removed in 5.0 of this package. + +### `StringHelper::trim()`, `ltrim()` and `rtrim()` strip more whitespace by default + +Without a `$charlist`, the three methods now call `mb_trim()`, `mb_ltrim()` and `mb_rtrim()` instead of +PHP's `trim()`, `ltrim()` and `rtrim()`. Besides the ASCII whitespace that the native functions strip, +they now also remove the form feed (`\f`), U+0085 and the Unicode space separators, including the +no-break space U+00A0, U+1680, U+2000 to U+200A, U+2028, U+2029, U+202F, U+205F, U+3000 and U+180E. + +```php +use Joomla\String\StringHelper; + +StringHelper::trim("\u{00A0}Größe\u{3000}"); // 4.x: 'Größe', 3.x: unchanged +``` + +To strip only ASCII whitespace as before, use PHP's `trim()` or pass the characters explicitly, for +example `StringHelper::trim($str, " \t\n\r\0\x0B")`. A `$charlist` is used as given. As in 3.x, +`..` does not define a range of characters.