This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
d8c8fb743aaea882c62c32eee888be97cadb4d8e
[perl5.git] / ext / Encode / lib / Encode / JP / ISO_2022_JP.pm
1 package Encode::JP::ISO_2022_JP;
2 use Encode::JP;
3 use Encode::JP::JIS;
4 use Encode::JP::H2Z;
5 use base 'Encode::Encoding';
6
7
8 my $canon = 'iso-2022-jp';
9 my $obj = bless {name => $canon}, __PACKAGE__;
10 $obj->Define($canon);
11
12 #
13 # decode is identical to 7bit-jis
14 #
15
16 sub decode
17 {
18     my ($obj,$str,$chk) = @_;
19     return Encode::decode('7bit-jis', $str, $chk);
20 }
21
22 # iso-2022-jp = 7bit-jis with all x201 (Hankaku) converted to
23 #               x208 equivalent (Zenkaku)
24
25 sub encode
26 {
27     my ($obj,$str,$chk) = @_;
28     my $euc =  Encode::encode('euc-jp', $str, $chk);
29     &Encode::JP::H2Z::h2z(\$euc);
30     return &Encode::JP::JIS::euc_jis(\$euc);
31 }
32
33 1;
34 __END__