4 # This script is written intentionally in ISO-2022-JP
5 # requires Encode 1.83 or better to work
9 if ($ENV{'PERL_CORE'}){
11 unshift @INC, '../lib';
13 require Config; import Config;
14 if ($Config{'extensions'} !~ /\bEncode\b/) {
15 print "1..0 # Skip: Encode was not built\n";
18 if (ord("A") == 193) {
19 print "1..0 # Skip: EBCDIC\n";
22 unless (PerlIO::Layer->find('perlio')){
23 print "1..0 # Skip: PerlIO required\n";
30 #use Test::More qw(no_plan);
31 use Test::More tests => 6;
33 use encoding 'iso-2022-jp';
35 my @hiragana = map {chr} ord("
\e$B$!
\e(B")..ord("
\e$B$s
\e(B");
36 my @katakana = map {chr} ord("
\e$B%!
\e(B")..ord("
\e$B%s
\e(B");
37 my $hiragana = join('' => @hiragana);
38 my $katakana = join('' => @katakana);
39 my %h2k; @h2k{@hiragana} = @katakana;
40 my %k2h; @k2h{@katakana} = @hiragana;
42 # print @hiragana, "\n";
46 $str = $hiragana; $str =~ tr/
\e$B$!
\e(B-
\e$B$s
\e(B/
\e$B%!
\e(B-
\e$B%s
\e(B/;
47 is($str, $katakana, "tr// # hiragana -> katakana");
48 $str = $katakana; $str =~ tr/
\e$B%!
\e(B-
\e$B%s
\e(B/
\e$B$!
\e(B-
\e$B$s
\e(B/;
49 is($str, $hiragana, "tr// # hiragana -> katakana");
51 $str = $hiragana; eval qq{\$str =~ tr/
\e$B$!
\e(B-
\e$B$s
\e(B/
\e$B%!
\e(B-
\e$B%s
\e(B/};
52 is($str, $katakana, "eval qq{tr//} # hiragana -> katakana");
53 $str = $katakana; eval qq{\$str =~ tr/
\e$B%!
\e(B-
\e$B%s
\e(B/
\e$B$!
\e(B-
\e$B$s
\e(B/};
54 is($str, $hiragana, "eval qq{tr//} # hiragana -> katakana");
56 $str = $hiragana; $str =~ s/([
\e$B$!
\e(B-
\e$B$s
\e(B])/$h2k{$1}/go;
57 is($str, $katakana, "s/// # hiragana -> katakana");
58 $str = $katakana; $str =~ s/([
\e$B%!
\e(B-
\e$B%s
\e(B])/$k2h{$1}/go;
59 is($str, $hiragana, "s/// # hiragana -> katakana");