如何读取标题的指定子节内容?

来源:百度知道 编辑:UC知道 时间:2024/05/15 03:35:53
ASP网页制作遇室如下问题,当标题大于60个字节时,读取前60个字节的内容,但RS读取以字符计,半角全角都按一个字算,结果读出来的标题有长有短,请问如果要读出前60个字节的内容,rs有什么函数可代替??

<%if lenb(rs("title"))>60then%>
<%=left(rs("title"),30)%>......
<%else%>
<%=rs("title")%>
<%end if%>
如:

123456789012345678901234567890......

123456789012345678901234567890......

123456789012345678901234567890

规规规规规规规规规规规规规规规规规规规规规规规规规24规规规......

规规规规规规规规规规规规规规规规规规规规规规规规规24规规规......

规规规规规规规规规规规规规规规规规规规规规规规规规24

function gotTopic(str,strlen)
if str="" then
gotTopic=""
exit function
end if
dim l,t,c, i
str=replace(replace(replace(replace(str," "," "),""",chr(34)),">",">"),"<","<")
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
gotTopic=left(str,i) & "…"
exit for
else
gotTopic=str
end if
next
gotTopic=replace(replace(replace(replace(gotTopic," "," "),chr(34),"""),">",">"),"<","<")
end function

卷卡式带分啊降幅达 阿凡