javascript计算字符串长度 学习了:https://blog.csdn.net/u012934325/article/details/75214847 function getByteLen(val) { var len = 0; for (var i = 0; i < val.length; i++) { var a = val.charAt(i); if (a.match(/[^\x00-\xff]/ig) != null) { len += 2; } else { len += 1
/*** 计算字符串长度* 参数是要计算的字符串* 返回值当前字符串的长度*/function charactersLen (words) { let tempMapWordNum = {} let doubleByteTotal = 0 // 双字节 let chineseTotal = 0 // 汉字 let singleByteTotal = 0 // 单字节 let numTotal = 0 for (let i = 0; i < words.length; i++) { let c =