function getLen( str) {
var totallength=0;
for (var i=0;i<str.length;i++)
{ var intCode=str.charCodeAt(i);
if (intCode>=0&&intCode<=128) {
totallength=totallength+1; //非中文单个字符长度加 1 } else { totallength=totallength+2; //中文字符长度则加 2 } } //end for
return totallength;
}
|