Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: Why does Encode::Repair only correctly fix one of these two tandem characters?

by Jim (Curate)
on Aug 10, 2014 at 16:24 UTC ( #1096920=note: print w/replies, xml ) Need Help??


in reply to Re: Why does Encode::Repair only correctly fix one of these two tandem characters?
in thread Why does Encode::Repair only correctly fix one of these two tandem characters?

TMTOWTDI.

I think the right-to-left pipeline I used to damage the characters for the purpose of the demonstration…

# <-- 3 <-- 2 <-- 1 $foo = encode('UTF-8', decode('Windows-1252', encode('UTF-8', $foo)));

…more clearly emulates what actually happens in the wild:  text is encoded in UTF-8, then wrongly decoded as if it were encoded in Windows-1252, then encoded again in UTF-8. I'm not sure what using the in-place convenience function Encode::from_to() lends to the clarity and effectiveness of the demonstration of the sequence of events.

FWIW, Encode::Repair uses Encode::encode() and Encode::decode(), not Encode::from_to().

Replies are listed 'Best First'.
Re^3: Why does Encode::Repair only correctly fix one of these two tandem characters?
by remiah (Hermit) on Aug 11, 2014 at 02:05 UTC

    I am so slow to understand the situation...

    I thought proper byte conversion from UTF-8 to cp1252 will solve the whole problem(between 1 and 2 of the pipeline).
    But the wrongly encoded text is already there in the wilderness, and no way back, right?

    Then I have no good idea...

      Sorry, I don't understand you.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (8)
As of 2020-09-24 11:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If at first I donít succeed, I Ö










    Results (133 votes). Check out past polls.

    Notices?