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"