|
ASP中一个字符串处理类(加强)(VBScript)(6) else Dim P_len,x P_len=0 StrLen=0 P_len=Len(Trim(Str)) For x=1 To P_len If Asc(Mid(Str,x,1))<0 Then StrLen=Int(StrLen) + 2 Else StrLen=Int(StrLen) + 1 End If Next end if End Function '**************************************************************************** '' @功能说明: 截取源字符串Str的前LenNum个字符(一个中文字符为2个字节长) '' @参数说明: - str [string]: 源字符串 '' @参数说明: - LenNum [int]: 截取的长度 '' @返回值: - [string]: 转换后的字符串 '**************************************************************************** Public Function CutStr(Str,LenNum) Dim P_num Dim I,X If StrLen(Str)<=LenNum Then Cutstr=Str Else P_num=0 X=0 Do While Not P_num > LenNum-2 X=X+1 If Asc(Mid(Str,X,1))<0 Then P_num=Int(P_num) + 2 Else P_num=Int(P_num) + 1 End If Cutstr=Left(Trim(Str),X)&"..." Loop End If End Function end class %>
|