utf8_normalize_spaces 함수에서 불필요한 공백 문자 추가 제거

This commit is contained in:
dewekk 2025-03-14 09:46:10 +09:00 committed by GitHub
parent 3f553d4d9c
commit 2276110b0f
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);
}
/**