
获得徽章 0
赞了这篇沸点
赞了这篇文章
赞了这篇文章
赞了这篇文章
赞了这篇文章
赞了这篇文章
赞了这篇文章
赞了这篇文章
赞了这篇文章
赞了这篇文章
赞了这篇文章
// 获取字符串长度 中文字符占2
const getStrLength = (str: string): number => {
const len = str.length;
let reLen = 0;
for (let i = 0; i < len; i++) {
if (str.charCodeAt(i) < 27 || str.charCodeAt(i) > 126) {
reLen += 2;
} else {
reLen += 1;
}
}
return reLen;
};
const getStrLength = (str: string): number => {
const len = str.length;
let reLen = 0;
for (let i = 0; i < len; i++) {
if (str.charCodeAt(i) < 27 || str.charCodeAt(i) > 126) {
reLen += 2;
} else {
reLen += 1;
}
}
return reLen;
};
展开
评论
点赞
赞了这篇文章
赞了这篇文章
赞了这篇文章
赞了这篇文章