摘要: /**得到字符串的字符长度(一个汉字占两个字符长)*/ functiongetBytesLength(str){//在GBK编码里,除了ASCII字符,其它都占两个字符宽returnstr.replace(/[^x00-xff]/g,'xx').length;}/***根据字符长来截取字符串*/functionsubStringByBytes(val,maxBytesLen){varlen=maxBytesLen;varresult=val.slice(0,len);while(getBytesLength(result)>maxBytesLen){result=resu 阅读全文
posted @ 2010-01-06 19:31 曾祥展 阅读(437) 评论(0) 推荐(0) 编辑