bug #37514 [String] throw when Alpine is used and translit fails (nicolas-grekas)
This PR was merged into the 5.0 branch.
Discussion
----------
[String] throw when Alpine is used and translit fails
| Q | A
| ------------- | ---
| Branch? | 5.0
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix #37213
| License | MIT
| Doc PR | -
Commits
-------
98f5d50945
[String] throw when Alpine is used and translit fails
This commit is contained in:
commit
f70bcf646d
@ -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