揰掵佲 发表于 2021-12-7 10:15:16

提取的QQ的Str操作JS,感觉还是不错的

/*
本段JS代码由乐易助手生成!助手下载地址:https://www.leybc.com/thread-7123-1-1.hml
请勿用于非法用途,产生后果均有使用者自负!
*/
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
            }).replace(/&#u({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 + ";"
            })
      },
      "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 + '"');
                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
      }
    }
}()
页: [1]
查看完整版本: 提取的QQ的Str操作JS,感觉还是不错的