I think it works as designed.  In other words, if you concat a unicode/character string with a non-unicode/byte string, the byte string will automatically be upgraded to unicode, with the non-ASCII values being interpreted as if they were in Latin-1 encoding — i.e. the first byte \xc2 (Â in Latin-1) becomes Unicode-Â (which happens to be codepoint U+00C2) encoded as UTF-8 (i.e. the bytes \xc3\x82), the second byte \xa9 (© in Latin-1) becomes Unicode-© (codepoint U+00A9) encoded as UTF-8 (i.e. the bytes \xc2\xa9), etc...

Update: if you print a hexdump of your string $x, e.g.

sub hexdump { my $s = shift; print join " ", unpack("(H2)*", $s), "\n"; } # ... hexdump($x);

you'd get

c3 82 c2 a9 c3 82 c2 ae c3 a2 c2 84 c2 a2 c2 a9 c2 ae e2 84 a2

with the first 4 bytes showing the result (UTF-8 encoding) of the conversion I tried to describe above.

Or, fully expanded:

_________ $r (auto-upgraded) _________ ________ $u ________ c2 a9 c2 ae e2 84 a2 c2-a9 c2-ae e2-84-a2 | | | | | | | | | | | | | | c3-82 c2-a9 c3-82 c2-ae c3-a2 c2-84 c2-a2 c2-a9 c2-ae e2-84-a2 Â © Â ® â U0084 ¢ © ® (TM)

In reply to Re: Problem with join'ing utf8 and non-utf8 strings (bug?) by almut
in thread Problem with join'ing utf8 and non-utf8 strings (bug?) by rsmah

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.