您的足迹:首页 > 我的代码 >多种编码解码处理,集合整理了一下ByAardio

多种编码解码处理,集合整理了一下ByAardio

import string;
import inet.url;

deCode = function(ustr){	
    ustr = string.replace(ustr,"<\=\x\x>+",
        function(cstr){
        	c = eval("'" + ( string.replace(cstr,"\=","\\x") ) + "'" );
            return c;  
        }
    );
    
    if(!string.isUtf8(ustr)){
    	ustr = string.fromto(ustr,0,65001)
    	return ustr; 
    }
    
    return inet.url.decode(ustr,true);
}

deUnicode = function(ustr,seperator){
	var a = string.split(ustr, seperator)
	var i
	var j = #a
	var s = ''
	for(i=1;j;1){
		if(#a[i]>0){
			//console.print(a[i])
			s = s ++ tostring(tonumber(a[i]),16)
		}
	}
	s = string.replace(s, '0x', "\\u")
	return eval("'" ++ s ++ "'")
}

deEscape = function(ustr){
	import web.script;
	ustr = string.replace(ustr,"\\","%");
	strEscape = web.script().run("unescape",ustr)
	return strEscape;
};
var ustr = {
deUnicode("\23433\21331", '\\');//Unicode编码,安卓
deUnicode("&#\23433&#\21331", '&#\\');//Unicode编码,安卓
deEscape("%u4E2D%u56FD%u8FD1%u4EE3%u53F2%20%u7684%u524D%u8F66%u4E4B%u9274");//中国近代史 的前车之鉴
deEscape('%u4E00%u4E9B\u4EBA\u7ECF\u5E38');//一些人经常
deEscape("\u8bf7\u8f93\u5165\u57ce\u5e02\u540d\u79f0\u6216\u57ce\u5e02\u4ee3\u7801");//Native编码
deEscape("http%3A%2F%2Fs.yytcdn.com%2Fswf%2Fcommon%2Fmvplayer.swf%3Ft%3D2016032212");
deCode("aau编程");
deCode("http%3A%2F%2Fs.yytcdn.com%2Fswf%2Fcommon%2Fmvplayer.swf%3Ft%3D2016032212");
deCode("aau%B1%E0%B3%CC");//aau编程
deCode("aau%E7%BC%96%E7%A8%8B");//aau编程
deCode("=D4=DA=CF=DF=C1=AA=CF=B5 =B0=A2=C0=EF=CD=FA=CD=FA=0D=0A");//在线联系 阿里旺旺(换行)
deCode("%E7%86%8A%E7%8C%AB");
deCode("%e6%8a%80%e6%9c%af");//UTF8="%e6%8a%80%e6%9c%af";//技术
deCode("%bc%bc%ca%f5");//GBK="%bc%bc%ca%f5";//技术
deCode("=D4=DA=CF=DF=C1=AA=CF=B5 =B0=A2=C0=EF=CD=FA=CD=FA=0D");//在线联系 阿里旺旺(无换行)
};
import console;
for(i=1;#ustr;1){
	console.log(i,ustr[i])
}


execute("pause")
本博客所有文章如无特别注明均为原创。作者:恶猫复制或转载请以超链接形式注明转自 恶猫的博客
原文地址《多种编码解码处理,集合整理了一下ByAardio

相关推荐

WRITTEN BY

avatar

发表评论

路人甲 表情
看不清楚?点图切换 Ctrl+Enter快速提交

网友评论(0)

恶猫的博客 -记录自己日常,代码,美图,电影,音乐,新闻,只是个人博客而已

浙ICP备15011757号-4 网站地图 联系我