日期:2014-05-18  浏览次数:20398 次

UTF-8编码的参数怎么转化为GBK编码的参数,最好只用JS解决
汉字"新"的
UTF-8编码是:%E6%96%B0 
GBK编码是:%D0%C2

现在有个请求 http://xxx.com/abc.html?p=%E6%96%B0

服务端怎样编写一个函数func,就能使
alert( func() );
的结果是汉字的“新”


在网上花了一上午找了一通,现在还是没能解决,我用的空间不支持ASP.NET
http://topic.csdn.net/u/20100805/10/951c7987-6c22-4931-a7ff-34b0f6873f8c.html



------解决方案--------------------
<script type="text/javascript">
Request = {
 QueryString : function(item){
var svalue = location.search.match(new RegExp("[\?\&]" + item + "=([^\&]*)(\&?)","i"));
return svalue ? svalue[1] : svalue;
 }
}
alert(Request.QueryString("id"));
</script>
encodeURIComponent/encodeURI