javascript字符类型操作函数
//获取字符串的长度 String.prototype.getByteLength = function() { var bytes=0,i=0; for (; i<this.length; ++i,++bytes) { if ( this.charCodeAt(i) > 255 ) { ++bytes; } } return bytes; }; /*函数调用方法*/ var a ="aaa ^&*"; var length = a.getByteLength(); alert(length);