Skip to content

Conversation

@yoeunes
Copy link
Contributor

@yoeunes yoeunes commented Nov 21, 2025

Q A
Branch? 6.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets -
License MIT
Doc PR -

Currently, trimPrefix and trimSuffix in UnicodeString inherit the binary comparison logic from AbstractString without handling Unicode normalization.

This creates an inconsistency where startsWith() returns true for canonically equivalent strings (NFC vs NFD), but trimPrefix() fails to remove the prefix because the bytes differ.

Example:

$nfc = "\xC3\xA9";       // é
$nfd = "\x65\xCC\x81";   // e + ´

$str = new UnicodeString($nfc);

$str->startsWith($nfd); // true
$str->trimPrefix($nfd); // returns "é" instead of "" (current behavior)

@fabpot
Copy link
Member

fabpot commented Nov 22, 2025

Thank you @yoeunes.

@fabpot fabpot merged commit c74df7a into symfony:6.4 Nov 22, 2025
11 checks passed
@fabpot fabpot mentioned this pull request Nov 27, 2025
This was referenced Dec 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants