6 skip_all_without_dynamic_extension('Encode');
7 skip_all("encoding doesn't work with EBCDIC") if $::IS_EBCDIC;
8 skip_all_without_perlio();
14 # %mbchars = (encoding => { bytes => utf8, ... }, ...);
15 # * pack('C*') is expected to return bytes even if ${^ENCODING} is true.
18 pack('C*', 0x40) => pack('U*', 0x40), # COMMERCIAL AT
19 pack('C*', 0xA4, 0x40) => "\x{4E00}", # CJK-4E00
22 pack('C*', 0xB0, 0xA1) => "\x{4E9C}", # CJK-4E9C
23 pack('C*', 0x8F, 0xB0, 0xA1) => "\x{4E02}", # CJK-4E02
26 pack('C*', 0xA9) => "\x{FF69}", # halfwidth katakana small U
27 pack('C*', 0x82, 0xA9) => "\x{304B}", # hiragana KA
31 # 4 == @char; paired tests inside 3 nested loops,
32 # plus extra pair of tests in a loop, plus extra pair of tests.
33 plan tests => 2 * (4 ** 3 + 4 + 1) * (keys %mbchars);
35 for my $enc (sort keys %mbchars) {
36 no warnings 'deprecated';
37 local ${^ENCODING} = find_encoding($enc);
38 use warnings 'deprecated';
39 my @char = (sort(keys %{ $mbchars{$enc} }),
40 sort(values %{ $mbchars{$enc} }));
44 for my $start (@char) {
46 my $string = $start.$end;
47 my ($expect, $return);
50 # The answer will always be a length in utf8, even if the
51 # scalar was encoded with a different length
52 $return = length ($end . "\x{100}") - 1;
57 is (chomp ($string), $return);
58 is ($string, $expect); # "$enc \$/=$rs $start $end"
61 # chomp should not stringify references unless it decides to modify
66 is (ref($_), "ARRAY", "chomp ref (no modify)");
69 $/ = ")"; # the last char of something like "ARRAY(0x80ff6e4)"
72 ok (!ref($_), "chomp ref (modify)");