2014-03-31 61 views
0

在Firefox中,有特殊字符的URL,像é,去URL编码IE8 VS的Firefox/Chrome浏览器UTF8字符

stores.php?id=AsuntosClientes&ancesterComboValue=Pérez, Gabriel&limit=25

在IE8

,它进入

stores.php?id=AsuntosClientes&ancesterComboValue=P%C3%A9rez,%20Gabriel&limit=25

在PHP中,与IE8中,$ _ GET项string(14) "P�rez, Gabriel"

与Firefox,但我s:string(15) "Pérez, Gabriel"

回答

0

解决的办法是要做到:

if(! mb_detect_encoding($_GET['ancesterComboValue'], 'UTF-8', true)){ 
    $_GET['ancesterComboValue'] = utf8_encode($_GET['ancesterComboValue']); 
} 

我们先来检查字符串不是UTF8已经,otherway我们对其进行编码,从CP1252为UTF8。

如果我们不检查它,那么它会在Firefox中破解,因为它会重新编码一个已经UTF8编码的字符串,它看起来像string(17) "Pérez, Gabriel"