diff --git a/src/Mbstring/Mbstring.php b/src/Mbstring/Mbstring.php index 3d45c9d9a..31e36a368 100644 --- a/src/Mbstring/Mbstring.php +++ b/src/Mbstring/Mbstring.php @@ -983,7 +983,7 @@ public static function mb_ltrim(string $string, ?string $characters = null, ?str public static function mb_rtrim(string $string, ?string $characters = null, ?string $encoding = null): string { - return self::mb_internal_trim('{[%s]+$}D', $string, $characters, $encoding, __FUNCTION__); + return self::mb_internal_trim('{[%s]+$}Du', $string, $characters, $encoding, __FUNCTION__); } private static function mb_internal_trim(string $regex, string $string, ?string $characters, ?string $encoding, string $function): string diff --git a/tests/Mbstring/MbstringTest.php b/tests/Mbstring/MbstringTest.php index 2020f4566..49a9aff10 100644 --- a/tests/Mbstring/MbstringTest.php +++ b/tests/Mbstring/MbstringTest.php @@ -886,6 +886,7 @@ public static function mbLTrimProvider(): iterable yield [' test ', ' test ', '']; yield ['いああああ', 'あああああああああああああああああああああああああああああああああいああああ', 'あ']; + yield ['あいうえお ', ' あいうえお ']; yield ['漢字', "\u{FFFE}漢字", "\u{FFFE}\u{FEFF}"]; yield [' abcd ', ' abcd ', '']; @@ -902,6 +903,7 @@ public static function mbRTrimProvider(): iterable yield [' a', str_repeat(' ', 129).'a']; yield ['あああああああああああああああああああああああああああああああああい', 'あああああああああああああああああああああああああああああああああいああああ', 'あ']; + yield [' あいうえお', ' あいうえお ']; yield [' abcd ', ' abcd ', ''];