<%
Class Utility
Private Reg
Public Function HTMLEncode (STR)
If IsNull (str) or IsEmpty (str) or str = "" Then
HTMLEncode = ""
Else
Dim s:s = Str
s = Replace (S, "<", "<")
s = Replace (S, ">", ">")
s = Replace (S, "", "")
s = Replace (S, vbCrLf, "<br/>")
HTMLEncode = S
End If
End Function
Public Function Htmlfilter (ByVal Code)
If IsNull (code) Or IsEmpty (code) Then Exit Function
With Reg
. Global = True
. Pattern = "<[^>]+?>"
End With
Code = Reg.replace (Code, "")
Htmlfilter = Code
End Function
Public Function Limit (ByVal Str, ByVal Num)
Dim Strlen:strlen = Len (STR)
If StrLen * 2 <= Num Then
Limit = Str
Else
Dim Strrlen
Call Rlen (STR, Strrlen)
If Strrlen <= Num Then
Limit = Str
Else
Dim I
Dim Restr
If StrLen > Num * 2 Then
i = Num \2
Restr = Left (Str, i)
Call Rlen (RESTR, Strrlen)
While Strrlen < Num
i = i + 1
Restr = Left (Str, i)
Call Rlen (RESTR, Strrlen)
Wend
Else
i = StrLen
RESTR = Str
Call Rlen (RESTR, Strrlen)
While Strrlen > Num
i = I-1
Restr = Left (Str, i)
Call Rlen (RESTR, Strrlen)
Wend
End If
Call Rlen (Right (restr, 1), Strrlen)
If Strrlen > 1 Then
Limit = Left (Restr, i-1) & "..."
Else
Limit = Left (Restr, i-2) & "..."
End If
End If
End If
End Function
Public Function Encode (ByVal Str)
str = Replace (str, "" "", "" ")
str = Replace (str, "" "," "")
Encode = Str
End Function
Public Function Encodeall (ByVal Str)
Dim M, MS
Reg.pattern = "[\x00-\xff]"
Set MS = Reg.execute (STR)
For all M in MS
str = Replace (str, m.value, "&#" & Asc (M.value) & ";")
Next
Encodeall = Str
End Function
Private Sub Class_Initialize ()
Set Reg = New RegExp
Reg.global = True
End Sub
Private Sub Class_Terminate ()
Set Reg = Nothing
End Sub
Public Sub Rlen (ByRef Str, ByRef Rl)
With Reg
. pattern = "[^\x00-\xff]"
Rl = Len (. Replace (Str, ".."))
End With
End Sub
End Class
%>
<%
Dim util:set Util = New Utility
%>