On Thu, 21 Mar 2002 22:12:33 +0900
SADAHIRO Tomoyuki <[EMAIL PROTECTED]> wrote:
> 
> Nevertheless, we shouldn't distinguish Unicode-ness of hash keys;
> otherwise we'd be upset more... :-)
> 
> #!perl
> use charnames qw(:full);
> 
> my $alpha = "\N{GREEK SMALL LETTER ALPHA}";
>    # "\x{945}" = "\xCE\xB1" UTF8
> 
> my $latin =
>   "\N{LATIN CAPITAL LETTER I WITH CIRCUMFLEX}\N{PLUS-MINUS SIGN}";
>    # "\xCE\xB1" Bytes
> 
> my %hash;
> $hash{$alpha} = "foo";
> $hash{$latin} = "bar";
> 
> print $hash{$alpha} eq $hash{$latin} ? "not ok" : "ok";
> 
> # Perl 5.6.1 says "not ok",
> # while Perl 5.7.3 says "ok".

Sorry, that is a bad example.
A better one:

#!perl
my %hash;
$hash{"\xA1"}     = "foo";
$hash{"\xC2\xA1"} = "bar";

print $hash{pack('U', 0xA1)};
  # "foo" on Perl 5.7.3
  # "bar" on Perl 5.6.1
  # U+00A1 is "\xC2\xA1" in UTF-8.

Regards,
SADAHIRO Tomoyuki

Reply via email to