Last active
November 17, 2017 06:29
-
-
Save steveWinter/61bc579d36a2807648e32a566b38638a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// namespace etc | |
class TextParser { | |
// other methods | |
public static function iconvUTF8($string) { | |
// see http://stackoverflow.com/questions/3371697/replacing-accented-characters-php | |
$map = array( | |
'À'=>'A', 'Á'=>'A', 'Â'=>'A', 'Ã'=>'A', 'Ä'=>'A', 'Å'=>'A', 'Æ'=>'A', 'Þ'=>'B', 'Ç'=>'C', | |
'Ð'=>'D', 'È'=>'E', 'É'=>'E', 'Ê'=>'E', 'Ë'=>'E', 'Ì'=>'I', 'Í'=>'I', 'Î'=>'I', 'Ï'=>'I', | |
'Ñ'=>'N', 'Ò'=>'O', 'Ó'=>'O', 'Ô'=>'O', 'Õ'=>'O', 'Ö'=>'O', 'Ø'=>'O', 'Š'=>'S', 'Ù'=>'U', | |
'Ú'=>'U', 'Û'=>'U', 'Ü'=>'U', 'Ý'=>'Y', 'Ÿ'=>'y', 'Ž'=>'Z', 'ß'=>'ss', | |
'à'=>'a', 'á'=>'a', 'â'=>'a', 'ã'=>'a', 'ä'=>'a', 'å'=>'a', 'æ'=>'a', 'þ'=>'b', 'ç'=>'c', | |
'ð'=>'d', 'è'=>'e', 'é'=>'e', 'ê'=>'e', 'ë'=>'e', 'ì'=>'i', 'í'=>'i', 'î'=>'i', 'ï'=>'i', | |
'ñ'=>'n', 'ò'=>'o', 'ó'=>'o', 'ô'=>'o', 'õ'=>'o', 'ö'=>'o', 'ø'=>'o', 'š'=>'s', 'ù'=>'u', | |
'ú'=>'u', 'û'=>'u', 'ü'=>'u', 'ý'=>'y', 'ÿ'=>'y', 'ž'=>'z', | |
// additional Turkish | |
'Ğ'=>'G', 'ğ'=>'g', 'İ'=>'I', 'ı'=>'i', 'Ş'=>'S', 'ş'=>'s', | |
// additional Romanian | |
'Ă'=>'A', 'ă'=>'a', 'Ș'=>'S', 'ș'=>'s', 'Ț'=>'T', 'ț'=>'t', | |
// additional Czech | |
'Č'=>'C', 'č'=>'c', 'Ň'=>'N', 'ň'=>'n', 'Ť'=>'T', 'ť'=>'t', 'Ů'=>'U', 'ů'=>'u', | |
); | |
return strtr($string, $map); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment