如何将长的标题用省略号收尾(2)



以上为函数,下面就可以直接调用。


<%call conleft(rs("content"),10)%>


OK,相信以后遇到这些问题应该是NO PROBLEM 

为了解决中英文截取的问题,建议大家使用如下函数:


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

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/3229.html