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.


In reply to Re^2: URL/URI encoding strings to go into query strings by Coruscate
in thread URL/URI encoding strings to go into query strings by Cody Pendant

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.