'**************************************************************************** '' @功能说明: 将字符串中的str中的HTML代码进行过滤 '' @参数说明: - str [string]: 源字符串 '' @返回值: - [string] 转换后的字符串 '**************************************************************************** Public Function HtmlEncode(str) If Trim(Str)="" Or IsNull(str) then HtmlEncode="" else str=Replace(str,">",">") str=Replace(str,"<","<") str=Replace(str,Chr(32)," ") str=Replace(str,Chr(9)," ") str=Replace(str,Chr(34),""") str=Replace(str,Chr(39),"'") str=Replace(str,Chr(13),"") str=Replace(str,Chr(10) & Chr(10), "</p><p>") str=Replace(str,Chr(10),"<br> ") HtmlEncode=str end if End Function '**************************************************************************** '' @功能说明: 计算源字符串Str的长度(一个中文字符为2个字节长) '' @参数说明: - str [string]: 源字符串 '' @返回值: - [Int] 源字符串的长度 '**************************************************************************** Public Function strLen(Str) If Trim(Str)="" Or IsNull(str) Then strlen=0 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
|