asp忽略中英文截取字符串

来源:互联网 发布:网络综艺特点 编辑:程序博客网 时间:2024/06/07 17:01

 Function cutStr(str,strlen)
 dim l,t,c
  l=len(str)
  t=0
  for i=1 to l
  c=Abs(Asc(Mid(str,i,1)))
  if c>255 then
   t=t+2
  else
   t=t+1
  end if
  if t>=strlen then
   cutStr=left(str,i)
  exit for
  else
   cutStr=str
  end if
  next
  cutStr=replace(cutStr,chr(10),"")
end Function