No, because high-bit characters/octets in Latin-1 encode differently as octets in UTF-8, and Perl doesn't know what to do with high-bit characters when writing them.
| [reply] |
What I'm wondering, though, is if there's ever a situation where
encode('utf8', decode('Latin-1', $_))
produces different output from
encode('utf8', $_)
| [reply] [d/l] [select] |
$_ = decode('utf-8', "\N{LATIN SMALL LETTER A WITH ACUTE}");
say encode('utf8', $_); # Replacement character EF
+BFBD.
say encode('utf8', decode('Latin-1', $_)); # Dies.
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord
}map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
| [reply] [d/l] [select] |
| [reply] |
Yes, and encode('utf8', decode('Latin-1', $_)) isn't a no-op.
| [reply] |