我的解决方案是使用Wordpress实现。虽然不漂亮,但最终没有什么其他的办法
function remove_accents( $string ) {
if ( !preg_match('/[\x80-\xff]/', $string) )
return $string;
$chars = array(
// Decompositions for Latin-1 Supplement
'ª' => 'a', 'º' => 'o',
'Ã' => 'A', 'Ã' => 'A',
'Ã' => 'A', 'Ã' => 'A',
'Ã' => 'A', 'Ã
' => 'A',
'Ã' => 'AE','Ã' => 'C',
'Ã' => 'E', 'Ã' => 'E',
'Ã' => 'E', 'Ã' => 'E',
'Ã' => 'I', 'Ã' => 'I',
'Ã' => 'I', 'Ã' => 'I',
'Ã' => 'D', 'Ã' => 'N',
'Ã' => 'O', 'Ã' => 'O',
'Ã' => 'O', 'Ã' => 'O',
'Ã' => 'O', 'Ã' => 'U',
'Ã' => 'U', 'Ã' => 'U',
'Ã' => 'U', 'Ã' => 'Y',
'Ã' => 'TH','Ã' => 's',
'à ' => 'a', 'á' => 'a',
'â' => 'a', 'ã' => 'a',
'ä' => 'a', 'å' => 'a',
'æ' => 'ae','ç' => 'c',
'è' => 'e', 'é' => 'e',
'ê' => 'e', 'ë' => 'e',
'ì' => 'i', 'Ã' => 'i',
'î' => 'i', 'ï' => 'i',
'ð' => 'd', 'ñ' => 'n',
'ò' => 'o', 'ó' => 'o',
'ô' => 'o', 'õ' => 'o',
'ö' => 'o', 'ø' => 'o',
'ù' => 'u', 'ú' => 'u',
'û' => 'u', 'ü' => 'u',
'ý' => 'y', 'þ' => 'th',
'ÿ' => 'y', 'Ã' => 'O',
// Decompositions for Latin Extended-A
'Ä' => 'A', 'Ä' => 'a',
'Ä' => 'A', 'Ä' => 'a',
'Ä' => 'A', 'Ä
' => 'a',
'Ä' => 'C', 'Ä' => 'c',
'Ä' => 'C', 'Ä' => 'c',
'Ä' => 'C', 'Ä' => 'c',
'Ä' => 'C', 'Ä' => 'c',
'Ä' => 'D', 'Ä' => 'd',
'Ä' => 'D', 'Ä' => 'd',
'Ä' => 'E', 'Ä' => 'e',
'Ä' => 'E', 'Ä' => 'e',
'Ä' => 'E', 'Ä' => 'e',
'Ä' => 'E', 'Ä' => 'e',
'Ä' => 'E', 'Ä' => 'e',
'Ä' => 'G', 'Ä' => 'g',
'Ä' => 'G', 'Ä' => 'g',
'Ä ' => 'G', 'Ä¡' => 'g',
'Ä¢' => 'G', 'Ä£' => 'g',
'Ĥ' => 'H', 'ĥ' => 'h',
'Ħ' => 'H', 'ħ' => 'h',
'Ĩ' => 'I', 'ĩ' => 'i',
'Ī' => 'I', 'ī' => 'i',
'Ĭ' => 'I', 'Ä' => 'i',
'Į' => 'I', 'į' => 'i',
'İ' => 'I', 'ı' => 'i',
'IJ' => 'IJ','ij' => 'ij',
'Ĵ' => 'J', 'ĵ' => 'j',
'Ķ' => 'K', 'ķ' => 'k',
'ĸ' => 'k', 'Ĺ' => 'L',
'ĺ' => 'l', 'Ļ' => 'L',
'ļ' => 'l', 'Ľ' => 'L',
'ľ' => 'l', 'Ŀ' => 'L',
'Å' => 'l', 'Å' => 'L',
'Å' => 'l', 'Å' => 'N',
'Å' => 'n', 'Å
' => 'N',
'Å' => 'n', 'Å' => 'N',
'Å' => 'n', 'Å' => 'n',
'Å' => 'N', 'Å' => 'n',
'Å' => 'O', 'Å' => 'o',
'Å' => 'O', 'Å' => 'o',
'Å' => 'O', 'Å' => 'o',
'Å' => 'OE','Å' => 'oe',
'Å' => 'R','Å' => 'r',
'Å' => 'R','Å' => 'r',
'Å' => 'R','Å' => 'r',
'Å' => 'S','Å' => 's',
'Å' => 'S','Å' => 's',
'Å' => 'S','Å' => 's',
'Å ' => 'S', 'Å¡' => 's',
'Å¢' => 'T', 'Å£' => 't',
'Ť' => 'T', 'ť' => 't',
'Ŧ' => 'T', 'ŧ' => 't',
'Ũ' => 'U', 'ũ' => 'u',
'Ū' => 'U', 'ū' => 'u',
'Ŭ' => 'U', 'Å' => 'u',
'Ů' => 'U', 'ů' => 'u',
'Ű' => 'U', 'ű' => 'u',
'Ų' => 'U', 'ų' => 'u',
'Ŵ' => 'W', 'ŵ' => 'w',
'Ŷ' => 'Y', 'ŷ' => 'y',
'Ÿ' => 'Y', 'Ź' => 'Z',
'ź' => 'z', 'Ż' => 'Z',
'ż' => 'z', 'Ž' => 'Z',
'ž' => 'z', 'ſ' => 's',
// Decompositions for Latin Extended-B
'È' => 'S', 'È' => 's',
'È' => 'T', 'È' => 't',
// Euro Sign
'â¬' => 'E',
// GBP (Pound) Sign
'£' => '',
// Vowels with diacritic (Vietnamese)
// unmarked
'Æ ' => 'O', 'Æ¡' => 'o',
'Ư' => 'U', 'ư' => 'u',
// grave accent
'Ầ' => 'A', 'ầ' => 'a',
'Ằ' => 'A', 'ằ' => 'a',
'á»' => 'E', 'á»' => 'e',
'á»' => 'O', 'á»' => 'o',
'á»' => 'O', 'á»' => 'o',
'Ừ' => 'U', 'ừ' => 'u',
'Ỳ' => 'Y', 'ỳ' => 'y',
// hook
'Ả' => 'A', 'ả' => 'a',
'Ẩ' => 'A', 'ẩ' => 'a',
'Ẳ' => 'A', 'ẳ' => 'a',
'Ẻ' => 'E', 'ẻ' => 'e',
'á»' => 'E', 'á»' => 'e',
'á»' => 'I', 'á»' => 'i',
'á»' => 'O', 'á»' => 'o',
'á»' => 'O', 'á»' => 'o',
'á»' => 'O', 'á»' => 'o',
'Ủ' => 'U', 'ủ' => 'u',
'Ử' => 'U', 'á»' => 'u',
'Ỷ' => 'Y', 'ỷ' => 'y',
// tilde
'Ẫ' => 'A', 'ẫ' => 'a',
'Ẵ' => 'A', 'ẵ' => 'a',
'Ẽ' => 'E', 'ẽ' => 'e',
'á»' => 'E', 'á»
' => 'e',
'á»' => 'O', 'á»' => 'o',
'Ỡ' => 'O', 'ỡ' => 'o',
'Ữ' => 'U', 'ữ' => 'u',
'Ỹ' => 'Y', 'ỹ' => 'y',
// acute accent
'Ấ' => 'A', 'ấ' => 'a',
'Ắ' => 'A', 'ắ' => 'a',
'Ế' => 'E', 'ế' => 'e',
'á»' => 'O', 'á»' => 'o',
'á»' => 'O', 'á»' => 'o',
'Ứ' => 'U', 'ứ' => 'u',
// dot below
'Ạ' => 'A', 'ạ' => 'a',
'Ậ' => 'A', 'áº' => 'a',
'Ặ' => 'A', 'ặ' => 'a',
'Ẹ' => 'E', 'ẹ' => 'e',
'á»' => 'E', 'á»' => 'e',
'á»' => 'I', 'á»' => 'i',
'á»' => 'O', 'á»' => 'o',
'á»' => 'O', 'á»' => 'o',
'Ợ' => 'O', 'ợ' => 'o',
'Ụ' => 'U', 'ụ' => 'u',
'á»°' => 'U', 'á»±' => 'u',
'Ỵ' => 'Y', 'ỵ' => 'y',
// Vowels with diacritic (Chinese, Hanyu Pinyin)
'É' => 'a',
// macron
'Ç' => 'U', 'Ç' => 'u',
// acute accent
'Ç' => 'U', 'Ç' => 'u',
// caron
'Ç' => 'A', 'Ç' => 'a',
'Ç' => 'I', 'Ç' => 'i',
'Ç' => 'O', 'Ç' => 'o',
'Ç' => 'U', 'Ç' => 'u',
'Ç' => 'U', 'Ç' => 'u',
// grave accent
'Ç' => 'U', 'Ç' => 'u',
);
$string = strtr($string, $chars);
return $string;
}