代码的转换

来源:百度知道 编辑:UC知道 时间:2024/06/21 20:29:40
我想把中文或者英文转化为类似%CE%D2%CA%C7%D6的代码

据说有软件可以 有的话给个地址

据说VBS也可以 有的话贴个代码,谢谢了

做成了一个函数,代码如下:

Public Function URLEncode(ByVal strParameter As String) As String
Dim s As String
Dim I As Integer
Dim intValue As Integer
Dim TmpData() As Byte

s = ""
TmpData = StrConv(strParameter, vbFromUnicode)
For I = 0 To UBound(TmpData)
intValue = TmpData(I)
If (intValue >= 48 And intValue <= 57) Or _
(intValue >= 65 And intValue <= 90) Or _
(intValue >= 97 And intValue <= 122) Then
s = s & Chr(intValue)
ElseIf intValue = 32 Then
s = s & "+"
Else
s = s & "%" & Hex(intValue)
End If
Next I
URLEncode = s

End Function