1use strict; 2use warnings; 3use Encode; 4use Encode::JP::Mobile ':props'; 5 6use Test::More; 7 8eval { require YAML }; 9plan skip_all => $@ if $@; 10 11my $dat = YAML::LoadFile("dat/kddi-table.yaml"); 12plan tests => 20 * @$dat; 13 14for my $r (@$dat) { 15 my $sjis = pack "H*", $r->{sjis}; 16 my $jis = "\e\$B" . pack("H*", $r->{email_jis}) . "\e(B"; 17 18 my $unicode = chr hex $r->{unicode}; 19 my $auto = chr hex $r->{unicode_auto}; 20 is decode("x-sjis-kddi-cp932-raw", $sjis), $unicode, $r->{unicode}; 21 is encode("x-sjis-kddi-cp932-raw", $unicode), $sjis, $r->{unicode}; 22 is encode("x-sjis-kddi-auto-raw", $auto), $sjis, $r->{unicode}; 23 is decode("x-sjis-kddi-auto-raw", $sjis), $auto, $r->{unicode}; 24 is decode("x-iso-2022-jp-kddi", $jis), $unicode, $r->{unicode}; 25 is encode("x-iso-2022-jp-kddi", $unicode), $jis, $r->{unicode}; 26 is decode("x-iso-2022-jp-kddi-auto", $jis), $auto, $r->{unicode}; 27 is encode("x-iso-2022-jp-kddi-auto", $auto), $jis, $r->{unicode}; 28 29 # is decode("x-utf8-kddi", encode("x-utf8-kddi", $auto)), $auto, $r->{unicode}; 30 my $x = encode("x-utf8-kddi", $auto); 31 Encode::_utf8_on($x); 32 is $x, $auto, $r->{unicode}; 33 34 if ($unicode =~ /\p{InKDDISoftBankConflicts}/) { 35 isnt decode('x-utf8-kddi', encode('x-utf8-kddi', $unicode)), $unicode, $r->{unicode}; 36 } else { 37 eval { encode("x-utf8-kddi", $unicode, Encode::FB_CROAK) }; 38 like $@, qr{does not map to x-utf8-kddi}, "$r->{unicode} does not map to x-utf8-kddi"; 39 } 40 41 ok $unicode =~ /^\p{InKDDIPictograms}+$/; 42 ok $unicode =~ /^\p{InKDDICP932Pictograms}+$/; 43 ok $unicode !~ /^\p{InKDDIAutoPictograms}+$/; 44 ok $unicode =~ /^\p{InMobileJPPictograms}+$/; 45 ok $unicode !~ /^\p{InDoCoMoPictograms}+$/; 46 47 ok $auto =~ /^\p{InKDDIPictograms}+$/; 48 ok $auto =~ /^\p{InKDDIAutoPictograms}+$/; 49 ok $auto !~ /^\p{InKDDICP932Pictograms}+$/; 50 ok $auto =~ /^\p{InMobileJPPictograms}+$/; 51 ok $auto !~ /^\p{InDoCoMoPictograms}+$/; 52} 53