<% '判断包含双字节字符的字符串长度 Function getStrLen(str) dim x,y,i x =len(str) y =0 for i =1to x ifasc(mid(str,i,1))<0orasc(mid(str,i,1))>255then y = y +2'双字节 else y = y +1'ascii码字符 endif next getStrLen = y End Function '从指定(包含双字节字符的)字符串中第一个字符起的指定长度的字符串 '指定的长度为单字节长度,即字节数 Function leftString(str,length) dim x,y,i,s s=str x =len(str) y =0 if x >=1then for i =1to x ifasc(mid(str,i,1)) <0orasc(mid(str,i,1)) >255then y = y +2 else y = y +1 endif if y >= length then s =left(str,i) '字符串字节数 exitfor endif next endif leftString = s End Function %> <%=getStrLen("双字节字符abc")%><br> <%=leftString("abc双字节字符字符串",10)%>