Skip to content

Commit 0ebd63d

Browse files
committed
Merge branch '5.1'
* 5.1: [String] improve slugger's portability accross implementations of iconv() Fix errors parsing in FirebaseTransport
2 parents 15b391c + 4a9afe9 commit 0ebd63d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

AbstractUnicodeString.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,15 @@ public function ascii(array $rules = []): self
139139
}
140140
} elseif (!\function_exists('iconv')) {
141141
$s = preg_replace('/[^\x00-\x7F]/u', '?', $s);
142-
} elseif (\ICONV_IMPL === 'glibc') {
143-
$s = iconv('UTF-8', 'ASCII//TRANSLIT', $s);
144142
} else {
145143
$s = @preg_replace_callback('/[^\x00-\x7F]/u', static function ($c) {
146-
if ('' === $c = (string) iconv('UTF-8', 'ASCII//IGNORE//TRANSLIT', $c[0])) {
144+
$c = (string) iconv('UTF-8', 'ASCII//TRANSLIT', $c[0]);
145+
146+
if ('' === $c && '' === iconv('UTF-8', 'ASCII//TRANSLIT', '²')) {
147147
throw new \LogicException(sprintf('"%s" requires a translit-able iconv implementation, try installing "gnu-libiconv" if you\'re using Alpine Linux.', static::class));
148148
}
149149

150-
return 1 < \strlen($c) ? ltrim($c, '\'`"^~') : (\strlen($c) ? $c : '?');
150+
return 1 < \strlen($c) ? ltrim($c, '\'`"^~') : ('' !== $c ? $c : '?');
151151
}, $s);
152152
}
153153
}

0 commit comments

Comments
 (0)