<script language="vbscript">
Function isalnum(ByVal strIn)
Dim c: c = Asc(LCase(Mid(strIn, 1, 1)))
If c>=Asc("0") And c<=Asc("9") Then
isalnum = True
ElseIf c>=Asc("a") And c<=Asc("z") Then
isalnum = True
Else
isalnum = False
End If
End Function
Function escape(ByVal strIn)
Dim i
For i=1 To Len(strIn)
Dim c: c = Mid(strIn, i, 1)
Dim a: a = AscW(c)
If isalnum(c) Then
escape = escape & c
ElseIf abs(a)<=128 Then
escape = escape & "%" & Hex(a)
Else
escape = escape & "%u" & Hex(a)
End If
Next
End Function
Function unescape(ByVal strIn)
Dim i
For i=1 To Len(strIn)
Dim c: c = Mid(strIn, i, 1)
If c = "%" Then
i = i + 1
c = Mid(strIn, i, 1)
If c = "u" Then
i = i + 1
c = Mid(strIn, i, 4)
i = i + 3
Else
c = Mid(strIn, i, 2)
i = i + 1
End If
unescape = unescape & ChrW("&H" & c)
Else
unescape = unescape & c
End If
Next
End Function
Dim a: a = escape("你好啊!hello world!")
Alert a
Alert unescape(a)