diff --git a/src/Utils/Strings.php b/src/Utils/Strings.php index 7015184a1..f3cb3ce36 100644 --- a/src/Utils/Strings.php +++ b/src/Utils/Strings.php @@ -184,7 +184,7 @@ public static function toAscii($s) array("\xC2\xBB", "\xC2\xAB", "\xE2\x80\xA6", "\xE2\x84\xA2", "\xC2\xA9", "\xC2\xAE"), array('>>', '<<', '...', 'TM', '(c)', '(R)'), $s ); - $s = @iconv('UTF-8', 'WINDOWS-1250//TRANSLIT', $s); // intentionally @ + $s = @iconv('UTF-8', 'WINDOWS-1250//TRANSLIT//IGNORE', $s); // intentionally @ $s = strtr($s, "\xa5\xa3\xbc\x8c\xa7\x8a\xaa\x8d\x8f\x8e\xaf\xb9\xb3\xbe\x9c\x9a\xba\x9d\x9f\x9e" . "\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3" . "\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8" @@ -193,7 +193,7 @@ public static function toAscii($s) "ALLSSSSTZZZallssstzzzRAAAALCCCEEEEIIDDNNOOOOxRUUUUYTsraaaalccceeeeiiddnnooooruuuuyt- <->|-."); $s = preg_replace('#[^\x00-\x7F]++#', '', $s); } else { - $s = @iconv('UTF-8', 'ASCII//TRANSLIT', $s); // intentionally @ + $s = @iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $s); // intentionally @ } $s = str_replace(array('`', "'", '"', '^', '~', '?'), '', $s); return strtr($s, "\x01\x02\x03\x04\x05\x06", '`\'"^~?'); diff --git a/tests/Utils/Strings.toAscii().phpt b/tests/Utils/Strings.toAscii().phpt index c3f101c95..891b84cbb 100644 --- a/tests/Utils/Strings.toAscii().phpt +++ b/tests/Utils/Strings.toAscii().phpt @@ -18,3 +18,4 @@ Assert::same( '"""\'\'\'>><<^', Strings::toAscii("\xE2\x80\x9E\xE2\x80\x9C\xE2\x Assert::same( '', Strings::toAscii("\xF0\x90\x80\x80") ); // U+10000 Assert::same( '', Strings::toAscii("\xC2\xA4") ); // non-ASCII char Assert::same( 'a b', Strings::toAscii("a\xC2\xA0b") ); // non-breaking space +Assert::same( 'Tarikh', Strings::toAscii("Ta\xCA\xBErikh") ); // Taʾrikh