| line | stmt | bran | cond | sub | pod | time | code | 
| 1 | 1 |  |  | 1 |  | 971 | use strict; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 26 |  | 
| 2 | 1 |  |  | 1 |  | 4 | use warnings; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 41 |  | 
| 3 |  |  |  |  |  |  | package App::FilterUtils::NFD; | 
| 4 |  |  |  |  |  |  | # ABSTRACT: Convert to Unicode Normalization Form Canonical Decomposition | 
| 5 |  |  |  |  |  |  | our $VERSION = '0.001'; # VERSION | 
| 6 | 1 |  |  | 1 |  | 4 | use base 'App::Cmd::Simple'; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 82 |  | 
| 7 | 1 |  |  | 1 |  | 5 | use utf8; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 4 |  | 
| 8 | 1 |  |  | 1 |  | 22 | use charnames qw(); | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 15 |  | 
| 9 | 1 |  |  | 1 |  | 3 | use open qw( :encoding(UTF-8) :std ); | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 4 |  | 
| 10 | 1 |  |  | 1 |  | 220 | use Module::Load qw(load); | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 4 |  | 
| 11 | 1 |  |  | 1 |  | 52 | use Getopt::Long::Descriptive; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 4 |  | 
| 12 |  |  |  |  |  |  |  | 
| 13 | 1 |  |  | 1 |  | 354 | use utf8; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 6 |  | 
| 14 | 1 |  |  | 1 |  | 33 | use Unicode::Normalize; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 461 |  | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | =pod | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  | =encoding utf8 | 
| 19 |  |  |  |  |  |  |  | 
| 20 |  |  |  |  |  |  | =head1 NAME | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | NFD - Convert to Unicode Normalization Form Canonical Decomposition | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | $ NFD é | xxd | 
| 27 |  |  |  |  |  |  | 00000000: 65cc 810a                                e... | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | =head1 OPTIONS | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | =head2 version / v | 
| 32 |  |  |  |  |  |  |  | 
| 33 |  |  |  |  |  |  | Shows the current version number | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | $ NFD --version | 
| 36 |  |  |  |  |  |  |  | 
| 37 |  |  |  |  |  |  | =head2 help / h | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | Shows a brief help message | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | $ NFD --help | 
| 42 |  |  |  |  |  |  |  | 
| 43 |  |  |  |  |  |  | =cut | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  | sub opt_spec { | 
| 46 |  |  |  |  |  |  | return ( | 
| 47 | 0 |  |  | 0 | 1 |  | [ 'version|v'    => "show version number"                               ], | 
| 48 |  |  |  |  |  |  | [ 'help|h'       => "display a usage message"                           ], | 
| 49 |  |  |  |  |  |  | ); | 
| 50 |  |  |  |  |  |  | } | 
| 51 |  |  |  |  |  |  |  | 
| 52 |  |  |  |  |  |  | sub validate_args { | 
| 53 | 0 |  |  | 0 | 1 |  | my ($self, $opt, $args) = @_; | 
| 54 |  |  |  |  |  |  |  | 
| 55 | 0 | 0 |  |  |  |  | if ($opt->{'help'}) { | 
|  |  | 0 |  |  |  |  |  | 
| 56 | 0 |  |  |  |  |  | my ($opt, $usage) = describe_options( | 
| 57 |  |  |  |  |  |  | $self->usage_desc(), | 
| 58 |  |  |  |  |  |  | $self->opt_spec(), | 
| 59 |  |  |  |  |  |  | ); | 
| 60 | 0 |  |  |  |  |  | print $usage; | 
| 61 | 0 |  |  |  |  |  | print "\n"; | 
| 62 | 0 |  |  |  |  |  | print "For more detailed help see 'perldoc App::FilterUtils::NFD'\n"; | 
| 63 |  |  |  |  |  |  |  | 
| 64 | 0 |  |  |  |  |  | print "\n"; | 
| 65 | 0 |  |  |  |  |  | exit; | 
| 66 |  |  |  |  |  |  | } | 
| 67 |  |  |  |  |  |  | elsif ($opt->{'version'}) { | 
| 68 | 0 |  |  |  |  |  | print $App::FilterUtils::NFD::VERSION, "\n"; | 
| 69 | 0 |  |  |  |  |  | exit; | 
| 70 |  |  |  |  |  |  | } | 
| 71 |  |  |  |  |  |  |  | 
| 72 | 0 |  |  |  |  |  | return; | 
| 73 |  |  |  |  |  |  | } | 
| 74 |  |  |  |  |  |  |  | 
| 75 |  |  |  |  |  |  | sub execute { | 
| 76 | 0 |  |  | 0 | 1 |  | my ($self, $opt, $args) = @_; | 
| 77 |  |  |  |  |  |  |  | 
| 78 | 0 | 0 |  | 0 |  |  | my $readarg = @$args ? sub { shift @$args } : sub {  }; | 
|  | 0 |  |  | 0 |  |  |  | 
|  | 0 |  |  |  |  |  |  | 
| 79 | 0 |  |  |  |  |  | chomp, print NFD($_), "\n" while defined ($_ = $readarg->()); | 
| 80 |  |  |  |  |  |  |  | 
| 81 | 0 |  |  |  |  |  | return; | 
| 82 |  |  |  |  |  |  | } | 
| 83 |  |  |  |  |  |  |  | 
| 84 |  |  |  |  |  |  | 1; | 
| 85 |  |  |  |  |  |  |  | 
| 86 |  |  |  |  |  |  | __END__ |