在JS中使用了encodeURIComponent对中文进行编码在PHP中使用iconv('UTF-8','gb2312',$q);就可以得到你需要的字串了,其中gb2312根据你实际应用来定如还不明白为什么看下面的文章
URL编码转换,escape() encodeURI() encodeURIComponent() 本文介绍对url编码的三种函数 escape() ,encodeURI() ,encodeURIComponent()
escape() 方法: phperz.com
因此,对于中文字符串来说,如果不希望把字符串编码格式转化成UTF-8格式的(比如原页面和目标页面的charset是一致的时候),只需要使用escape。如果你的页面是GB2312 或者其他的编码,而接受参数的页面是UTF-8编码的,就要采用encodeURI或者encodeURIComponent。
注意:escape 方法不能用来对“统一资源标识符”(uri) 进行编码。对其编码应使用 encodeuri 和 encodeuricomponent 方法。 另外,encodeURI/encodeURIComponent是在javascript1.5之后引进的,escape则在javascript1.0版本就有。
|
JS中encodeURIComponent函数用php解码
最新推荐文章于 2025-06-09 15:45:45 发布