Copy Code code as follows:
<%
Class Stringoperations
''****************************************************************************
"' @ Feature Description: Swap string for char-type array
' @ parameter Description:-str [string]: string to convert
' @ return value:-[array] char array
''****************************************************************************
Public Function ToCharArray (ByVal str)
ReDim Chararray (Len (str))
For i = 1 to Len (str)
Chararray (i-1) = Mid (str,i,1)
Next
ToCharArray = Chararray
End Function
''****************************************************************************
' @ Function Description: Converts an array into a string
' @ parameter Description:-arr [Array]: data that needs to be converted
' @ return Value:-[string] string
''****************************************************************************
Public Function arraytostring (ByVal arr)
For i = 0 to UBound (arr)
Strobj = strobj & Arr (i)
Next
arraytostring = Strobj
End Function
''****************************************************************************
' @ Feature Description: Check source string str starts with chars
' @ parameter Description:-str [string]: source string
' @ parameter Description:-chars [string]: Character/string of comparison
' @ return value:-[bool]
''****************************************************************************
Public function StartsWith (ByVal str, chars)
If left (Str,len (chars)) = Chars Then
StartsWith = True
Else
StartsWith = False
End If
End Function
''****************************************************************************
' @ Feature Description: Check source string str to end with chars
' @ parameter Description:-str [string]: source string
' @ parameter Description:-chars [string]: Character/string of comparison
' @ return value:-[bool]
''****************************************************************************
Public Function EndsWith (ByVal str, chars)
If Right (Str,len (chars)) = Chars Then
EndsWith = True
Else
EndsWith = False
End If
End Function
''****************************************************************************
' @ Feature Description: Copy n string str
' @ parameter Description:-str [string]: source string
' @ parameter Description:-n [int]: number of copies
' @ return Value:-[string] copied string
''****************************************************************************
Public Function Clone (ByVal str, n)
For i = 1 to n
Value = value & str
Next
Clone = value
End Function
''****************************************************************************
' @ Feature Description: Delete source string The first n characters of str
' @ parameter Description:-str [string]: source string
' ' @ parameter description:-n [int]: number of characters deleted
"@ return Value:-[string] deleted string
''****************************************************************************
Public function TrimStart (ByVal str, n)
Value = Mid (str, n+1)
TrimStart = value
End Function
''****************************************************************************
' @ Feature Description: Delete source string Str's last n string
' @ parameter Description:-str [string]: source string
' ' @ parameter description:-n [int]: number of characters deleted
"@ return Value:-[string] deleted string
''****************************************************************************
Public function trimend (ByVal str, n)
Value = Left (str, Len (str)-N)
TrimEnd = value
End Function
''****************************************************************************
' @ Feature Description: Check character character is an English character A-Z or a-Z
' @ parameter Description:-character [char]: Character checked
' @ return value:-[bool] If it is an English character, returns true, False instead
''****************************************************************************
Public Function isalphabetic (byVal character)
Asciivalue = CInt (ASC (character))
if (<= asciivalue and Asciivalue <=) or (<= Asciivalue and Asciivalue <=) 122
Isalphabetic = True
Else
Isalphabetic = False
End If
End Function
''****************************************************************************
' @ Feature Description: Case conversion of STR string
' @ parameter Description:-str [string]: source string
' @ return Value:-[string] converted String
''****************************************************************************
Public function swapcase (str)
For i = 1 to Len (str)
Current = Mid (str, I, 1)
If Isalphabetic (current) Then
High = ASC (UCase)
Low = ASC (LCase (current))
sum = high + low
return = return & Chr (SUM-ASC)
Else
return = return & current
End If
Next
Swapcase = return
End Function
''****************************************************************************
' @ Feature Description: Converts the first letter of each word in the source string str to uppercase
' @ parameter Description:-str [string]: source string
' @ return Value:-[string] converted String
''****************************************************************************
Public function capitalize (str)
Words = Split (str, "")
For i = 0 To UBound (words)
If not i = 0 Then
TMP = ""
End If
TMP = tmp & UCase (left (words (i), 1)) & Right (words (i), Len (words (i))-1)
Words (i) = tmp
Next
Capitalize = arraytostring (words)
End Function
''****************************************************************************
"" Filter to "'" after the source character str: ""
' @ parameter Description:-str [string]: source string
' @ return Value:-[string] converted String
''****************************************************************************
Public Function Checkstr (STR)
If Trim (str) = "" Or IsNull (str) Then
Checkstr= ""
Else
Checkstr=replace ((STR), "'" "," "")
End If
End Function
''****************************************************************************
' @ Feature Description: Filter the HTML code in str in the string
' @ parameter Description:-str [string]: source string
' @ return Value:-[string] converted 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) & Chr (a), "</p><p>"
Str=replace (STR,CHR), "<br>"
Htmlencode=str
End If
End Function
''****************************************************************************
' @ Feature Description: Calculates the length of the source string str (a Chinese character is 2 bytes long)
' @ parameter Description:-str [string]: source string
' @ return value:-[Int] The length of the source string
''****************************************************************************
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
''****************************************************************************
' @ Feature Description: Intercept source string Str's front lennum characters (one Chinese character is 2 bytes long)
' @ parameter Description:-str [string]: source string
' ' @ parameter description:-lennum [int]: Length of interception
' @ return Value:-[string]: converted 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, 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
%>