1use strict; 2use warnings; 3use Test::More tests => 42; 4use Encode::JP::Mobile; 5use Encode::JP::Mobile::KDDIJIS; 6use Encode; 7 8sub test_it { 9 my ($jis, $normal_uni, $auto_uni, $case) = @_; 10 $case ||= unpack "H*", $normal_uni; 11 12 is decode("x-iso-2022-jp-kddi", $jis), $normal_uni, "decoding $case(normal)"; 13 is $jis, encode("x-iso-2022-jp-ezweb", $normal_uni), "encoding $case(normal)"; 14 is decode("x-iso-2022-jp-ezweb-auto", $jis), $auto_uni, "decoding $case(auto)"; 15 is $jis, encode("x-iso-2022-jp-kddi-auto", $auto_uni), "encoding $case(auto)"; 16 17 # test kddi-auto Unicode chars as well ... rare in reality though 18 my $bytes = $jis; 19 Encode::from_to($bytes, "x-iso-2022-jp-kddi" => "x-sjis-kddi-cp932-raw"); 20 Encode::from_to($bytes, "x-sjis-kddi-cp932-raw", "x-iso-2022-jp-kddi"); 21 is $bytes, $jis, "x-sjis-kddi-auto $case"; 22} 23 24test_it("\e\$B\x75\x41\e(B", "\x{E488}", "\x{EF60}", "pictogram"); 25 26test_it "a", decode('utf8', 'a'), decode('utf8', 'a'), 'alphabet'; 27test_it "\e\$B\x24\x57\e\(B", "\x{3077}", "\x{3077}", 'kanji(tora)'; 28 29is encode('x-iso-2022-jp-kddi', "\x{5bc5}"), encode('iso-2022-jp', "\x{5bc5}"), "kanji"; 30is decode('x-iso-2022-jp-kddi', "\e\$B\x24\x57\e\(B", Encode::FB_PERLQQ), "\x{3077}", "test fallback branch(only for test coverage)"; 31 32test_it "\e\$B\x75\x41\e(B", "\x{E488}", "\x{EF60}", 'pictogram'; 33test_it "\e\$B\x75\x41\x76\x76\e(B", "\x{e488}\x{e51b}", "\x{EF60}\x{EFF4}", 'pictogram'; 34test_it encode('iso-2022-jp', decode("utf8", "お")), decode('utf8', "お"), decode('utf8', "お"), 'o'; 35test_it encode('iso-2022-jp', decode("utf8", "おいおい。山岡くん。kanbenしてくれよ!表示。")), decode('utf8', "おいおい。山岡くん。kanbenしてくれよ!表示。"), decode('utf8', "おいおい。山岡くん。kanbenしてくれよ!表示。"), 'kanji, hiragana, alphabet'; 36test_it "\e\(I\x54\x2F\x4E\x5F\e(B", decode('utf8', "ヤッポ"), decode('utf8', "ヤッポ"), 'half width katakana'; 37 38# is decode('x-iso-2022-jp-kddi', "\e\$(D\x2B\x21\x30\x57\e(B"), "\x{00E1}\x{4F0C}", 'JIS X 0212'; 39