-
Notifications
You must be signed in to change notification settings - Fork 11.7k
Description
- Laravel Version: 9.0.0-beta.3
- PHP Version: 8.1.0
Description:
In 9.x, the trimString middleware removes NBSP. #38117
This is causing the problem. When dealing with multi-byte words (in my case Japanese), we have some problems. A few words are garbled.
When I put だ or ム in the end of text, those words will be garbled.
Steps to Reproduce (quick version)
Add below to the welcome.blade.php.
<h1>Hello {{ request()->name }}</h1>Access the url.
http://localhost/?name=やま
http://localhost/?name=やまだ
(Replace localhost to your domain. やま or やまだ may be encoded in the URL field of your browser.)
You can see やま is ok. But if you add だ, it's not working.
Steps To Reproduce: (Original version)
[Caution]
You cannot just copy and paste the below. NBSP is replaced with the normal space.
Please use NBSP as the second argument of the trim function.
You can copy NBSP from the real source code. (Please don't copy from the github website.)
$str = 'あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらをわがぎぐげござしずぜぞだぢづでどばびぶべぼぱぴぷぺぽ'
. 'アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラヲワガギグゲゴザジズゼゾダヂヅデドバビブベボパピプペポ';
$words = preg_split('//u', $str); // split a string into each words. (This part is not related with the problem)
foreach ($words as $word) {
echo $word.' '.bin2hex($word).' '.trim($word, " ")."<br>";
}I guess the reason is that だ is like e381a0 and ム is like e383a0 and the NBSP is like U+00A0 in Unicode.
So If I put だ in the end of text, the last part of word a0 is trimmed and the word is garbled.
We (Japanese) also use chinese characters which I didn't looked into.
Thank you for reading.



