File Coverage

blib/lib/App/ansiecho/Util.pm
Criterion Covered Total %
statement 19 19 100.0
branch 2 4 50.0
condition 1 2 50.0
subroutine 7 7 100.0
pod 0 2 0.0
total 29 34 85.2


line stmt bran cond sub pod time code
1             package App::ansiecho::Util;
2 2     2   24 use v5.14;
  2         8  
3 2     2   12 use warnings;
  2         4  
  2         98  
4              
5 2     2   11 use Encode;
  2         3  
  2         165  
6 2     2   11 use Exporter 'import';
  2         3  
  2         110  
7             our @EXPORT_OK = qw(decode_argv unescape);
8              
9 2     2   1712 use charnames ':loose';
  2         22665  
  2         14  
10              
11             sub decode_argv {
12             map {
13 103 50   103 0 249 utf8::is_utf8($_) ? $_ : decode('utf8', $_);
  457         10269  
14             }
15             @_;
16             }
17              
18             sub unescape {
19 384 50   384 0 1215 local *_ = @_ > 0 ? \$_[0] : \$_;
20 384         1958 s{
21             ( \\ x\{[0-9a-f]+\}
22             | \\ x[0-9a-f]{2}
23             | \\ N\{[\-\ \w]+\}
24             | \\ N\{U\+[0-9a-f]+\}
25             | \\ c.
26             | \\ o\{\d+\}
27             | \\ \d{1,3}
28             | \\ .
29             )
30 22   50     1793 }{ eval qq["$1"] // die "$1 : string error.\n"}xiger;
31             }
32              
33             1;