iconv — Convert string to requested character encoding
php manual iconv方法的原话。
一般的情况下,我使用这个方法,都是这样使用:
If you append the string //TRANSLIT to out_charset transliteration is activated. This means that when a character can't be represented in the target charset, it can be approximated through one or several similarly looking characters. If you append the string //IGNORE, characters that cannot be represented in the target charset are silently discarded. Otherwise, str is cut from the first illegal character and an E_NOTICE is generated.
2 $text = 'xxxxxxxxxx';
3 echo 'Plain : ', iconv("UTF-8", "ISO-8859-1", $text), PHP_EOL;
4