开发者

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

开发者 https://www.devze.com 2022-12-30 00:49 出处:网络
so for example this will turn 1251 into utf-8. $utf8 = iconv(\'windows-1251\', \'utf-8\', $ansi); But how to turn unknown (when it comes to us we do not know yet what format it is) ( in general an

so for example this will turn 1251 into utf-8.

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

But how to turn unknown (when it comes to us we do not know yet what format it is) ( in general any ) format (possibly known by Iconv ) to 开发者_运维技巧utf-8? (code sample)


You cannot translate from an unknown character set, the best you can do is make a guess about the actual charset and use that guess as first parameter - you can use mb_detect_encoding() for that purpose.


I have written an array with the values of the string. You just need to do this:

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

And they are gone!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号