in reply to Re: URL/URI encoding strings to go into query strings
in thread URL/URI encoding strings to go into query strings
URI::Escape can be used to escape and unescape "special" characters in URI's.
URI::Escape should be used to escape and unescape "special" characters in URI's query strings. :)
Just me being quite picky (hey, I just got home from work at 3:30AM. I'm allowed to be picky {grin}). All I mean here is that URI::Escape should always be used if you are planning on passing anything more trivial than "a=bc" as a query string. Also note that URI::Escape should only be used on the query string, not the entire URI. So you'd do this:
print 'http://www.perlmonks.org/index.pl?node=', uri_escape('Am I #1? +Yeah!');
rather than this:
print uri_escape('http://www.perlmonks.org/index.pl?node=Am I #1? Yeah +!');
Why? Because the latter will also escape the colon, slashes, the question marks, and even that '=' sign (I hate that last one). The annoying thing I find about URI::Escape is the fact that you have to be careful what part of the query string you pass it, as it will sometimes give undesired results. I already know that you knew that steves, just me being picky and trying to clarify something that might already be clear to readers :). ++ to you for recommending the right module for the job :)
If the above content is missing any vital points or you feel that any of the information is misleading, incorrect or irrelevant, please feel free to downvote the post. At the same time, reply to this node or /msg me to tell me what is wrong with the post, so that I may update the node to the best of my ability. If you do not inform me as to why the post deserved a downvote, your vote does not have any significance and will be disregarded.
|
|---|