This is a carryover from Panorama 6, in that not all characters are converted by URLencode. For instance, “A & B” should become “A%20%26%20B” but Panorama produces “A%20&%20B” leaving the ampersand untouched.
I am thinking that since the ampersand is a legitimate URL character, it does not get encoded. In the same way that the ‘A’ and ‘B’ were not encoded, the ampersand is left alone. Only the ‘space’ must be encoded.
Along these lines though, does anyone know how to encode a single quote ‘ for use in an HTML string? The single quote is not defined in HTML and I’m trying to figure out how to display it. My HTML strings regularly come up with /‘ instead of just ’
The purpose of URL encoding is not to create the URL of a web site; it’s to include additional text as a part of a URL. There are a handful fo characters that need to be converted in order to be interpretted correctly by the receiving server. These include &, /, ?, # and other otherwise legal url characters.
Go to any site that does encoding for you and they’ll encode the ampersand. Eric Meyer’s site for instance.
BTW, your single quote should be URLencoded to %27.
Fine, but it’s not a matter of getting it to display. Submit a query to Google, for example, using “Black%20&%20White” and it will search for Black. Change the query to “Black%20%26%20White” and it does search for Black and White. The ampersand needs to be encoded.
I did quite a bit of research on this when I developed the urlencode( function. The problem is, there is no standard for this (Eric Meyer notwithstanding), so there is no way to write a universal function that does the right thing in all situations. Yes, how urlencode( works may be wrong for google queries, but it is correct for some other applications. Each server makes it’s own decisions for how to do this. I believe I ultimately decided to leave it the same as Panorama 6, so that if you were using it before, it will work the same.