I have a feed taken from third-party sites, and sometimes I have to apply utf8_decode
and other times utf8_encode
to get the desired visible output.
If by mistake the same stuff is applied twice/or the wrong method is used I get something more ugly, this is what I want to change.
How can I detect when what have to apply on the string?
Actually the content returns UTF-8, but inside there are parts that are not.
I can't say I can rely on
mb_detect_encoding()
. I had some freaky false positives a while back.The most universal way I found to work well in every case was: