File Coverage

lib/Text/Undiacritic.pm
Criterion Covered Total %
statement 23 23 100.0
branch 2 2 100.0
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 31 31 100.0


line stmt bran cond sub pod time code
1             package Text::Undiacritic;
2              
3 2     2   62687 use strict;
  2         4  
  2         69  
4 2     2   11 use warnings;
  2         5  
  2         157  
5             our $VERSION = '0.05';
6              
7             require Exporter;
8             our @ISA = qw(Exporter); ## no critic
9             our @EXPORT_OK = qw(undiacritic);
10              
11 2     2   950 use charnames ':full';
  2         49790  
  2         15  
12 2     2   2212 use Unicode::Normalize qw(decompose);
  2         5456  
  2         453  
13              
14             sub undiacritic {
15 11     11 1 661 my $characters = shift;
16              
17 11 100       22 if ( !$characters ) { return $characters; }
  3         11  
18              
19 8         15 my $undiacritics = q{};
20              
21 8         53 $characters = decompose($characters);
22 8         32 $characters =~ s/\p{NonspacingMark}//gxms;
23              
24 8         24 for my $character ( split //xms, $characters ) {
25              
26 12         320 my $name = charnames::viacode( ord $character );
27 12         486 $name =~ s/\s WITH \s .+ \z//xms;
28 12         27 $undiacritics .= chr charnames::vianame( $name );
29              
30             }
31              
32 8         556 return $undiacritics;
33             }
34              
35             1;
36              
37             __END__