-
- '****************************************** ***********
- 'Function name: gotTopic
- 'Function: truncate the string, one Chinese character counts as two characters, and one English character counts as one character
- 'Parameter: str ----Original string
- ' strlen ---- intercept length
- 'Return value: intercepted string
- '********************************** *******************
- Function gotTopic(ByVal str, ByVal strlen)
- If str = "" Then
- gotTopic = ""
- Exit Function
- End If
- Dim l , t, c, i, strTemp
- str = Replace(Replace(Replace(Replace(str, " ", " "), """, Chr(34)), ">", ">"), " <", "<")
- l = Len(str)
- t = 0
- strTemp = str
- strlen = CLng(strlen)
- 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
- strTemp = Left(str, i)
- Exit For
- End If
- Next
- If strTemp <> str Then
- strTemp = strTemp & "…"
- End If
- gotTopic = Replace(Replace(Replace(Replace(strTemp, " ", " "), Chr(34), " ""), ">", ">"), "<", "<")
- End Function
- ?>
Copy code
|