打印本文 打印本文 关闭窗口 关闭窗口
asp 中英文字符长度检测判断函数
作者:佚名  文章来源:本站原创  点击数4303  更新时间:2012/12/5 18:46:27  文章录入:mintao  责任编辑:mintao

asp 中英文字符长度检测判断函数

以下是代码片段:

function strLength(str)
       ON ERROR RESUME NEXT
       dim WINNT_CHINESE
       WINNT_CHINESE    = (len("论坛")=2)
       if WINNT_CHINESE then
          dim l,t,c
          dim i
          l=len(str)
          t=l
          for i=1 to l
             c=asc(mid(str,i,1))
             if c<0 then c=c+65536
             if c>255 then
                t=t+1
             End if
          next
          strLength=t
       else
          strLength=len(str)
       End if
       if err.number<>0 then err.clear
End function

如果有错误提示,有可能是中文空格所致,删除空格即可。
打印本文 打印本文 关闭窗口 关闭窗口