| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Unicode::Char; |
|
2
|
4
|
|
|
4
|
|
236335
|
use 5.008001; |
|
|
4
|
|
|
|
|
34
|
|
|
3
|
4
|
|
|
4
|
|
16
|
use strict; |
|
|
4
|
|
|
|
|
4
|
|
|
|
4
|
|
|
|
|
92
|
|
|
4
|
4
|
|
|
4
|
|
16
|
use warnings; |
|
|
4
|
|
|
|
|
16
|
|
|
|
4
|
|
|
|
|
110
|
|
|
5
|
4
|
|
|
4
|
|
17
|
use Carp; |
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
228
|
|
|
6
|
4
|
|
|
4
|
|
1857
|
use charnames ':loose'; |
|
|
4
|
|
|
|
|
107246
|
|
|
|
4
|
|
|
|
|
24
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = sprintf "%d.%02d", q$Revision: 0.03 $ =~ /(\d+)/g; |
|
9
|
|
|
|
|
|
|
our $DEBUG = 0; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our %Name2Chr; |
|
12
|
|
|
|
|
|
|
our %Chr2Name; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
|
15
|
12
|
|
|
12
|
0
|
234
|
my $pkg = shift; |
|
16
|
12
|
|
|
|
|
20
|
return bless \eval { my $scalar }, $pkg; |
|
|
12
|
|
|
|
|
45
|
|
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub valid($$) { |
|
20
|
14
|
|
|
14
|
0
|
33
|
my ( $self, $ord ) = @_; |
|
21
|
14
|
100
|
|
|
|
34
|
return 0 if $ord < 0; |
|
22
|
13
|
100
|
|
|
|
30
|
return 1 if $ord < 0xDC00; # BMP before surrogates |
|
23
|
8
|
100
|
|
|
|
27
|
return 0 if $ord <= 0xDFFF; # surrogates |
|
24
|
6
|
100
|
|
|
|
21
|
return 1 if $ord < 0xFFFF; # BMP after surrogates |
|
25
|
4
|
100
|
|
|
|
12
|
return 0 if $ord == 0xFFFF; # U+FFFF is invalid |
|
26
|
3
|
100
|
|
|
|
11
|
return 1 if $ord <= 0x10FFFF; # and to the max; |
|
27
|
1
|
|
|
|
|
3
|
return 0; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub names($$) { |
|
31
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $str ) = @_; |
|
32
|
0
|
|
|
|
|
0
|
return map { $self->name($_) } split q() => $str; |
|
|
0
|
|
|
|
|
0
|
|
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub name($$) { |
|
36
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $char ) = @_; |
|
37
|
0
|
|
|
|
|
0
|
return charnames::viacode( ord $char ); |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub u($$) { |
|
41
|
4
|
|
|
4
|
1
|
7
|
my ( $self, $hex ) = @_; |
|
42
|
4
|
|
|
|
|
9
|
my $ord = hex($hex); |
|
43
|
4
|
50
|
|
|
|
15
|
croak "$ord is invalid" unless $self->valid($ord); |
|
44
|
4
|
|
|
|
|
13
|
return chr($ord); |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub n($$) { |
|
48
|
5
|
|
|
5
|
1
|
11
|
my ( $self, $name ) = @_; |
|
49
|
5
|
|
|
|
|
11
|
my $char = $Name2Chr{$name}; |
|
50
|
|
|
|
|
|
|
return $char |
|
51
|
|
|
|
|
|
|
? $char |
|
52
|
5
|
50
|
|
|
|
195
|
: $Name2Chr{$name} = eval qq("\\N{$name}"); |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
0
|
|
|
sub DESTROY { } # so AUTOLOAD will not handle this |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub AUTOLOAD { |
|
58
|
9
|
|
|
9
|
|
35
|
my $method = our $AUTOLOAD; |
|
59
|
9
|
50
|
|
|
|
32
|
$DEBUG and carp $method; |
|
60
|
9
|
|
|
|
|
49
|
$method =~ s/.*:://o; |
|
61
|
9
|
100
|
|
|
|
32
|
if ( $method =~ s/^u_?//o ) { |
|
62
|
4
|
|
|
|
|
10
|
my $chr = __PACKAGE__->new()->u($method); |
|
63
|
4
|
50
|
|
|
|
11
|
defined $chr or croak "U$method is invalid!"; |
|
64
|
4
|
|
|
4
|
|
2553
|
no strict 'refs'; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
394
|
|
|
65
|
4
|
|
|
4
|
|
14
|
*{$AUTOLOAD} = sub { $chr }; |
|
|
4
|
|
|
|
|
12
|
|
|
|
4
|
|
|
|
|
14
|
|
|
66
|
4
|
|
|
|
|
15
|
goto &$AUTOLOAD; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
else { |
|
69
|
5
|
|
|
|
|
14
|
my $chr = __PACKAGE__->new()->n($method); |
|
70
|
5
|
50
|
|
|
|
22
|
defined $chr or croak qq(There is no character named "$method"); |
|
71
|
4
|
|
|
4
|
|
21
|
no strict 'refs'; |
|
|
4
|
|
|
|
|
5
|
|
|
|
4
|
|
|
|
|
410
|
|
|
72
|
5
|
|
|
5
|
|
22
|
*{$AUTOLOAD} = sub { $chr }; |
|
|
5
|
|
|
|
|
19
|
|
|
|
5
|
|
|
|
|
23
|
|
|
73
|
5
|
|
|
|
|
18
|
goto &$AUTOLOAD; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
|
78
|
|
|
|
|
|
|
__END__ |