[String] throw when Alpine is used and translit fails
This commit is contained in:
parent
d285042b48
commit
98f5d50945
@ -142,8 +142,10 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
} elseif (ICONV_IMPL === 'glibc') {
|
||||
$s = iconv('UTF-8', 'ASCII//TRANSLIT', $s);
|
||||
} else {
|
||||
$s = preg_replace_callback('/[^\x00-\x7F]/u', static function ($c) {
|
||||
$c = iconv('UTF-8', 'ASCII//IGNORE//TRANSLIT', $c[0]);
|
||||
$s = @preg_replace_callback('/[^\x00-\x7F]/u', static function ($c) {
|
||||
if ('' === $c = (string) iconv('UTF-8', 'ASCII//IGNORE//TRANSLIT', $c[0])) {
|
||||
throw new \LogicException(sprintf('"%s" requires a translit-able iconv implementation, try installing "gnu-libiconv" if you\'re using Alpine Linux.', static::class));
|
||||
}
|
||||
|
||||
return 1 < \strlen($c) ? ltrim($c, '\'`"^~') : (\strlen($c) ? $c : '?');
|
||||
}, $s);
|
||||
|
Reference in New Issue
Block a user