String.prototype.substr2=function(a,b){var s = this.replace(/([^\x00-\xff])/g,"\x00$1");return(s.length<b)?this:s.substring(a,b).replace(/\x00/g,'');}
大于255的Ascii码 转换成 \x00$1 ‘字符串'.length==3 //true
‘字符串’.replace(/([^\x00-\xff])/g,'\x00$1').length==6 //true