function utf8_urldecode($str) php
{
$str = preg_replace("/%u([0-9a-f]{3,4})/i","&#x\\1;",urldecode($str));
return html_entity_decode($str,null,'UTF-8');;
}html
function ConvertUTF8ToGB2312($str)
{
return iconv("UTF-8","GB2312//IGNORE",$str);
}jquery
function ConvertGB2312ToUTF8($str)
{
return iconv("GB2312","UTF-8//IGNORE",$str);
}web
php處理環境是utf-8的, jquery所在網頁也是的utf-8的, jquery post的中文數據以%u開頭, 須要將這個code轉發到另外一臺接收gb2312字符的web網站post
if(isset($_REQUEST["code"])) { //解碼 $tmp = utf8_urldecode($_REQUEST["code"]); //utf-8轉gb2312 $tmp = ConvertUTF8ToGB2312($tmp); //編碼 $tmp = urlencode($tmp); $AppendPara .= "&code=" . $tmp; } else { $AppendPara .= "&code="; }