-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Because the default characters are defined in the stub file, and the stub file is UTF-8 (typically), the characters are encoded in the string as UTF-8. When using a different character encoding, there is a mismatch between what mb_trim expects and the UTF-8 encoded string it gets. One way of solving this is by making the characters argument nullable, which would mean that it always uses the internal code path that has the unicode codepoints that are defaulted actually stored as codepoint numbers instead of in a string. Co-authored-by: @ranvis
- Loading branch information
Showing
4 changed files
with
26 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--TEST-- | ||
GH-13815 (mb_trim() inaccurate $characters default value) | ||
--EXTENSIONS-- | ||
mbstring | ||
--FILE-- | ||
<?php | ||
$strUtf8 = "\u{3042}\u{3000}"; // U+3000: fullwidth space | ||
var_dump(mb_strlen(mb_trim($strUtf8))); | ||
var_dump(mb_strlen(mb_trim($strUtf8, encoding: 'UTF-8'))); | ||
|
||
mb_internal_encoding('Shift_JIS'); | ||
$strSjis = mb_convert_encoding($strUtf8, 'Shift_JIS', 'UTF-8'); | ||
var_dump(mb_strlen(mb_trim($strSjis))); | ||
var_dump(mb_strlen(mb_trim($strSjis, encoding: 'Shift_JIS'))); | ||
?> | ||
--EXPECT-- | ||
int(1) | ||
int(1) | ||
int(1) | ||
int(1) |