复制代码 代码如下:
'************************************
'截取文字长度函数,支持utf-8
'输入参数:
' 1、文字内容
' 2、文字最大长度
'************************************
public function cut_title(title,tlen)
dim k,i,d,c
dim istr
dim fortotal
if cdbl(tlen) > 0 then
k=0
d=strlen(title)
istr=""
fortotal = len(title)
for i=1 to fortotal
c=abs(ascw(mid(title,i,1)))
if c>255 then
k=k+2
else
k=k+1
end if
istr=istr&mid(title,i,1)
if clng(k)>clng(tlen) then
istr=istr".."
exit for
end if
next
cut_title=istr
else
cut_title=""
end if
end function
'*******************************
'检测文字长度函数,支持utf-8
'输入参数:
' 1、文字内容
'*******************************
public function strlen(strtext)
dim k,i,c
dim fortotal
k=0
fortotal = len(strtext)
for i=1 to fortotal
c=abs(ascw(mid(strtext,i,1)))
if c>255 then
k=k+2
else
k=k+1
end if
next
strlen=k
end function
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!