计算有多少个字符

 function gblen(val) {
    var len = 0;
    for (var i = 0; i < val.length; i++) {
        if (val.charCodeAt(i) > 127 || val.charCodeAt(i) == 94) {
            len += 2;
        } else {
            len++;
        }
    }
    return len;
}

猜你喜欢

转载自www.cnblogs.com/hyx626/p/10364104.html
0条评论
添加一条新回复