中英文混合字符串的截取函数

[ 2006-06-22 15:58:51 | 作者: admin ]
字号: | |
Function gotTopic(str,strlen)
        if str="" then
               gotTopic=""
               exit function
        end if
        dim l,t,c, i
        str=replace(replace(replace(replace(str,"&nbsp;"," "),"&quot;",chr(34)),"&gt;",">"),"&lt;","<")
        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," ","&nbsp;"),chr(34),"&quot;"),">","&gt;"),"<","&lt;")
End Function
评论Feed 评论Feed: http://blog.xg98.com/feed.asp?q=comment&id=670

这篇日志没有评论。

此日志不可发表评论。