Click to See Complete Forum and Search --> : escaping urls


Scriptage
05-23-2005, 09:12 AM
Is there a simple function in perl to escape a string so that it can be safely used in an URL. I've had a look at URI::Escape and URI::URL but they seem to miss out on some character escapes, ie "~" is not escaped. What I could really do with is a function similar to javascripts escape();
Any help is greratly appreciated.
Regards
Carl

Jeff Mott
05-24-2005, 09:42 AM
Both URI::Escape and URI::URL would seem to be doing their job correctly. The "~" is not a reserved character in URIs. Some URL encoding implementations, such as JavaScript's escape, encode everything that is not alphanumeric simply because it's easier than looking up which individual characters must be encoded.

Scriptage
05-24-2005, 12:32 PM
Cheers Jeff.
I just didn't know if there would be any conflict in the decoding using CGI.pm as I needed to emulate HTML form URI encoding.
Thanks once again.
Regards
Carl