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