line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Convert::EastAsianWidth; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
2044473
|
use 5.008; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
77
|
|
4
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
72
|
|
5
|
2
|
|
|
2
|
|
11
|
use Exporter; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
499
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '1.02'; |
8
|
|
|
|
|
|
|
our @ISA = 'Exporter'; |
9
|
|
|
|
|
|
|
our @EXPORT = qw(to_fullwidth to_halfwidth); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub to_fullwidth { |
12
|
2
|
|
|
2
|
0
|
1427
|
my $text; |
13
|
2
|
|
|
|
|
6
|
my $enc = $_[1]; |
14
|
|
|
|
|
|
|
|
15
|
2
|
100
|
|
|
|
7
|
if ($enc) { |
16
|
1
|
|
|
|
|
32
|
require Encode; |
17
|
1
|
|
|
|
|
10
|
$text = Encode::decode($enc => $_[0]); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
else { |
20
|
1
|
|
|
|
|
2
|
$text = $_[0]; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
2
|
|
|
2
|
|
11
|
$text =~ tr/ -~/\x{3000}\x{FF01}-\x{FF5E}/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
30
|
|
|
2
|
|
|
|
|
5292
|
|
24
|
|
|
|
|
|
|
|
25
|
2
|
100
|
|
|
|
16
|
return ( $enc ? Encode::encode($enc => $text) : $text ); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub to_halfwidth { |
29
|
2
|
|
|
2
|
0
|
695
|
my $text; |
30
|
2
|
|
|
|
|
5
|
my $enc = $_[1]; |
31
|
|
|
|
|
|
|
|
32
|
2
|
100
|
|
|
|
7
|
if ($enc) { |
33
|
1
|
|
|
|
|
10
|
require Encode; |
34
|
1
|
|
|
|
|
6
|
$text = Encode::decode($enc => $_[0]); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
else { |
37
|
1
|
|
|
|
|
2
|
$text = $_[0]; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
2
|
|
|
|
|
61
|
$text =~ tr/\x{3000}\x{FF01}-\x{FF5E}/ -~/; |
41
|
|
|
|
|
|
|
|
42
|
2
|
100
|
|
|
|
11
|
return ( $enc ? Encode::encode($enc => $text) : $text ); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__END__ |