App-FilterUtils
view release on metacpan or search on metacpan
lib/App/FilterUtils/2u.pm view on Meta::CPAN
use strict;
use warnings;
package App::FilterUtils::2u;
# ABSTRACT: Show Unicode charnames
our $VERSION = '0.002'; # VERSION
use base 'App::Cmd::Simple';
use utf8;
use charnames qw();
use open qw( :encoding(UTF-8) :std );
use Getopt::Long::Descriptive;
use utf8;
use charnames qw();
=pod
=encoding utf8
=head1 NAME
2u - Show Unicode charnames
=head1 SYNOPSIS
$ echo ð¨âð | 2u
MAN <ð¨> 128104, Hex 1f468, Octal 372150
ZERO WIDTH JOINER <> 8205, Hex 200d, Octal 20015
GRADUATION CAP <ð> 127891, Hex 1f393, Octal 371623
$ 2u U+200e
LEFT-TO-RIGHT MARK <â> 8206, Hex 200e, Octal 20016
=head1 OPTIONS
=head2 version / v
Shows the current version number
$ 2u --version
=head2 help / h
Shows a brief help message
$ 2u --help
=cut
sub usage_desc { "2u [character ... | codepoint]" }
sub opt_spec {
return (
[ 'version|v' => "show version number" ],
[ 'help|h' => "display a usage message" ],
);
}
sub validate_args {
my ($self, $opt, $args) = @_;
if ($opt->{'help'}) {
my ($opt, $usage) = describe_options(
usage_desc(),
$self->opt_spec(),
);
print $usage;
print "\n";
print "For more detailed help see 'perldoc App::FilterUtils::2u'\n";
print "\n";
exit;
}
elsif ($opt->{'version'}) {
print $App::FilterUtils::2u::VERSION, "\n";
exit;
}
return;
}
sub execute {
my ($self, $opt, $args) = @_;
my $readarg = @$args ? sub { shift @$args } : sub { <STDIN> };
while (defined ($_ = $readarg->())) {
chomp;
$_ = chr hex $1 if /^U\+([[:xdigit:]]+)$/;
for (split '') {
$_ = ord;
printf "%s <%c> %d, Hex %x, Octal %o\n", charnames::viacode($_), ($_)x4;
}
print "\n";
}
return;
}
1;
__END__
=head1 GIT REPOSITORY
L<http://github.com/athreef/App-FilterUtils>
=head1 SEE ALSO
L<The Perl Home Page|http://www.perl.org/>
=head1 AUTHOR
Ahmad Fatoum C<< <athreef@cpan.org> >>, L<http://a3f.at>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2017 Ahmad Fatoum
This library is free software; you can redistribute it and/or modify
( run in 1.258 second using v1.01-cache-2.11-cpan-140bd7fdf52 )