Re: What does this do?



Trevor L. wrote:
> Roland,
> I am not sure that your answer gives the whole story
>
> You state:

You snipped some relevant context so I'm putting it back in:

>>> function encodestring(s)
>>>
>>> {
>>>
>>> return s.toString().replace(/\%/g, "%26").replace(/=/g, "%3D");

This seems to be a client-side replacement for the Server.URLEncode
function, which encodes strings to allow them to be used in the URL without
causing errors.


> Converts variable to string, replace all % to %26, replace all = to
> %3D.
> But you don't say what %26 is (I think it is &) or what %3D (I think
> it is =)

Almost correct. These are the codes that represent the strings

>
> Why is this done is an intersting question, e.g. why replace = by = ?
>

It;s not. It's replacing = with %3D

& and = have special meanings in a URL querystring. & delimits the
name/value pairs, and = separates the name of the variable from its value.
If you need to pass data that contains these characters via querystring,
then you need to encode the data so as not to confuse the program that
parses the querystring in te requested page.


Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


.



Relevant Pages

  • Re: passing a % value in a querystring
    ... Dan wrote: ... > I would like to pass a whereclause to a page but each time I send the ... If you're creating the querystring in server-side ... This email account is my spam trap so I ...
    (microsoft.public.scripting.vbscript)
  • Re: Session object value not displaying
    ... Be more explicit please. ... Are you saying you have tried this? ... The querystring does not rely on cookies - it is just ... This email account is my spam trap so I ...
    (microsoft.public.inetserver.asp.general)
  • Re: Replacing QueryString Name-Value
    ... bob, thank you. ... > That does not explain why you are trying to manipulate the querystring. ... >> how else can i keep up with the filter criteria values from combo ... This email account is my spam trap so I ...
    (microsoft.public.scripting.jscript)
  • Re: Replacing QueryString Name-Value
    ... >> Below is code i'm firing with OnChange Property of a combo named ... >> selected on the combo the existing querystring. ... >> Error occurs if user selects the same catID combo again after user ... This email account is my spam trap so I ...
    (microsoft.public.scripting.jscript)
  • Re: QueryString query
    ... You pass the letter alone in the querystring. ... Please reply to the newsgroup. ... This email account is my spam trap so I ...
    (microsoft.public.inetserver.asp.db)