Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^4: Encoding horridness

by Anonymous Monk
on Jul 12, 2017 at 14:26 UTC ( [id://1194939]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Encoding horridness
in thread Encoding horridness

What I'm wondering, though, is if there's ever a situation where
encode('utf8', decode('Latin-1', $_))
produces different output from
encode('utf8', $_)

Replies are listed 'Best First'.
Re^5: Encoding horridness
by choroba (Cardinal) on Jul 12, 2017 at 16:51 UTC
    Yes, for example:
    $_ = 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,
      Fine. If the decode doesn't die, does it ever produce different output? (One might argue that call that dies doesn't produce any output, and therefore does not produce different output, but whatever.)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1194939]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-19 17:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found