If you used the accepted answer, however, you will still receive the PHP Notice if a character in your input string cannot be transliterated:
<?php
$cp1252 = '';
for ($i = 128; $i < 256; $i++) {
$cp1252 .= chr($i);
}
echo iconv("cp1252", "utf-8//TRANSLIT", $cp1252);
PHP Notice: iconv(): Detected an illegal character in input string in CP1252.php on line 8
Notice: iconv(): Detected an illegal character in input string in CP1252.php on line 8
So you should use IGNORE, which will ignore what can't be transliterated:
echo iconv("cp1252", "utf-8//IGNORE", $cp1252);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…