(function(window, undef){
var document = window.document;
//编码工具
window.$coder = function(){
};
//将native码转换成ascii
//\uxxxx --------- x
$coder.NativeToASCII = function(s){
return unescape(s.replace(/\\(u[0-9a-fA-F]{4})/gm, '%$1'));
};
//将ascii转换成unicode
//x ------- \uxxxx
$coder.ASCIIToNative = function(s){
return escape(s).replace(/%(u[0-9A-F]{4})|(%[0-9A-F]{2})/gm, function($0, $1, $2) {
return $1 && '\\' + $1.toLowerCase() || unescape($2);
});
};
})(window);
var document = window.document;
//编码工具
window.$coder = function(){
};
//将native码转换成ascii
//\uxxxx --------- x
$coder.NativeToASCII = function(s){
return unescape(s.replace(/\\(u[0-9a-fA-F]{4})/gm, '%$1'));
};
//将ascii转换成unicode
//x ------- \uxxxx
$coder.ASCIIToNative = function(s){
return escape(s).replace(/%(u[0-9A-F]{4})|(%[0-9A-F]{2})/gm, function($0, $1, $2) {
return $1 && '\\' + $1.toLowerCase() || unescape($2);
});
};
})(window);