1,502
社区成员




Function UTF8EncodeURI(strUTF8 As String) As String
Dim nFor As Long
Dim nAsc As Long
Dim strWchar As String
Dim strURIchar As String
UTF8EncodeURI = ""
For nFor = 1 To Len(strUTF8)
strWchar = Mid(strUTF8, nFor, 1)
nAsc = AscW(strWchar)
If nAsc < 0 Then nAsc = nAsc + 65536
If (nAsc And &HFF80) = 0 Then
UTF8EncodeURI = UTF8EncodeURI & strWchar
ElseIf (nAsc And &HF000) = 0 Then
strURIchar = "%" & Hex(((nAsc \ 2 ^ 6)) Or &HC0) & Hex(nAsc And &H3F Or &H80)
UTF8EncodeURI = UTF8EncodeURI & strURIchar
Else
strURIchar = "%" & Hex((nAsc \ 2 ^ 12) Or &HE0) & _
"%" & Hex((nAsc \ 2 ^ 6) And &H3F Or &H80) & _
"%" & Hex(nAsc And &H3F Or &H80)
UTF8EncodeURI = UTF8EncodeURI & strURIchar
End If
Next
End Function
Function UTF8EncodeURI(strUTF8 As String) As String
Dim nFor As Long
Dim nAsc As Long
Dim strWchar As String
Dim strURIchar As String
UTF8EncodeURI = ""
For nFor = 1 To Len(strUTF8)
strWchar = Mid(strUTF8, nFor, 1)
nAsc = AscW(strWchar)
If nAsc < 0 Then nAsc = nAsc + 65536
If (nAsc And &HFF80) = 0 Then
UTF8EncodeURI = UTF8EncodeURI & strWchar
ElseIf (nAsc And &HF000) = 0 Then
strURIchar = "%" & Hex(((nAsc \ 2 ^ 6)) Or &HC0) & Hex(nAsc And &H3F Or &H80)
UTF8EncodeURI = UTF8EncodeURI & strURIchar
Else
strURIchar = "%" & Hex((nAsc \ 2 ^ 12) Or &HE0) & _
"%" & Hex((nAsc \ 2 ^ 6) And &H3F Or &H80) & _
"%" & Hex(nAsc And &H3F Or &H80)
UTF8EncodeURI = UTF8EncodeURI & strURIchar
End If
Next
End Function