Javascript String charLength()
String.prototype.charLength = function() { var len = 0;//from w w w . j a v a 2 s . com for (var i = 0; i < this.length; i++) { var c = this.charCodeAt(i); if ((c >= 0x0001 && c <= 0x007e) || (0xff60 <= c && c <= 0xff9f)) len += 1; else len += 2; } return len; };