Skip to content

[4.x] Document the new default whitespace set of the StringHelper trim methods - #80

Open
Hackwar wants to merge 1 commit into
joomla-framework:4.x-devfrom
Hackwar:4.x-docs-trim-whitespace
Open

Hackwar wants to merge 1 commit into
joomla-framework:4.x-devfrom
Hackwar:4.x-docs-trim-whitespace

Conversation

@Hackwar

@Hackwar Hackwar commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Summary of Changes

Since 4.0, StringHelper::trim(), ltrim() and rtrim() without a character list call mb_trim(), mb_ltrim() and mb_rtrim() instead of PHP's trim() family (3.x used phputf8, which delegated to the native functions). Besides ASCII whitespace, the mb_* functions also strip the form feed, U+0085 and the Unicode space separators, including the no-break space:

StringHelper::trim("\u{00A0}Größe\u{3000}"); // 4.x: 'Größe', 3.x: returned unchanged

docs/v3-to-v4-update.md did not mention this change. It now has a section with the full list of the additional characters and how to get the old behaviour.

The review also reported that x..y ranges in $charlist no longer work. That is not a 4.x change: the 3.x phputf8 implementation built a regex character class from $charlist and treated .. literally too (utf8_trim('abcz', 'a..z') returned 'bc' in 3.0.4, the same as 4.x). The guide says that .. does not define a range, so nothing changes in the code.

Testing Instructions

Docs only. The example was checked against 4.x-dev, and the 3.x behaviour against src/phputf8/trim.php from tag 3.0.4.

Documentation Changes Required

This is the documentation change: a new section in docs/v3-to-v4-update.md.

The owner's docs PR #72 appends two sections to the end of docs/v3-to-v4-update.md ("symfony/polyfill-mbstring is now required" and "Dependency changes"), and so does this PR, so expect a small conflict there. #72's overview already says that trim() "also strips non-breaking spaces".

🤖 Generated with Claude Code

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 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant