That doesn't sound right

I beg to differ. They are not the same. Hashes should consider them different just like eq does. In perlguts speak, the UTF8 flag is preserved and observed (unlike the taint flag). That flag is a very important piece of information, and it should not be ignored.

Strings of chars and strings of encoded chars (no matter what the encoding) are not the same thing.

use Test::Simple tests => 6; use strict; use warnings; #use Devel::Peek qw( Dump ); use Encode qw( encode _utf8_on _utf8_off); { ok(1); my $chars_suites = "\x{2660}\x{2661}\x{2662}\x{2663}"; my $utf8_suites = encode('UTF-8', $chars_suites); _utf8_off(my $utf8_suites2 = $chars_suites); _utf8_on(my $chars_suites2 = $utf8_suites); # # Make sure they're the same, UTF8 flag non-withstanding. # print("\n"); # print("chars_suites:\n"); Dump($chars_suites); # print("\n"); # print("chars_suites2\n"); Dump($chars_suites2); # print("\n"); # print("utf8_suites:\n"); Dump($utf8_suites); # print("\n"); # print("utf8_suites2\n"); Dump($utf8_suites2); # print("\n"); ok($chars_suites eq $chars_suites2); ok($utf8_suites eq $utf8_suites ); ok($chars_suites ne $utf8_suites ); ok($chars_suites2 ne $utf8_suites2 ); my %hash; $hash{$chars_suites } .= 'a'; $hash{$chars_suites2} .= 'b'; $hash{$utf8_suites } .= 'c'; $hash{$utf8_suites2 } .= 'd'; ok($hash{$chars_suites} eq 'ab' && $hash{$utf8_suites } eq 'cd'); }

In reply to Re^3: Hash key string restrictions? by ikegami
in thread Hash key string restrictions? by Ojosh!ro

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.