一个不错的字符串转码解码函数(自写)_javascript技巧
程序员文章站
2022-03-31 13:17:40
...
function isString(variable) { return Object.prototype.toString.call(variable).indexOf('String') != -1; } function isNumeric(variable) { return !isNaN(parseFloat(variable)) && isFinite(variable); } function stringEncode(string) { string = isString(string) || isNumeric(string) ? String(string) : ''; var code, i = 0, code_string = '', len = string.length; while(i