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

Appearance settings

Commit dfec24b

Browse filesBrowse files
[String] improve slugger's portability accross implementations of iconv()
1 parent ae655bf commit dfec24b
Copy full SHA for dfec24b

File tree

1 file changed

+4
-4
lines changed
Filter options

1 file changed

+4
-4
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/String/AbstractUnicodeString.php
+4-4Lines 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', static function ($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
throw new \LogicException(sprintf('"%s" requires a translit-able iconv implementation, try installing "gnu-libiconv" if you\'re using Alpine Linux.', static::class));
146146
}
147147

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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.