line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#-*- perl -*- |
2
|
|
|
|
|
|
|
#-*- coding: us-ascii -*- |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Encode::JISLegacy; |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
7
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
44
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
6
|
use base qw(Encode::Encoding); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
108
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
1008
|
use Encode::JP; |
|
1
|
|
|
|
|
10354
|
|
|
1
|
|
|
|
|
76
|
|
13
|
1
|
|
|
1
|
|
16
|
use XSLoader; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
880
|
|
14
|
|
|
|
|
|
|
XSLoader::load(__PACKAGE__, $VERSION); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $HTMLCREF = Encode::HTMLCREF(); |
17
|
|
|
|
|
|
|
my $PERLQQ = Encode::PERLQQ(); |
18
|
|
|
|
|
|
|
my $XMLCREF = Encode::XMLCREF(); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# JIS C 6226-1978, 1st revision of JIS X 0208. |
21
|
|
|
|
|
|
|
$Encode::Encoding{'jis-x-0208-1978'} = bless { |
22
|
|
|
|
|
|
|
Name => 'jis-x-0208-1978', |
23
|
|
|
|
|
|
|
alt => '1978', |
24
|
|
|
|
|
|
|
encoding => $Encode::Encoding{'jis0208-raw'}, |
25
|
|
|
|
|
|
|
} => __PACKAGE__; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# 26 row-cell pairs swapped between JIS C 6226-1978 and JIS X 0208-1983. |
28
|
|
|
|
|
|
|
# cf. JIS X 0208:1997 Annex 2 Table 1. |
29
|
|
|
|
|
|
|
my @swap1978 = ( |
30
|
|
|
|
|
|
|
"\x30\x33" => "\x72\x4D", "\x32\x29" => "\x72\x74", |
31
|
|
|
|
|
|
|
"\x33\x42" => "\x69\x5a", "\x33\x49" => "\x59\x78", |
32
|
|
|
|
|
|
|
"\x33\x76" => "\x63\x5e", "\x34\x43" => "\x5e\x75", |
33
|
|
|
|
|
|
|
"\x34\x52" => "\x6b\x5d", "\x37\x5b" => "\x70\x74", |
34
|
|
|
|
|
|
|
"\x39\x5c" => "\x62\x68", "\x3c\x49" => "\x69\x22", |
35
|
|
|
|
|
|
|
"\x3F\x59" => "\x70\x57", "\x41\x28" => "\x6c\x4d", |
36
|
|
|
|
|
|
|
"\x44\x5B" => "\x54\x64", "\x45\x57" => "\x62\x6a", |
37
|
|
|
|
|
|
|
"\x45\x6e" => "\x5b\x6d", "\x45\x73" => "\x5e\x39", |
38
|
|
|
|
|
|
|
"\x46\x76" => "\x6d\x6e", "\x47\x68" => "\x6a\x24", |
39
|
|
|
|
|
|
|
"\x49\x30" => "\x5B\x58", "\x4b\x79" => "\x50\x56", |
40
|
|
|
|
|
|
|
"\x4c\x79" => "\x69\x2e", "\x4F\x36" => "\x64\x46", |
41
|
|
|
|
|
|
|
"\x36\x46" => "\x74\x21", "\x4B\x6A" => "\x74\x22", |
42
|
|
|
|
|
|
|
"\x4D\x5A" => "\x74\x23", "\x60\x76" => "\x74\x24", |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
my %swap1978 = (@swap1978, reverse @swap1978); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub encode { |
47
|
0
|
|
|
0
|
1
|
|
my ($self, $utf8, $chk) = @_; |
48
|
|
|
|
|
|
|
|
49
|
0
|
0
|
|
|
|
|
if (not ref $chk) { |
50
|
0
|
|
|
|
|
|
$chk &= ~($PERLQQ | $HTMLCREF | $XMLCREF); |
51
|
|
|
|
|
|
|
} |
52
|
0
|
|
|
|
|
|
my $str; |
53
|
0
|
0
|
|
|
|
|
if ($self->{alt} eq '1978') { |
54
|
0
|
|
|
|
|
|
$str = $self->{encoding}->encode($utf8, $chk); |
55
|
0
|
0
|
|
|
|
|
$str =~ s{([\x21-\x7E]{2})}{$swap1978{$1} || $1}eg; |
|
0
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
} else { |
57
|
0
|
|
|
|
|
|
$str = $self->{encoding}->encode($utf8, $chk); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
$_[1] = $utf8; |
61
|
0
|
|
|
|
|
|
return $str; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub decode { |
65
|
0
|
|
|
0
|
1
|
|
my ($self, $str, $chk) = @_; |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
my $utf8; |
68
|
0
|
0
|
|
|
|
|
if ($self->{alt} eq '1978') { |
69
|
0
|
0
|
|
|
|
|
$str =~ s{([\x21-\x7E]{2})}{$swap1978{$1} || $1}eg; |
|
0
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
$utf8 = $self->{encoding}->decode($str, $chk); |
71
|
0
|
0
|
|
|
|
|
$str =~ s{([\x21-\x7E]{2})}{$swap1978{$1} || $1}eg; |
|
0
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
} else { |
73
|
0
|
|
|
|
|
|
$utf8 = $self->{encoding}->decode($str, $chk); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
$_[1] = $str; |
77
|
0
|
|
|
|
|
|
return $utf8; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
0
|
1
|
|
sub perlio_ok { 0 } |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
__END__ |