Public Function UTF8EncodeGET(ByVal szInput As String) As String
Dim wch As String
Dim uch As String
Dim szRet As String
Dim x As Long
Dim inputLen As Long
Dim nAsc As Long
If szInput = "" Then
UTF8EncodeGET = szInput
Exit Function
End If
inputLen = Len(szInput)
For x = 1 To inputLen
' Get each character
wch = Mid(szInput, x, 1)
' Get the corresponding UNICODE encoding
nAsc = AscW(wch)
' Check if it's less than 0 and add 65536
If nAsc < 0 Then nAsc = nAsc + 65536
' Check if it's an ASCII character (<128)
If (nAsc And &HFF80) = 0 Then
szRet = szRet & wch
Else
' Encode the character as UTF-8
uch = "%" & Hex(nAsc \ 2 ^ 8) & "%" & Hex(nAsc Mod 256)
szRet = szRet & uch
End If
Next
UTF8EncodeGET = szRet
End Function