Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 2x 2x 2x 2x 18x 6x 12x 2x | /**
* 获取字节长度
* @param str // 需要获取字节长度的字符串
* 中文+2 英文+1
*/
export const getBiteLen = (str: string) => {
Iif (typeof str !== 'string') return 0;
let len = 0;
for (let i = 0; i < str.length; i++) {
if (str.charCodeAt(i) > 127 || str.charCodeAt(i) === 94) {
len += 2;
} else {
len += 1;
}
}
return len;
};
|