URLencode omits characters from the encoding

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.

Shouldn’t it too be converted unless I escape it?

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 ’

Robert Ameeti

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.

I understand that the & must sometimes be part of the ‘additional’ characters. But I’m not needing to encode it.

Check out this url that has the & unencoded and also fails to properly display the single quote using the %27

http://wheresthedance.com/userData/wtdSchedule_r.php?sponsorID=TORRASQU1&col_10=date&col_60=sponsorName&caption=Club’s%20ABC http://wheresthedance.com/userData/wtdSchedule_r.php?sponsorID=TORRASQU1&col_1=levelIcon&col_10=date&col_25=leaderPicture&col_4=dow&col_60=sponsorName&col_90=address&sectionHeader=true&caption=Club’s%20ABC</br>Yellow%20=%20Classes%20%20%20%20%20Green%20=%20Workshops&col_15=flyer

Robert Ameeti

Ooops. I meant to simplify it to this.

http://wheresthedance.com/userData/wtdSchedule_r.php?sponsorID=TORRASQU1&col_10=date&col_60=sponsorName&caption=Club’s%20ABC http://wheresthedance.com/userData/wtdSchedule_r.php?sponsorID=TORRASQU1&col_10=date&col_60=sponsorName&caption=Club’s%20ABC

Robert Ameeti

Dang. Can’t seem to make this simple, can I? Grrr. Or is the forum posting ‘helping’ me? There should be a single url below.

http://wheresthedance.com/userData/wtdSchedule_r.php?sponsorID=TORRASQU1&col_10=date&col_60=sponsorName&caption=Club's%20ABC

Robert Ameeti

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.