UrlDecode

Decode a URL encoded string.

code format="vb" ' UrlDecode - function to return decoded version of a URL encoded string ' ======================================================================

function UrlDecode$(str$) i = 1 while i <= len(str$) c$ = mid$(str$, i, 1) if c$ = "+" then ' Convert + to space c$ = " " end if       if c$ = "%" then ' Found an encoded character d$ = mid$(str$, i + 1, 2) h = hexdec(d$) if h <> 0 then c$ = chr$(h) i = i + 2 end if       end if        UrlDecode$ = UrlDecode$ + c$        i = i + 1 next end function code