in reply to Problem with join'ing utf8 and non-utf8 strings (bug?)
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)
|
|---|