[JavaScript] 纯文本查看 复制代码
/*
本段JS代码由乐易助手生成!助手下载地址:[url]https://www.leybc.com/thread-7123-1-1.hml[/url]
请勿用于非法用途,产生后果均有使用者自负!
*/
str = function() {
var htmlDecodeDict = {
"quot": '"',
"lt": "<",
"gt": ">",
"amp": "&",
"nbsp": " ",
"#34": '"',
"#60": "<",
"#62": ">",
"#38": "&",
"#160": " "
}, htmlEncodeDict = {
'"': "#34",
"<": "#60",
">": "#62",
"&": "#38",
" ": "#160"
};
return {
"decodeHtml": function(t) {
return (t += "").replace(/&(quot|lt|gt|amp|nbsp);/gi, function(t, e) {
return htmlDecodeDict[e]
}).replace(/&#u([a-f\d]{4});/gi, function(t, e) {
return String.fromCharCode(parseInt("0x" + e))
}).replace(/&#(\d+);/gi, function(t, e) {
return String.fromCharCode(+e)
})
},
"encodeHtml": function(t) {
return (t += "").replace(/["<>& ]/g, function(t) {
return "&" + htmlEncodeDict[t] + ";"
})
},
"trim": function(t) {
for (var e = /\s/, n = (t = (t += "").replace(/^\s+/, "")).length; e.test(t.charAt(--n)););
return t.slice(0, n + 1)
},
"uin2hex": function uin2hex(str) {
var maxLength = 16;
str = parseInt(str);
for (var hex = str.toString(16), len = hex.length, i = len; i < maxLength; i++)
hex = "0" + hex;
for (var arr = [], j = 0; j < maxLength; j += 2)
arr.push("\\x" + hex.substr(j, 2));
var result = arr.join("");
return eval('result="' + result + '"'), result
},
"bin2String": function(t) {
for (var e = [], n = 0, i = t.length; n < i; n++) {
var o = t.charCodeAt(n).toString(16);
1 == o.length && (o = "0" + o), e.push(o)
}
return e = "0x" + e.join(""), e = parseInt(e, 16)
},
"str2bin": function str2bin(str) {
for (var arr = [], i = 0; i < str.length; i += 2)
arr.push(eval("'\\x" + str.charAt(i) + str.charAt(i + 1) + "'"));
return arr.join("")
},
"utf8ToUincode": function(t) {
var e = "";
try {
var n = t.length,
o = [];
for (i = 0; i < n; i += 2)
o.push("%" + t.substr(i, 2));
e = decodeURIComponent(o.join("")), e = $.str.decodeHtml(e)
} catch (r) {
e = ""
}
return e
},
"json2str": function(t) {
var e = "";
if ("undefined" != typeof JSON) e = JSON.stringify(t);
else {
var n, i = [];
for (n in t)
i.push('"' + n + '":"' + t[n] + '"');
e = "{" + i.join(",") + "}"
}
return e
},
"time33": function(t) {
for (var e = 0, n = 0, i = t.length; n < i; n++)
e = (33 * e + t.charCodeAt(n)) % 4294967296;
return e
},
"hash33": function(t) {
for (var e = 0, n = 0, i = t.length; n < i; ++n)
e += (e << 5) + t.charCodeAt(n);
return 2147483647 & e
}
}
}()