加入收藏 | 设为首页 | 会员中心 | 我要投稿 聊城站长网 (https://www.0635zz.com/)- 智能语音交互、行业智能、AI应用、云计算、5G!
当前位置: 首页 > 站长学院 > Asp教程 > 正文

截取实测长度文字串并将其空白化

发布时间:2023-04-22 14:22:07 所属栏目:Asp教程 来源:
导读:function cutstr(thestr,strlen)

dim l,t,c

l=len(thestr)

t=0

for dxy=1 to l

c=Abs(asc(Mid(thestr,dxy,1)))

if c>255 then

t=t+2

else

t=t+1

end if

if t>=strlen t
function cutstr(thestr,strlen)
 
dim l,t,c
 
l=len(thestr)
 
t=0
 
for dxy=1 to l
 
c=Abs(asc(Mid(thestr,dxy,1)))
 
if c>255 then
 
t=t+2
 
else
 
t=t+1
 
end if
 
if t>=strlen then
 
thev=left(thestr,dxy)
 
exit for
 
else
 
bu=strlen-t
 
for bui=1 to bu
 
strbu=" "
 
strbuall=strbuall&strbu
 
next
 
thev=thestr&strbuall
 
strbu=""
 
strbuall=""
 
end if
 
next
 
cutstr=thev
 
end function
 
<%
 
'============================
 
'函数名w_cut(type,num)
 
'作用:字符串截取
 
'参数type,num
 
'type:字符串内容
 
'num:字符串被截取的长度
 
'=============================
 
Function w_cut(types,num)
 
  dim ctypes,cnum,ci,tt,tc,cc
 
  ctypes=types:cnum=int(num):w_cut="":tc=0:cc=0
 
  for ci=1 to len(ctypes)
 
    if cnum<0 then w_cut=w_cut&"...":exit for
 
    tt=mid(ctypes,ci,1)
 
    if int(asc(tt))>=0 then
 
      w_cut=w_cut&tt
 
      tc=tc+1:cc=cc+1
 
      if tc=2 then
 
        tc=0:cnum=cnum-1
 
      end if
 
      if cc>5 then cnum=cnum-1:cc=0
 
    else
 
      cnum=cnum-1
 
      if cnum<=0 then w_cut=w_cut&"...":exit for
 
      w_cut=w_cut&tt
 
    end if
 
  next
 
End Function
 
%>
 
 

(编辑:聊城站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章