File Coverage

blib/lib/App/ansiprintf/Util.pm
Criterion Covered Total %
statement 19 19 100.0
branch 3 6 50.0
condition n/a
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::ansiprintf::Util;
2 2     2   25 use v5.14;
  2         13  
3 2     2   9 use warnings;
  2         21  
  2         100  
4              
5 2     2   11 use Encode;
  2         4  
  2         188  
6 2     2   15 use Exporter 'import';
  2         4  
  2         135  
7             our @EXPORT_OK = qw(decode_argv unescape);
8              
9 2     2   1331 use charnames ':full';
  2         1667  
  2         14  
10              
11             sub decode_argv {
12             map {
13 9 50   9 0 21 utf8::is_utf8($_) ? $_ : decode('utf8', $_);
  22         485  
14             }
15             @_;
16             }
17              
18             sub unescape {
19 22 50   22 0 58 local *_ = @_ > 0 ? \$_[0] : \$_;
20 22         135 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 2 50       284 }{ eval qq["$1"] or die "$1 : string error.\n"}xiger;
31             }
32              
33             1;