iconv - Detected an illegal character in input string
The illegal character is not in $matches[1]
, but in $xml
Try
iconv($matches[1], 'utf-8//TRANSLIT', $xml);
And showing us the input string would be nice for a better answer.
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);