获取字符串长度(中英文)

xiaoxiao2021-02-28  5

function GetLength(str){ var realLength = 0; for (var i = 0; i < str.length; i++) { charCode = str.charCodeAt(i); if (charCode >= 0 && charCode <= 128) realLength += 1; else realLength += 2; } return realLength;
转载请注明原文地址: https://www.6miu.com/read-2000279.html

最新回复(0)