|
|
本帖最后由 hcmgood 于 2014-11-24 11:00 编辑
需要取页面的一个中文参数,页面上面中文参数编码了赵阳。 如 赵阳 我需要直接在规则里面转为中文。 有没有大神又办法的
关于赵阳中文解码的问题 现给出脚本供参考 来源于网络【多找百度大哥】 - function reconvert(str){
- str = str.replace(/(\\u)(\w{1,4})/gi,function($0){
- return (String.fromCharCode(parseInt((escape($0).replace(/(%5Cu)(\w{1,4})/g,"$2")),16)));
- });
- str = str.replace(/(&#x)(\w{1,4});/gi,function($0){
- return String.fromCharCode(parseInt(escape($0).replace(/(%26%23x)(\w{1,4})(%3B)/g,"$2"),16));
- });
- str = str.replace(/(&#)(\d{1,6});/gi,function($0){
- return String.fromCharCode(parseInt(escape($0).replace(/(%26%23)(\d{1,6})(%3B)/g,"$2")));
- });
- return str;
- }
复制代码
其他应该知道啦吧
|
|