function utf8_urldecode($str) 

{
$str = preg_replace("/%u([0-9a-f]{3,4})/i","&#x\\1;",urldecode($str));
return html_entity_decode($str,null,'UTF-8');;
}

function ConvertUTF8ToGB2312($str)
{
return iconv("UTF-8","GB2312//IGNORE",$str);
}

function ConvertGB2312ToUTF8($str)
{
return iconv("GB2312","UTF-8//IGNORE",$str);
}

php处理环境是utf-8的, jquery所在网页也是的utf-8的, jquery post的中文数据以%u开头, 需要将这个code转发到另一台接收gb2312字符的web网站

if(isset($_REQUEST["code"]))
{
    //解码
    $tmp = utf8_urldecode($_REQUEST["code"]);
    //utf-8转gb2312
    $tmp = ConvertUTF8ToGB2312($tmp);
    //编码
    $tmp = urlencode($tmp);
    $AppendPara .= "&code=" . $tmp;
}
else
{
    $AppendPara .= "&code=";
}

 

相关文章:

  • 2022-01-07
  • 2021-07-18
  • 2021-08-24
  • 2021-12-25
  • 2021-08-30
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-25
  • 2021-05-23
  • 2021-11-10
  • 2022-02-08
  • 2021-10-01
  • 2022-12-23
  • 2021-11-27
相关资源
相似解决方案