JavaScript or ASP.NET URL Encoding - Dot - Period
I
was building an interface to a Google Search Appliance and one of its
requirements is to double encode the URL. Interestingly, I noticed that none of
the standard JavaScript URL encode functions like encodeURIComponent, encodeURI or escape actually encode the period or dot. Even
the asp.net HttpUtility functions like UrlEncode, UrlPathEncode, UrlEncodeUnicode
etc. does not encode the period or dot. If the query string data contains a period
and if it is not encoded, the Google Search Appliance always returned the wrong
data.
Naturally,
I googled around and I could not find any
reasonable solution to the problem. It seems that the widely accepted solution
is to literally replace the period or dot with its ASCII value "%2E".
Even
though it is a quick & dirty solution, it actually worked and the Google
search appliance returned the valid data!! So, the quick JavaScript workaround
is - anystring.replace (".","%2E")
Labels: %2E, ASCII, encodeURI, encodeURIComponent, Encoding, escape, Google, Google Search Appliance, Javascript, String, URI, URL, URL Encoding
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]