Merge pull request #2527 from dewekk/fix-spaces2

utf8_normalize_spaces() 함수에서 공백 문자 추가 제거
This commit is contained in:
Kijin Sung 2025-03-18 22:32:49 +09:00 committed by GitHub
commit ec8003003c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -680,7 +680,7 @@ function utf8_mbencode($str): string
*/
function utf8_normalize_spaces($str, bool $multiline = false): string
{
return $multiline ? preg_replace('/((?!\x0A)[\pZ\pC])+/u', ' ', (string)$str) : preg_replace('/[\pZ\pC]+/u', ' ', (string)$str);
return $multiline ? preg_replace(['/((?!\x0A)[\pZ\pC])+/u', '/\x20(?=\x0A)/u'], [' ', ''], (string)$str) : preg_replace('/[\pZ\pC]+/u', ' ', (string)$str);
}
/**