How to convert any possible format to UTF-8 using Iconv?

so, for example, it will turn 1251 into utf-8.

$utf8 = iconv('windows-1251', 'utf-8', $ansi);

But how to turn the unknown (when we still don’t know what format it is) (generally any) format (possibly well-known Iconv) into utf-8? (sample code)

+5
source share
2 answers

You cannot translate from an unknown character set; the best you can do is guess the actual encoding and use it as the first parameter - you can use it mb_detect_encoding()for this purpose.

+8
source

I wrote an array with string values. You just need to do this:

$string = str_replace("â€Å"","",$string);
$string = str_replace("â€Â","",$string);

And they are gone!

-14
source

All Articles