Re: URLEncode/Decode

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: mikeb (mailbox.google_at_nospam.mailnull.com)
Date: 08/19/04


Date: Thu, 19 Aug 2004 10:17:16 -0700

Nic wrote:
> Hello all,
>
> I ran into a problem encoding/decoding special characters in URLs.
> by using Server.UrlEncode and Server.UrlDecode.
> Basically, encoding x+y results in x%2by, however decoding
> x%2by results in x y (missing the +).
>

This does not happen to me:

             Console.WriteLine( HttpUtility.UrlDecode( "x%2by"));

I'm guessing that what's happening is that you're passing in to
UrlDecode a string that you've gotten from Request.QueryString[] (or
something similar).

The strings in the QueryString collection have already been decoded, so
you would be in effect decoding the string twice which would result in
the behavior you're seeing ('+' gets decoded into a space).

-- 
mikeb


Relevant Pages

  • Re: How to sort array
    ... same string you're opening, use a variable instead of specifying the ... same string twice to make sure you do close it: ... file descriptors, at least as it's currently written). ... Checking the return value of getline is better, thanks, although in this ...
    (comp.lang.awk)
  • Re: reversing a string - newbie question
    ... >> string in reverse direction. ... Since `strlen' has to iterate through the string to find its length, ... While the OP could not avoid to iterate through the string twice, ...
    (comp.lang.c)
  • Re: Ada BIND was: Improving Adas image - Was: 7E7 Flight Controls Electronics
    ... > number of characters or the maximum buffer size. ... > in many cases you have to read the string twice while Ada allows you to ...
    (comp.lang.ada)
  • Re: Could you comment on my little program? Thank you!
    ... Oliver Wong wrote: ... I don't think you should have the client code pass a string in, because if the client unwittingly passes in the same string twice, that could screw things up. ...
    (comp.lang.java.programmer)