Function urlencoding(vstrin)
  Dim strreturn
  Dim i
  Dim thischr
  Dim innercode
  Dim hight8
  Dim low8

  strreturn = ""
  For i = 1 To len(vstrin)
    thischr = mid(vstrin,i,1)
    If (abs(asc(thischr)) < &hff) Then
      strreturn = strreturn & thischr
    Else
      innercode = asc(thischr)
      If (innercode < 0) Then
        innercode = innercode + &h10000
      End If
      hight8 = (innercode and &hff00)\ &hff
      low8 = innercode and &hff
      strreturn = strreturn & "%" & hex(hight8) &  "%" & hex(low8)
    End If
  Next

  urlencoding = strreturn
End Function

Function bytes2bstr(vin)
  Dim strreturn
  Dim thischarcode
  Dim nextcharcode

  strreturn = ""
  For i = 1 To lenb(vin)
    thischarcode = ascb(midb(vin,i,1))
    If (thischarcode < &h80) then
      strreturn = strreturn & chr(thischarcode)
    Else
      nextcharcode = ascb(midb(vin,i+1,1))
      strreturn = strreturn & chr(clng(thischarcode) * &h100 + cint(nextcharcode))
      i = i + 1
    End If
  Next

  bytes2bstr = strreturn
End Function