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   360292 use strict;
  7         60  
  7         261  
4 7     7   38 use warnings;
  7         14  
  7         215  
5              
6 7     7   40 use XSLoader;
  7         12  
  7         170  
7 7     7   3468 use parent 'Exporter';
  7         2209  
  7         38  
8              
9             our $VERSION = '0.002000';
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 3663 my ($text, $more) = @_;
20 14 50       32 return undef unless defined($text);
21              
22 14         33 utf8::encode($text);
23 14 50       63 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__