[OPEN-ILS-DEV] en/decodeURIComponent vs un/escape()

Whalen, Liam Liam.Whalen at NRCan-RNCan.gc.ca
Tue Sep 20 12:50:30 EDT 2011


I am wondering about the use of encodeURIComponent() and decodeURIComponent as opposed to escape() and unescape() to parse URLs?  encodeURIComponent() and decodeURIComponent preserve UTF-8 characters while escape and unescape do not.  A quick 'grep -re "escape(" * | wc -l' in the /Evergreen-ILS-2.0.8/Open-ILS directory brings up 394 occurrences of escape() and unescape().  I imagine many of them do not deal with UTF-8 characters, but it might be a good idea to replace them all any way.
This website (http://www.dangrossman.info/2007/05/25/handling-utf-8-in-javascript-php-and-non-utf8-databases/) suggests using code like this:
if (encodeURIComponent) {
    string = encodeURIComponent(string); 
} else {
    string = escape(string);
}
in order to allow the ILS to work with older browsers.
I am willing to make the changes, but I wanted to get some input before going ahead and making close to 400 edits.
Liam

	Natural Resources Canada Library / Bibliothèque de Ressources naturelles Canada
615 rue Booth Street, 121, Ottawa, ON, Canada
K1A 0E9
Telephone / Téléphone : 613-995-4180
lwhalen at nrcan-rncan.gc.ca
Web: http://www.nrcan.gc.ca/library/ 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://libmail.georgialibraries.org/pipermail/open-ils-dev/attachments/20110920/b3208351/attachment.htm>


More information about the Open-ils-dev mailing list