Skip to content

Commit

Permalink
Strings::toAscii() uses //IGNORE
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Mar 26, 2015
1 parent ca58dcb commit 7342827
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Utils/Strings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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", '`\'"^~?');
Expand Down
1 change: 1 addition & 0 deletions tests/Utils/Strings.toAscii().phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 7342827

Please sign in to comment.