| 1 | package Text::Undiacritic; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 2 | our $VERSION = '0.07'; | |||||||||
| 6 | |||||||||||
| 7 | 2 | require Exporter; | |||||||||
| 8 | 2 | our @ISA = qw(Exporter); ## no critic | |||||||||
| 9 | 2 | our @EXPORT_OK = qw(undiacritic); | |||||||||
| 10 | |||||||||||
| 11 | 2 | ▶ | use charnames ':full'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 2 | ▶ | use Unicode::Normalize qw(decompose); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 11 | ▶ | sub undiacritic { | ||||||||
|
Subroutine
undiacritic: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 15 | 11 | my $characters = shift; | |||||||||
| 16 | |||||||||||
| 17 | 11 | ▶ | if ( !$characters ) { return $characters; } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 18 | |||||||||||
| 19 | 8 | $characters = decompose($characters); | |||||||||
| 20 | 8 | $characters =~ s/\p{NonspacingMark}//gxms; | |||||||||
| 21 | |||||||||||
| 22 | return join('', | ||||||||||
| 23 | map { | ||||||||||
| 24 | 8 | (ord($_) > 127) | |||||||||
| 25 | 12 | ▶ | ? do { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | 1 | my $charname = charnames::viacode(ord $_); | |||||||||
| 27 | 1 | $charname =~ s/\s WITH \s .+ \z//x; | |||||||||
| 28 | #charnames::string_vianame($charname); | ||||||||||
| 29 | 1 | chr charnames::vianame($charname); | |||||||||
| 30 | } | ||||||||||
| 31 | : $_; | ||||||||||
| 32 | } | ||||||||||
| 33 | split //, $characters | ||||||||||
| 34 | ); | ||||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | 2 | 1; | |||||||||
| 38 | |||||||||||
| 39 | __END__ | ||||||||||