And have you decided what format you want to normalize to? If so, what is that? (If not, why not?)
If there's really no way to predict what sort of encoding is coming back from the database for a given query, then you really do have one totally fubar'd database. What a shame.
I gather you've done some diagnosis of database contents, and have some idea about the scope of variation. Is stuff still being added to it? If so, does it continue to be as messy and uncontrolled as the stuff that's already there?
Don't feel like you have to tell us the answers to all those questions - those are just the main things you have to think about because they affect what kind(s) of solution(s) are likely to be useful.
Let's suppose you want to your "normalized format" to be just utf8 characters (no entities like & ®  etc.)
In terms of checking what needs to be done to a given string in order to get to that normalized form, there are a few handy guidelines:
and then check $@. If it's true (meaning that the eval block died), then the string is definitely not utf8; if it's false, the eval block didn't die, and you can be reasonably sure that the string is utf8-encoded.eval { decode('utf8', $string, Encode::FB_CROAK) };
Once the string is purely utf8 characters with no entity references, it should be pretty easy to convert that, if necessary, to any other form that you may need for a web display. Good luck.
In reply to Re: Convert strings with unknown encodings to html
by graff
in thread Convert strings with unknown encodings to html
by Pascal666
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |