| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#!perl |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package App::unichar; |
|
4
|
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
620
|
use 5.026; |
|
|
1
|
|
|
|
|
3
|
|
|
6
|
1
|
|
|
1
|
|
537
|
use utf8; |
|
|
1
|
|
|
|
|
11
|
|
|
|
1
|
|
|
|
|
4
|
|
|
7
|
1
|
|
|
1
|
|
26
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
25
|
|
|
8
|
1
|
|
|
1
|
|
497
|
use open qw(:std :utf8); |
|
|
1
|
|
|
|
|
1022
|
|
|
|
1
|
|
|
|
|
4
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.013'; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=encoding utf8 |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=pod |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 NAME |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
App::unichar - get info about a character |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Call it as a program with a name, character, or hex code number: |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
% perl lib/App/unichar.pm 'CHECK MARK' |
|
25
|
|
|
|
|
|
|
Processing CHECK MARK |
|
26
|
|
|
|
|
|
|
match type name |
|
27
|
|
|
|
|
|
|
code point U+2713 |
|
28
|
|
|
|
|
|
|
decimal 10003 |
|
29
|
|
|
|
|
|
|
name CHECK MARK |
|
30
|
|
|
|
|
|
|
character ✓ |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
% perl lib/App/unichar.pm ✓ |
|
33
|
|
|
|
|
|
|
Processing CHECK MARK |
|
34
|
|
|
|
|
|
|
match type grapheme |
|
35
|
|
|
|
|
|
|
code point U+2713 |
|
36
|
|
|
|
|
|
|
decimal 10003 |
|
37
|
|
|
|
|
|
|
name CHECK MARK |
|
38
|
|
|
|
|
|
|
character ✓ |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
% perl lib/App/unichar.pm 0x2713 |
|
41
|
|
|
|
|
|
|
Processing 0x2713 |
|
42
|
|
|
|
|
|
|
match type code point |
|
43
|
|
|
|
|
|
|
code point U+2713 |
|
44
|
|
|
|
|
|
|
decimal 10003 |
|
45
|
|
|
|
|
|
|
name CHECK MARK |
|
46
|
|
|
|
|
|
|
character ✓ |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
I use this as a little command-line program to quickly convert between |
|
51
|
|
|
|
|
|
|
values of characters. |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 AUTHOR |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
brian d foy, C. |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 SOURCE AVAILABILITY |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
This module is in Github: |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
https://github.com/briandfoy/unichar |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Copyright 2011-2021 brian d foy |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
This module is licensed under the Artistic License 2.0. |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=cut |
|
70
|
|
|
|
|
|
|
|
|
71
|
1
|
|
|
1
|
|
628
|
use Encode qw(decode); |
|
|
1
|
|
|
|
|
8850
|
|
|
|
1
|
|
|
|
|
61
|
|
|
72
|
1
|
|
|
1
|
|
435
|
use I18N::Langinfo qw(langinfo CODESET); |
|
|
1
|
|
|
|
|
511
|
|
|
|
1
|
|
|
|
|
62
|
|
|
73
|
|
|
|
|
|
|
|
|
74
|
1
|
|
|
1
|
|
557
|
use charnames (); |
|
|
1
|
|
|
|
|
26010
|
|
|
|
1
|
|
|
|
|
25
|
|
|
75
|
1
|
|
|
1
|
|
7
|
use List::Util; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
384
|
|
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
binmode STDOUT, ':utf8'; |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
my %r = ( |
|
80
|
|
|
|
|
|
|
u => qr/(?:U\+?(?[0-9A-F]+))/i, |
|
81
|
|
|
|
|
|
|
h => qr/(?:0x(?[0-9A-F]+))/i, |
|
82
|
|
|
|
|
|
|
d => qr/(?:(?[0-9]+))/, |
|
83
|
|
|
|
|
|
|
); |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
my %transformation = ( |
|
86
|
|
|
|
|
|
|
'hex' => sub { hex $_[0] }, |
|
87
|
|
|
|
|
|
|
'int' => sub { $_[0] }, |
|
88
|
|
|
|
|
|
|
); |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
my $codeset = langinfo(CODESET); |
|
91
|
|
|
|
|
|
|
@ARGV = map { decode $codeset, $_ } @ARGV; |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
run( @ARGV ) unless caller; |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub run { |
|
96
|
0
|
|
|
0
|
0
|
|
foreach ( @ARGV ) { |
|
97
|
0
|
|
|
|
|
|
my $fallthrough = 1; |
|
98
|
0
|
|
|
|
|
|
say "Processing $_"; |
|
99
|
0
|
|
|
|
|
|
my( $code, $match ); |
|
100
|
|
|
|
|
|
|
|
|
101
|
0
|
0
|
|
|
|
|
if( / \A (?: $r{u} | $r{h} | $r{d} ) \z /x ) { |
|
102
|
0
|
|
|
|
|
|
$match = 'code point'; |
|
103
|
1
|
|
|
1
|
|
448
|
my( $key ) = keys %+; |
|
|
1
|
|
|
|
|
396
|
|
|
|
1
|
|
|
|
|
312
|
|
|
|
0
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
$code = $transformation{$key}( $+{$key} ); |
|
105
|
0
|
|
|
|
|
|
$fallthrough = 0; |
|
106
|
|
|
|
|
|
|
} |
|
107
|
0
|
0
|
|
|
|
|
if( / \A ([A-Z\s]{2,}) \z /ix ) { |
|
108
|
0
|
|
|
|
|
|
$match = 'name'; |
|
109
|
0
|
|
|
|
|
|
$code = eval { charnames::vianame( uc($1) ) }; |
|
|
0
|
|
|
|
|
|
|
|
110
|
0
|
0
|
|
|
|
|
unless( defined $code ) { |
|
111
|
0
|
|
|
|
|
|
say "\tCouldn't match <$1> to a code name"; |
|
112
|
0
|
|
|
|
|
|
next; |
|
113
|
|
|
|
|
|
|
} |
|
114
|
0
|
|
|
|
|
|
$fallthrough = 0; |
|
115
|
|
|
|
|
|
|
} |
|
116
|
0
|
0
|
|
|
|
|
if( / \A (\X) \z /x ) { |
|
117
|
0
|
|
|
|
|
|
$match = 'grapheme'; |
|
118
|
0
|
|
|
|
|
|
$code = ord( $1 ); |
|
119
|
0
|
|
|
|
|
|
$fallthrough = 0; |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
|
|
122
|
0
|
0
|
|
|
|
|
if( $fallthrough ) { |
|
123
|
0
|
0
|
|
|
|
|
unless( $code ) { |
|
124
|
0
|
|
|
|
|
|
say "\tInvalid character or codepoint --> $_\n"; |
|
125
|
|
|
|
|
|
|
} |
|
126
|
0
|
|
|
|
|
|
next; |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
|
my $hex = sprintf 'U+%04X', $code; |
|
130
|
0
|
|
|
|
|
|
my $char = chr( $code ); |
|
131
|
0
|
0
|
|
|
|
|
$char = '' if $char !~ /\p{Print}/; |
|
132
|
0
|
0
|
|
|
|
|
$char = '' if $char =~ /\p{Space}/; |
|
133
|
0
|
0
|
|
|
|
|
$char = '' if $char =~ /\p{Control}/; |
|
134
|
|
|
|
|
|
|
|
|
135
|
0
|
|
0
|
|
|
|
my $name = charnames::viacode( $code ) // ''; |
|
136
|
|
|
|
|
|
|
|
|
137
|
0
|
|
|
|
|
|
print <<~"HERE"; |
|
138
|
|
|
|
|
|
|
match type $match |
|
139
|
|
|
|
|
|
|
code point $hex |
|
140
|
|
|
|
|
|
|
decimal $code |
|
141
|
|
|
|
|
|
|
name $name |
|
142
|
|
|
|
|
|
|
character $char |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
HERE |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
} |
|
147
|
|
|
|
|
|
|
} |
|
148
|
|
|
|
|
|
|
|