9 # Two hashes one will all keys 8-bit possible (initially), other
10 # with a utf8 requiring key from the outset.
12 my %hash8 = ( "\xff" => 0xff,
15 my %hashu = ( "\xff" => 0xff,
20 # Check that we can find the 8-bit things by various litterals
21 is($hash8{"\x{00ff}"},0xFF);
22 is($hash8{"\x{007f}"},0x7F);
23 is($hash8{"\xff"},0xFF);
24 is($hash8{"\x7f"},0x7F);
25 is($hashu{"\x{00ff}"},0xFF);
26 is($hashu{"\x{007f}"},0x7F);
27 is($hashu{"\xff"},0xFF);
28 is($hashu{"\x7f"},0x7F);
30 # Now try same thing with variables forced into various forms.
31 foreach my $a ("\x7f","\xff")
34 is($hash8{$a},ord($a));
35 is($hashu{$a},ord($a));
37 is($hash8{$a},ord($a));
38 is($hashu{$a},ord($a));
41 is($hash8{$b},ord($b));
42 is($hashu{$b},ord($b));
45 # Check we have not got an spurious extra keys
46 is(join('',sort { ord $a <=> ord $b } keys %hash8),"\x7f\xff");
47 is(join('',sort { ord $a <=> ord $b } keys %hashu),"\x7f\xff\x{1ff}");
49 # Now add a utf8 key to the 8-bit hash
50 $hash8{chr(0x1ff)} = 0x1ff;
52 # Check we have not got an spurious extra keys
53 is(join('',sort { ord $a <=> ord $b } keys %hash8),"\x7f\xff\x{1ff}");
55 foreach my $a ("\x7f","\xff","\x{1ff}")
58 is($hash8{$a},ord($a));
61 is($hash8{$b},ord($b));
64 # and remove utf8 from the other hash
65 is(delete $hashu{chr(0x1ff)},0x1ff);
66 is(join('',sort keys %hashu),"\x7f\xff");
68 foreach my $a ("\x7f","\xff")
71 is($hashu{$a},ord($a));
73 is($hashu{$a},ord($a));
76 is($hashu{$b},ord($b));