line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Encode::HanConvert; |
2
|
1
|
|
|
1
|
|
1396
|
use 5.006; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
42
|
|
3
|
1
|
|
|
1
|
|
6
|
use vars qw/$VERSION @EXPORT @EXPORT_OK/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
97
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
$VERSION = '0.35'; |
6
|
|
|
|
|
|
|
@EXPORT = qw( |
7
|
|
|
|
|
|
|
big5_to_gb trad_to_simp big5_to_simp gb_to_trad big5_to_trad gb_to_simp |
8
|
|
|
|
|
|
|
gb_to_big5 simp_to_trad simp_to_big5 trad_to_gb trad_to_big5 simp_to_gb |
9
|
|
|
|
|
|
|
); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
@EXPORT_OK = qw(simple trad); |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
26
|
use base 'Exporter'; |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
1015
|
|
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
1169
|
if (eval "use Encode qw|encode decode from_to encode_utf8 decode_utf8|; 1") { |
|
1
|
|
|
|
|
12915
|
|
|
1
|
|
|
|
|
113
|
|
16
|
|
|
|
|
|
|
require XSLoader; |
17
|
|
|
|
|
|
|
eval { XSLoader::load(__PACKAGE__, $VERSION) } |
18
|
|
|
|
|
|
|
or eval {local $^W; require Encode::HanConvert::Perl; Encode::HanConvert::Perl->import; 1} |
19
|
|
|
|
|
|
|
or die "Can't load Perl-based Converter: $@"; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
else { |
22
|
|
|
|
|
|
|
eval {local $^W; require Encode::HanConvert::Perl; Encode::HanConvert::Perl->import; 1} |
23
|
|
|
|
|
|
|
or die "Can't load Perl-based Converter: $@"; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub big5_to_gb ($) { |
27
|
2
|
|
|
2
|
0
|
351
|
local $^W; # shuts Encode::HZ's redefine warnings up |
28
|
2
|
|
|
|
|
1180
|
require Encode::CN; |
29
|
|
|
|
|
|
|
|
30
|
2
|
100
|
|
|
|
8920
|
local $_[0] = $_[0] if defined wantarray; |
31
|
2
|
|
|
|
|
11
|
from_to($_[0], 'big5-simp' => 'gbk'); |
32
|
2
|
|
|
|
|
718
|
return $_[0]; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub gb_to_big5 ($) { |
36
|
2
|
|
|
2
|
0
|
2229
|
require Encode::TW; |
37
|
|
|
|
|
|
|
|
38
|
2
|
100
|
|
|
|
3132
|
local $_[0] = $_[0] if defined wantarray; |
39
|
2
|
|
|
|
|
11
|
from_to($_[0], 'gbk-trad' => 'big5'); |
40
|
2
|
|
|
|
|
712
|
return $_[0]; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub trad_to_simp ($) { |
44
|
0
|
0
|
|
0
|
0
|
|
return decode('trad-simp', encode_utf8($_[0])) |
45
|
|
|
|
|
|
|
if (defined wantarray); |
46
|
0
|
|
|
|
|
|
$_[0] = decode('trad-simp', encode_utf8($_[0])); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub simp_to_trad ($) { |
50
|
0
|
0
|
|
0
|
0
|
|
return decode('simp-trad', encode_utf8($_[0])) |
51
|
|
|
|
|
|
|
if (defined wantarray); |
52
|
0
|
|
|
|
|
|
$_[0] = decode('simp-trad', encode_utf8($_[0])); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub big5_to_simp ($) { |
56
|
0
|
0
|
|
0
|
0
|
|
return decode('big5-simp', $_[0]) if (defined wantarray); |
57
|
0
|
|
|
|
|
|
$_[0] = decode('big5-simp', $_[0]); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub simp_to_big5 ($) { |
61
|
0
|
0
|
|
0
|
0
|
|
return encode('big5-simp', $_[0]) if (defined wantarray); |
62
|
0
|
|
|
|
|
|
$_[0] = encode('big5-simp', $_[0]); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub gb_to_trad ($) { |
66
|
0
|
0
|
|
0
|
0
|
|
return decode('gbk-trad', $_[0]) if (defined wantarray); |
67
|
0
|
|
|
|
|
|
$_[0] = decode('gbk-trad', $_[0]); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub trad_to_gb ($) { |
71
|
0
|
0
|
|
0
|
0
|
|
return encode('gbk-trad', $_[0]) if (defined wantarray); |
72
|
0
|
|
|
|
|
|
$_[0] = encode('gbk-trad', $_[0]); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# For completeness' sake... |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub big5_to_trad ($) { |
78
|
0
|
|
|
0
|
0
|
|
require Encode::TW; |
79
|
0
|
0
|
|
|
|
|
return decode('big5', $_[0]) if (defined wantarray); |
80
|
0
|
|
|
|
|
|
$_[0] = decode('big5', $_[0]); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub trad_to_big5 ($) { |
84
|
0
|
|
|
0
|
0
|
|
require Encode::TW; |
85
|
0
|
0
|
|
|
|
|
return encode('big5', $_[0]) if (defined wantarray); |
86
|
0
|
|
|
|
|
|
$_[0] = encode('big5', $_[0]); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub gb_to_simp ($) { |
90
|
0
|
|
|
0
|
0
|
|
local $^W; |
91
|
0
|
|
|
|
|
|
require Encode::CN; |
92
|
0
|
0
|
|
|
|
|
return decode('gbk', $_[0]) if (defined wantarray); |
93
|
0
|
|
|
|
|
|
$_[0] = decode('gbk', $_[0]); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub simp_to_gb ($) { |
97
|
0
|
|
|
0
|
0
|
|
local $^W; |
98
|
0
|
|
|
|
|
|
require Encode::CN; |
99
|
0
|
0
|
|
|
|
|
return encode('gbk', $_[0]) if (defined wantarray); |
100
|
0
|
|
|
|
|
|
$_[0] = encode('gbk', $_[0]); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# Lingua::ZH::HanConvert drop-in replacement -- not exported by default |
104
|
|
|
|
|
|
|
|
105
|
0
|
|
|
0
|
0
|
|
sub trad { simp_to_trad($_[0]) }; |
106
|
0
|
|
|
0
|
0
|
|
sub simple { trad_to_simp($_[0]) }; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
1; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
__END__ |