String.prototype.getBytes = function()
{
var cArr = this.match(/[^\x00-\xff]/ig);
return this.length + (cArr == null ? 0 : cArr.length*2);
}
javascript 获取带中文的字符长度(汉字占3位)
最新推荐文章于 2024-09-29 14:00:00 发布
String.prototype.getBytes = function()
{
var cArr = this.match(/[^\x00-\xff]/ig);
return this.length + (cArr == null ? 0 : cArr.length*2);
}