日期:2014-05-17  浏览次数:20898 次

ASP如何截短字串
ASP如何截短字串对中文当一个字符,英文和半角当半个字符,谢谢了。

------解决方案--------------------
<%
Function Mylen2(txt,length)
txt=trim(txt)
x = len(txt)
y = 0
if x > = 1 then
for ii = 1 to x
if asc(mid(txt,ii,1)) < 0 or asc(mid(txt,ii,1)) > 255 then
y = y + 2
else
y = y + 1
end if
if y > = length then
txt = left(trim(txt),ii) ' "字符串限长
exit for
end if
next
Mylen2= txt
else
Mylen2= " "
end if
End Function

a= "在这里发贴,表示您接受了CSDN社区的 用户行为准则。 "
response.write mylen2(a,15)
%>