URI::Encode::XS - a Perl URI encoder/decoder using C
use URI::Encode::XS qw/uri_encode uri_decode/; my $encoded = uri_encode($data); my $decoded = uri_decode($encoded);
This is a Perl URI encoder/decoder written in XS based on RFC3986. This module always encodes characters that are not unreserved. When decoding, invalid escape sequences are preserved, e.g:
uri_decode("foo%20bar%a/"); # foo bar%a/ uri_decode("foo%20bar%a"); # foo bar%a uri_decode("foo%20bar%"); # foo bar%
As of version 0.09, the bench script shows it to be significantly faster than URI::Escape:
bench
URI::Escape
Rate escape encode escape 144165/s -- -98% encode 8239785/s 5616% -- Rate unescape decode unescape 196870/s -- -97% decode 6051468/s 2974% --
However this is just one string - the fewer encoded/decoded characters are in the string, the closer the benchmark is likely to be (see bench for details of the benchmark). Different hardware will yield different results.
Another fast encoder/decoder which supports custom escape lists, is URI::XSEscape.
$ cpan URI::Encode::XS
Or
$ git clone https://github.com/dnmfarrell/URI-Encode-XS $ cd URI-Encode-XS $ perl Makefile.PL $ make $ make test $ make install
Aristotle Pagaltzis
Christian Hansen
Jesse DuMond
URI::XSEscape
URL::Encode
My article about the story of this module: The road to a 55x speedup with XS
https://github.com/dnmfarrell/URI-Encode-XS
See LICENSE
© 2016 David Farrell
To install URI::Encode::XS, copy and paste the appropriate command in to your terminal.
cpanm
cpanm URI::Encode::XS
CPAN shell
perl -MCPAN -e shell install URI::Encode::XS
For more information on module installation, please visit the detailed CPAN module installation guide.