URLDecode ?

Results 1 to 3 of 3

Thread: URLDecode ?

  1. #1
    django reinhardt Guest

    Default URLDecode ?

    sorry if this is a stupid question...<BR><BR>is there a way to reverse a url-encoded string?<BR><BR>for example, if i do:<BR><BR>server.urlencode("http://www.mydomain.com")<BR><BR>i&#039;ll get:<BR><BR>http%3A%2F%2Fwww%2Emydomain%2Ecom<BR>< BR>how can i do the opposite of that? i thought i knew how - but i evidently didn&#039;t<BR><BR>thank you

  2. #2
    Join Date
    Dec 1969

    Default Found this function

    a while back, I think on 4 guys. No built in method to decode so need to do on your own:<BR><BR>Function URLDecode(Byval What)<BR>&#039;URL decode function<BR>&#039;2001 Antonin Foller, PSTRUH Software, http://www.pstruh.cz<BR> Dim Pos, pPos<BR><BR> &#039;replace + to space<BR> What = Replace(What, "+", " ")<BR><BR> On Error Resume Next<BR> Dim Stream: Set Stream = CreateObject("ADODB.Stream")<BR> If Err = 0 Then &#039;URLDecode using ADODB.Stream, if possible<BR> On Error Goto 0<BR> Stream.Type = 2 &#039;String<BR> Stream.Open<BR><BR> &#039;replace all %XX to character<BR> Pos = Instr(1, What, "%")<BR> pPos = 1<BR> Do While Pos &#062; 0<BR> Stream.WriteText Mid(What, pPos, Pos - pPos) + _<BR> Chr(CLng("&H" & Mid(What, Pos + 1, 2)))<BR> pPos = Pos + 3<BR> Pos = Instr(pPos, What, "%")<BR> Loop<BR> Stream.WriteText Mid(What, pPos)<BR><BR> &#039;Read the text stream<BR> Stream.Position = 0<BR> URLDecode = Stream.ReadText<BR><BR> &#039;Free resources<BR> Stream.Close<BR> Else &#039;URL decode using string concentation<BR> On Error Goto 0<BR> &#039;UfUf, this is a little slow method. <BR> &#039;Do not use it for data length over 100k<BR> Pos = Instr(1, What, "%")<BR> Do While Pos&#062;0 <BR> What = Left(What, Pos-1) + _<BR> Chr(CLng("&H" & Mid(What, Pos+1, 2))) + _<BR> Mid(What, Pos+3)<BR> Pos = Instr(Pos+1, What, "%")<BR> Loop<BR> URLDecode = What<BR> End If<BR>End Function<BR>

  3. #3
    django reinhardt Guest

    Default RE: Found this function

    krank you, thank<BR><BR>i mean<BR><BR>thank you, krank<BR><BR>i&#039;ll give this a try<BR><BR>i appreciate it :)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts