|
NAMEURI::Encode - Simple percent Encoding/DecodingSYNOPSIS# OOP Interface use URI::Encode; my $uri = URI::Encode->new( { encode_reserved => 0 } ); my $encoded = $uri->encode($data); my $decoded = $uri->decode($encoded); # Functional use URI::Encode qw(uri_encode uri_decode); my $encoded = uri_encode($data); my $decoded = uri_decode($encoded); DESCRIPTIONThis modules provides simple URI (Percent) encoding/decodingThe main purpose of this module (at least for me) was to provide an easy method to encode strings (mainly URLs) into a format which can be pasted into a plain text emails, and that those links are 'click-able' by the person reading that email. This can be accomplished by NOT encoding the reserved characters. This module can also be useful when using HTTP::Tiny to ensure the URLs are properly escaped. If you are looking for speed and want to encode reserved characters, use URI::Escape::XS See this script <https://github.com/mithun/perl-uri-encode/raw/master/.author/benchmark.pl> for a comparison on encoding results and performance. METHODSnew()Creates a new object, no arguments are requiredmy $encoder = URI::Encode->new(\%options); The following options can be passed to the constructor
"encode($url, \%options)"This method encodes the URL provided. The $url provided is first converted into UTF-8 before percent encoding. Options set in the constructor, or defaults, can be overrided by passing them as the (optional) second argument. Options passed must be a hashref.$uri->encode("http://perl.com/foo bar"); $uri->encode( "http://perl.com/foo bar", { encode_reserved => 1 } ); "decode($url)"This method decodes a 'percent' encoded URL. If you had encoded the URL using this module (or any other method), chances are that the URL was converted to UTF-8 before 'percent' encoding. Be sure to check the format and convert back if required.$uri->decode("http%3A%2F%2Fperl.com%2Ffoo%20bar"); EXPORTED FUNCTIONSThe following functions are exported upon request. This provides a non-OOP interface
CHARACTER CLASSESReserved CharactersThe following characters are considered as reserved (RFC 3986 <http://tools.ietf.org/html/rfc3986>). They will be encoded only if requested.! * ' ( ) ; : @ & = + $ , / ? # [ ] Unreserved CharactersThe following characters are considered as Unreserved. They will not be encodeda-z A-Z 0-9 - _ . ~ DEPENDENCIESEncodeACKNOWLEDGEMENTSGisle Aas for URI::EscapeDavid Nicol for Tie::UrlEncoder SEE ALSORFC 3986 <http://tools.ietf.org/html/rfc3986>URI::Escape URI::Escape::XS URI::Escape::JavaScript Tie::UrlEncoder BUGS AND LIMITATIONSPlease report any bugs or feature requests to "bug-uri-encode@rt.cpan.org", or through the web interface at <http://rt.cpan.org/Public/Dist/Display.html?Name=URI-Encode>AUTHORMithun Ayachit "mithun@cpan.org"LICENSE AND COPYRIGHTCopyright (c) 2012, Mithun Ayachit. All rights reserved.This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
Visit the GSP FreeBSD Man Page Interface. |