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…