Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re^2: Convert strings with unknown encodings to html

by Pascal666 (Scribe)
on Jul 01, 2015 at 02:18 UTC ( #1132741=note: print w/replies, xml ) Need Help??

in reply to Re: Convert strings with unknown encodings to html
in thread Convert strings with unknown encodings to html

I mentioned the database primarily so that I would not get suggestions that involve open's encoding option. All of the examples above are from the same column. It may be possible to have multiple formats in the same string. Even if that is not the case today, I would like a solution that supports it in the future.

I need to normalize to HTML. Whatever intermediate encoding gets the job done is fine by me. Passing html to encode_entities causes it to be double encoded, which does not display correctly on a web page, so first thing I do is run the input through decode_entities. I suppose it is possible that the input will already be double encoded html. I hadn't thought about running decode_entities multiple times before. Good idea.

The database is only a few months old, is added to constantly, and is expected to be added to indefinitely. It is extremely unlikely the provider will do anything to improve their input sanitization. Had they the choice, they would not provide me the data in any format. They certainly aren't going to make it any easier to parse.

I do try not to post n run. You took the time to read my message and reply, the least I can do is satisfy your curiousity.

Thank you for the detailed analysis and suggestions. Had Encoding::FixLatin not been suggested first, I probably would have ended up using your "guidelines" as an outline for a solution.

  • Comment on Re^2: Convert strings with unknown encodings to html

Replies are listed 'Best First'.
Re^3: Convert strings with unknown encodings to html
by graff (Chancellor) on Jul 01, 2015 at 02:27 UTC
    I hadn't heard of Encoding::FixLatin myself prior to seeing this thread, and I'm glad to have learned about it.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2020-10-23 03:28 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (234 votes). Check out past polls.