File Coverage

blib/lib/URI/XSEscape.pm
Criterion Covered Total %
statement 16 17 94.1
branch 2 4 50.0
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 24 27 88.8


line stmt bran cond sub pod time code
1             package URI::XSEscape;
2              
3 7     7   76170 use strict;
  7         7  
  7         150  
4 7     7   19 use warnings;
  7         8  
  7         118  
5              
6 7     7   25 use XSLoader;
  7         8  
  7         98  
7 7     7   2590 use parent 'Exporter';
  7         1538  
  7         28  
8              
9             our $VERSION = '0.000008';
10             XSLoader::load( 'URI::XSEscape', $VERSION );
11              
12             our @EXPORT_OK = qw{
13             uri_escape
14             uri_escape_utf8
15             uri_unescape
16             };
17              
18             sub uri_escape_utf8 {
19 14     14 1 2632 my ($text, $more) = @_;
20 14 50       22 return undef unless defined($text);
21              
22 14         18 utf8::encode($text);
23 14 50       46 return uri_escape($text) unless defined($more);
24 0           return uri_escape($text, $more);
25             }
26              
27             eval {
28             # ENV{'PERL_URI_XSESCAPE'} = undef # yes
29             # ENV{'PERL_URI_XSESCAPE'} = 1 # yes
30             # ENV{'PERL_URI_XSESCAPE'} = 0 # no
31             if ( ! defined $ENV{'PERL_URI_XSESCAPE'} || $ENV{'PERL_URI_XSESCAPE'} ) {
32             require URI::Escape;
33              
34             *URI::Escape::uri_escape = *URI::XSEscape::uri_escape;
35             *URI::Escape::uri_escape_utf8 = *URI::XSEscape::uri_escape_utf8;
36             *URI::Escape::uri_unescape = *URI::XSEscape::uri_unescape;
37             }
38             };
39              
40             1;
41              
42             __END__