计算微信文本字节长度
export function calcBytesLength(text = '') {
return text.split('').reduce((length, item) => {
// 英文字符算 1 个字节,其他均算 3 个字节
return length + (item.charCodeAt(0) < 128 ? 1 : 3);
}, 0);
}
export function calcBytesLength(text = '') {
return text.split('').reduce((length, item) => {
// 英文字符算 1 个字节,其他均算 3 个字节
return length + (item.charCodeAt(0) < 128 ? 1 : 3);
}, 0);
}