line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package mb::Encode; |
2
|
|
|
|
|
|
|
###################################################################### |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# mb::Encode - provides MBCS encoder and decoder |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# https://metacpan.org/release/mb-Encode |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# Copyright (c) 2021 INABA Hitoshi in a CPAN |
9
|
|
|
|
|
|
|
###################################################################### |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# use 5.00503; # Universal Consensus 1998 for primetools |
12
|
2
|
|
|
2
|
|
7360
|
use 5.008001; # Lancaster Consensus 2013 for toolchains |
|
2
|
|
|
|
|
13
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
$VERSION = '0.01'; |
15
|
|
|
|
|
|
|
$VERSION = $VERSION; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
require Exporter; |
18
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
19
|
|
|
|
|
|
|
@EXPORT = qw(); |
20
|
|
|
|
|
|
|
@EXPORT_OK = qw( |
21
|
|
|
|
|
|
|
to_big5 big5 by_big5 |
22
|
|
|
|
|
|
|
to_big5hkscs big5hkscs by_big5hkscs |
23
|
|
|
|
|
|
|
to_cp932 cp932 by_cp932 |
24
|
|
|
|
|
|
|
to_cp936 cp936 by_cp936 |
25
|
|
|
|
|
|
|
to_cp949 cp949 by_cp949 |
26
|
|
|
|
|
|
|
to_cp950 cp950 by_cp950 |
27
|
|
|
|
|
|
|
to_eucjp eucjp by_eucjp |
28
|
|
|
|
|
|
|
to_gbk gbk by_gbk |
29
|
|
|
|
|
|
|
to_sjis sjis by_sjis |
30
|
|
|
|
|
|
|
to_uhc uhc by_uhc |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
2
|
|
|
2
|
|
23
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
55
|
|
34
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
61
|
|
35
|
2
|
|
|
2
|
|
1187
|
use Encode qw(); |
|
2
|
|
|
|
|
21284
|
|
|
2
|
|
|
|
|
1735
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
#------------------------------------------------------------------------------------- |
38
|
|
|
|
|
|
|
# return octets to any encoding |
39
|
2
|
|
|
2
|
0
|
316
|
sub to_big5 ($) { Encode::from_to(my $oct=$_[0], 'utf8', 'big5', ); $oct } |
|
2
|
|
|
|
|
6995
|
|
40
|
2
|
|
|
2
|
0
|
146
|
sub to_big5hkscs ($) { Encode::from_to(my $oct=$_[0], 'utf8', 'big5-hkscs',); $oct } |
|
2
|
|
|
|
|
119
|
|
41
|
2
|
|
|
2
|
0
|
64
|
sub to_cp932 ($) { Encode::from_to(my $oct=$_[0], 'utf8', 'cp932', ); $oct } |
|
2
|
|
|
|
|
15695
|
|
42
|
2
|
|
|
2
|
0
|
148
|
sub to_cp936 ($) { Encode::from_to(my $oct=$_[0], 'utf8', 'cp936', ); $oct } |
|
2
|
|
|
|
|
21921
|
|
43
|
2
|
|
|
2
|
0
|
156
|
sub to_cp949 ($) { Encode::from_to(my $oct=$_[0], 'utf8', 'cp949', ); $oct } |
|
2
|
|
|
|
|
20233
|
|
44
|
2
|
|
|
2
|
0
|
160
|
sub to_cp950 ($) { Encode::from_to(my $oct=$_[0], 'utf8', 'cp950', ); $oct } |
|
2
|
|
|
|
|
121
|
|
45
|
2
|
|
|
2
|
0
|
69
|
sub to_eucjp ($) { Encode::from_to(my $oct=$_[0], 'utf8', 'euc-jp', ); $oct } |
|
2
|
|
|
|
|
97
|
|
46
|
2
|
|
|
2
|
0
|
59
|
sub to_gbk ($) { Encode::from_to(my $oct=$_[0], 'utf8', 'gbk', ); $oct } |
|
2
|
|
|
|
|
735
|
|
47
|
2
|
|
|
2
|
0
|
129
|
sub to_sjis ($) { Encode::from_to(my $oct=$_[0], 'utf8', 'sjis', ); $oct } |
|
2
|
|
|
|
|
593
|
|
48
|
2
|
|
|
2
|
0
|
146
|
sub to_uhc ($) { Encode::from_to(my $oct=$_[0], 'utf8', 'uhc', ); $oct } |
|
2
|
|
|
|
|
517
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
#------------------------------------------------------------------------------------- |
51
|
|
|
|
|
|
|
# shorthand of mb::to_XXXX |
52
|
2
|
|
|
2
|
0
|
122
|
sub big5 ($) { Encode::from_to(my $oct=$_[0], 'utf8', 'big5', ); $oct } |
|
2
|
|
|
|
|
128
|
|
53
|
2
|
|
|
2
|
0
|
62
|
sub big5hkscs ($) { Encode::from_to(my $oct=$_[0], 'utf8', 'big5-hkscs',); $oct } |
|
2
|
|
|
|
|
93
|
|
54
|
2
|
|
|
2
|
0
|
58
|
sub cp932 ($) { Encode::from_to(my $oct=$_[0], 'utf8', 'cp932', ); $oct } |
|
2
|
|
|
|
|
92
|
|
55
|
2
|
|
|
2
|
0
|
56
|
sub cp936 ($) { Encode::from_to(my $oct=$_[0], 'utf8', 'cp936', ); $oct } |
|
2
|
|
|
|
|
109
|
|
56
|
2
|
|
|
2
|
0
|
58
|
sub cp949 ($) { Encode::from_to(my $oct=$_[0], 'utf8', 'cp949', ); $oct } |
|
2
|
|
|
|
|
91
|
|
57
|
2
|
|
|
2
|
0
|
57
|
sub cp950 ($) { Encode::from_to(my $oct=$_[0], 'utf8', 'cp950', ); $oct } |
|
2
|
|
|
|
|
108
|
|
58
|
2
|
|
|
2
|
0
|
58
|
sub eucjp ($) { Encode::from_to(my $oct=$_[0], 'utf8', 'euc-jp', ); $oct } |
|
2
|
|
|
|
|
91
|
|
59
|
2
|
|
|
2
|
0
|
89
|
sub gbk ($) { Encode::from_to(my $oct=$_[0], 'utf8', 'gbk', ); $oct } |
|
2
|
|
|
|
|
121
|
|
60
|
2
|
|
|
2
|
0
|
57
|
sub sjis ($) { Encode::from_to(my $oct=$_[0], 'utf8', 'sjis', ); $oct } |
|
2
|
|
|
|
|
115
|
|
61
|
2
|
|
|
2
|
0
|
55
|
sub uhc ($) { Encode::from_to(my $oct=$_[0], 'utf8', 'uhc', ); $oct } |
|
2
|
|
|
|
|
179
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
#------------------------------------------------------------------------------------- |
64
|
|
|
|
|
|
|
# return octets from any encoding |
65
|
2
|
|
|
2
|
0
|
60
|
sub by_big5 ($) { Encode::from_to(my $oct=$_[0], 'big5', 'utf8',); $oct } |
|
2
|
|
|
|
|
115
|
|
66
|
2
|
|
|
2
|
0
|
81
|
sub by_big5hkscs ($) { Encode::from_to(my $oct=$_[0], 'big5-hkscs', 'utf8',); $oct } |
|
2
|
|
|
|
|
86
|
|
67
|
2
|
|
|
2
|
0
|
56
|
sub by_cp932 ($) { Encode::from_to(my $oct=$_[0], 'cp932', 'utf8',); $oct } |
|
2
|
|
|
|
|
83
|
|
68
|
2
|
|
|
2
|
0
|
55
|
sub by_cp936 ($) { Encode::from_to(my $oct=$_[0], 'cp936', 'utf8',); $oct } |
|
2
|
|
|
|
|
82
|
|
69
|
2
|
|
|
2
|
0
|
55
|
sub by_cp949 ($) { Encode::from_to(my $oct=$_[0], 'cp949', 'utf8',); $oct } |
|
2
|
|
|
|
|
94
|
|
70
|
2
|
|
|
2
|
0
|
54
|
sub by_cp950 ($) { Encode::from_to(my $oct=$_[0], 'cp950', 'utf8',); $oct } |
|
2
|
|
|
|
|
99
|
|
71
|
2
|
|
|
2
|
0
|
55
|
sub by_eucjp ($) { Encode::from_to(my $oct=$_[0], 'euc-jp', 'utf8',); $oct } |
|
2
|
|
|
|
|
83
|
|
72
|
2
|
|
|
2
|
0
|
51
|
sub by_gbk ($) { Encode::from_to(my $oct=$_[0], 'gbk', 'utf8',); $oct } |
|
2
|
|
|
|
|
108
|
|
73
|
2
|
|
|
2
|
0
|
52
|
sub by_sjis ($) { Encode::from_to(my $oct=$_[0], 'sjis', 'utf8',); $oct } |
|
2
|
|
|
|
|
106
|
|
74
|
2
|
|
|
2
|
0
|
55
|
sub by_uhc ($) { Encode::from_to(my $oct=$_[0], 'uhc', 'utf8',); $oct } |
|
2
|
|
|
|
|
106
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
__END__ |