// Get string width
function getStringWidth(val) {
let len = 0;
for (let i = 0; i < val.length; i++) {
let length = val.charCodeAt(i);
if( length >= 0 && length <= 128 ) {
len += 1;
} else {
len += 2;
}
}
return len;
网友评论