我必须在我的php上将法语字符转换成英语。我使用了以下代码:
iconv("utf-8", "ascii//TRANSLIT", $string);
但ËËË
的结果是"E"E"E
。
我不需要双引号和其他额外的字符-我想显示一个像EEE
这样的输出。有没有其他方法可以把法语翻译成英语?你能帮我做这件事吗?
发布于 2012-08-08 22:16:34
这对我的法语字符很有效。
$str = utf8_encode($str);
$str = iconv('UTF-8', 'ASCII//TRANSLIT', $str);
发布于 2015-07-03 01:52:06
另一种选择:
function replaceAccents($str) {
$search = explode(",","ç,æ,œ,á,é,í,ó,ú,à,è,ì,ò,ù,ä,ë,ï,ö,ü,ÿ,â,ê,î,ô,û,å,ø,Ø,Å,Á,À,Â,Ä,È,É,Ê,Ë,Í,Î,Ï,Ì,Ò,Ó,Ô,Ö,Ú,Ù,Û,Ü,Ÿ,Ç,Æ,Œ");
$replace = explode(",","c,ae,oe,a,e,i,o,u,a,e,i,o,u,a,e,i,o,u,y,a,e,i,o,u,a,o,O,A,A,A,A,A,E,E,E,E,I,I,I,I,O,O,O,O,U,U,U,U,Y,C,AE,OE");
return str_replace($search, $replace, $str);
}
$str = "À é ü ä ç";
$str = replaceAccents($str);
echo "$str \n";
//output "A e u a c"
发布于 2014-07-30 02:08:42
下面是wordpress的方法:
http://codex.wordpress.org/Function_Reference/remove_accents
您可以将remove_accents()函数复制并实现到系统中。
https://core.trac.wordpress.org/browser/tags/3.9.1/src/wp-includes/formatting.php#L682
https://stackoverflow.com/questions/10054818
复制相似问题