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.


In reply to Re^2: Convert strings with unknown encodings to html by Pascal666
in thread Convert strings with unknown encodings to html by Pascal666

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.