<%
Function GetTrueLength(ByVal strChinese, ByVal lenMaxWord)
Dim i, strTail, lenTotal, lenWord
Dim strWord, bOverFlow, RetString
If strChinese = "" Or VarType(strChinese) = vbNull Or CLng(lenMaxWord) <= 0 Then
GetTrueLength = ""
Exit Function
End If
strTail = "..."
bOverFlow = False
lenTotal = 0
For i = 1 To Len(strChinese)
strWord = Mid(strChinese, i, 1)
If Asc(strWord) < 0 Or Asc(strWord) > 255 Then
lenTotal = lenTotal + 2
Else
lenTotal = lenTotal + 1
End If
Next
If lenTotal > lenMaxWord Then bOverFlow = True
If bOverFlow = True Then
lenWord = 0
RetString = ""
For i = 1 To Len(strChinese)
strWord = Mid(strChinese, i, 1)
If Asc(strWord) < 0 Or Asc(strWord) > 255 Then
lenWord = lenWord + 2
Else
lenWord = lenWord + 1
End If
If lenWord <= (lenMaxWord - Len(strTail)) Then
RetString = RetString + strWord
Else
GetTrueLength = RetString + strTail
Exit For
End If
Next
Else
GetTrueLength = strChinese
End If
End Function
%>
| |
|
<%=GetTrueLength("
| China to build the oil re |
| More than 200 Chinese ships and three aircraft have joined the search mission, and China has invited ROK authorities to send rescue boats and coast guard vessels, the spo |
|
|
| ",200)%> |
|