line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Encode::IBM::835SOSI::TSGH; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
4
|
1
|
|
|
1
|
|
6
|
use vars qw($VERSION); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
48
|
|
5
|
|
|
|
|
|
|
$VERSION = '1.01'; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
5
|
use Encode (); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
17
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
5
|
use base qw(Encode::Encoding); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
636
|
|
10
|
|
|
|
|
|
|
__PACKAGE__->Define('ibm-835-sosi-tsgh'); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $base37; |
13
|
|
|
|
|
|
|
my $base835; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub decode |
16
|
|
|
|
|
|
|
{ |
17
|
0
|
|
|
0
|
1
|
|
my ($obj,$str,$chk) = @_; |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
0
|
|
|
|
$base37 ||= Encode::find_encoding('cp37'); |
20
|
0
|
|
0
|
|
|
|
$base835 ||= Encode::find_encoding('ibm-835'); |
21
|
|
|
|
|
|
|
#$str =~ s/\x00/K/g; |
22
|
0
|
|
|
|
|
|
$str =~ s/\x00/\x40/g; |
23
|
0
|
|
|
|
|
|
$str =~ s/\x30\xe1/Fg/g; # MAKE SMALL |
24
|
0
|
|
|
|
|
|
$str =~ s/\x30\xe0//g; # MAKE LARGE |
25
|
|
|
|
|
|
|
#$str =~ s/\x30\xe0/Mh/g; |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
my $out; |
28
|
0
|
|
|
|
|
|
foreach my $chunk (split(/\x28([^\x29]*\x29)/, $str)) { |
29
|
0
|
0
|
|
|
|
|
if ($chunk =~ /\x29\z/) { |
30
|
0
|
|
|
|
|
|
chop $chunk; |
31
|
0
|
|
|
|
|
|
$chunk =~ s/\@\@/iJ/g; |
32
|
0
|
|
|
|
|
|
$out .= $base835->decode($chunk); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
else { |
35
|
0
|
|
|
|
|
|
$out .= $base37->decode($chunk); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
0
|
|
|
|
|
|
return $out; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub encode |
42
|
|
|
|
|
|
|
{ |
43
|
0
|
|
|
0
|
1
|
|
my ($obj,$str,$chk) = @_; |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
0
|
|
|
|
$base37 ||= Encode::find_encoding('cp37'); |
46
|
0
|
|
0
|
|
|
|
$base835 ||= Encode::find_encoding('ibm-835'); |
47
|
|
|
|
|
|
|
|
48
|
0
|
0
|
|
|
|
|
if ($str =~ s/^([\x00-\xff]+)//) { |
|
|
0
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# english |
50
|
0
|
|
|
|
|
|
my $sub = $1; |
51
|
0
|
|
|
|
|
|
return $base37->encode($sub) . $obj->encode($str, $chk); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
elsif ($str =~ s/^([^\x00-\xff]+)//) { |
54
|
|
|
|
|
|
|
# chinese - shift in + shift out |
55
|
0
|
|
|
|
|
|
my $sub = $1; |
56
|
0
|
|
|
|
|
|
return "\x28".$base835->encode($sub)."\x29".$obj->encode($str, $chk); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |
61
|
|
|
|
|
|
|
__END__ |