截取實(shí)際長(zhǎng)度字符串,并用空格替換
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
<%
'============================
'函數(shù)名w_cut(type,num)
'作用:字符串截取
'參數(shù)type,num
'type:字符串內(nèi)容
'num:字符串被截取的長(zhǎng)度
'=============================
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
%>
相關(guān)文章
asp 存貯過程 (SQL版asp調(diào)用存儲(chǔ)過程)
asp 存貯過程 (SQL版asp調(diào)用存儲(chǔ)過程)...2007-11-11ASP中Split分割字符串函數(shù)的實(shí)例用法
ASP中Split函數(shù)的用法,用split分割截取字符串,看幾個(gè)例子就能理解了2013-03-03ASP編程入門進(jìn)階(十八):FSO組件之文件操作(中)
ASP編程入門進(jìn)階(十八):FSO組件之文件操作(中)...2007-01-01如何將長(zhǎng)的標(biāo)題用省略號(hào)收尾
如何將長(zhǎng)的標(biāo)題用省略號(hào)收尾...2007-02-02ServerVariables集合檢索預(yù)定的環(huán)境變量
ServerVariables集合檢索預(yù)定的環(huán)境變量...2007-02-02