Skip to content

Commit

Permalink
Merge branch '5.1'
Browse files Browse the repository at this point in the history
* 5.1:
  [String] improve slugger's portability accross implementations of iconv()
  Fix errors parsing in FirebaseTransport
  • Loading branch information
fabpot committed Sep 17, 2020
2 parents 15b391c + 4a9afe9 commit 0ebd63d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions AbstractUnicodeString.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,15 @@ public function ascii(array $rules = []): self
}
} elseif (!\function_exists('iconv')) {
$s = preg_replace('/[^\x00-\x7F]/u', '?', $s);
} elseif (\ICONV_IMPL === 'glibc') {
$s = iconv('UTF-8', 'ASCII//TRANSLIT', $s);
} else {
$s = @preg_replace_callback('/[^\x00-\x7F]/u', static function ($c) {
if ('' === $c = (string) iconv('UTF-8', 'ASCII//IGNORE//TRANSLIT', $c[0])) {
$c = (string) iconv('UTF-8', 'ASCII//TRANSLIT', $c[0]);

if ('' === $c && '' === iconv('UTF-8', 'ASCII//TRANSLIT', '²')) {
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 : '?');
return 1 < \strlen($c) ? ltrim($c, '\'`"^~') : ('' !== $c ? $c : '?');
}, $s);
}
}
Expand Down

0 comments on commit 0ebd63d

Please sign in to comment.