[API]
WideCharToMultiByte

[CODE]
Public Function URLEncode(ByVal xURL As String, Optional ByVal ExcludeChars As String) As String
  Dim xLong1 As Long
  Dim xLong2 As Long
  Dim xChar1 As String
  
  xLong1 = Len(xURL)
  If Not xLong1 = 0& Then
    xLong2 = WideCharToMultiByte(65001, 0&, ByVal StrPtr(xURL), xLong1, ByVal 0&, 0&, ByVal 0&, ByVal 0&)
    xChar1 = String(xLong2, vbNullChar)
    xLong1 = WideCharToMultiByte(65001, 0&, ByVal StrPtr(xURL), xLong1, ByVal xChar1, xLong2, ByVal 0&, ByVal 0&)
    If xLong1 = xLong2 Then
      For xLong1 = 1& To Len(xChar1)
        xLong2 = Asc(Mid(xChar1, xLong1, 1&)) 'ascW?
        If InStr(ExcludeChars, Chr(xLong2)) = 0& Then
          Select Case xLong2
            Case 45&, 46&, 48& To 57&, 65& To 90&, 95&, 97& To 122& ', 126&
              URLEncode = URLEncode + Chr(xLong2)
            Case 32&
              URLEncode = URLEncode + "+"
            Case Else
              URLEncode = URLEncode + "%" + Right("0" + Hex(xLong2), 2&)
            End Select
          Else
          URLEncode = URLEncode + Chr(xLong2)
          End If
        Next
      End If
    End If
  End Function