Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdfec24b

Browse files
[String] improve slugger's portability accross implementations of iconv()
1 parentae655bf commitdfec24b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

‎src/Symfony/Component/String/AbstractUnicodeString.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,15 @@ public function ascii(array $rules = []): self
137137
}
138138
}elseif (!\function_exists('iconv')) {
139139
$s =preg_replace('/[^\x00-\x7F]/u','?',$s);
140-
}elseif (\ICONV_IMPL ==='glibc') {
141-
$s =iconv('UTF-8','ASCII//TRANSLIT',$s);
142140
}else {
143141
$s = @preg_replace_callback('/[^\x00-\x7F]/u',staticfunction ($c) {
144-
if ('' ===$c = (string)iconv('UTF-8','ASCII//IGNORE//TRANSLIT',$c[0])) {
142+
$c = (string)iconv('UTF-8','ASCII//TRANSLIT',$c[0]);
143+
144+
if ('' ===$c &&'2' !==iconv('UTF-8','ASCII//TRANSLIT','²')) {
145145
thrownew \LogicException(sprintf('"%s" requires a translit-able iconv implementation, try installing "gnu-libiconv" if you\'re using Alpine Linux.',static::class));
146146
}
147147

148-
return1 <\strlen($c) ?ltrim($c,'\'`"^~') : (\strlen($c) ?$c :'?');
148+
return1 <\strlen($c) ?ltrim($c,'\'`"^~') : ('' !==$c ?$c :'?');
149149
},$s);
150150
}
151151
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp