Why is %2526
used instead of %26
to encode an &
?
Im invoking a URL to an external site and when I encode the &
as %2526
the parameters are passed correctly but when I just use %26
they are not.
Why is %2526
used instead of %26
to encode an &
?
Im invoking a URL to an external site and when I encode the &
as %2526
the parameters are passed correctly but when I just use %26
they are not.
If you url-encode an ampersand you get
%26
. If you url-encode%26
you get%2526
. Thus, it is url-encoded twice.%25
is the percent character, so%2526
URLDecoded results inwhich URLDecoded results in
For some reason, the call you make seems to require doubly percent encoded input. Without knowing more about what you're doing, it's impossible to know why, but I guess all is in order.
Apparently it gets decoded twice in the process, first from
%2526
to%26
and then from%26
to&
.You shouldn't dwell too long on the why; if this works, just use it like this.
If the URL is used in return URL or value of another query string, the Reserved and Excluded characters should be doubled encoded. & is single-encoded as %26 and double-encoded as %2526.
&
is indeed encoded as%26
.You can test it creating an HTML file, opening it in a browser, inputing symbols you need to test and looking at the resulting URL in browser: