I have run into a strange situation while using PHP's iconv()
function. I have a MySQL database which contains several records that have French (and other European languages) characters within them. For example:
Saint-Côme-du-Mont
I am trying to write a function to convert these to friendly URLs, and turned to iconv()
. The problem is that if I use the transliteration feature, I get the following error:
Notice: iconv(): Detected an illegal character in input string in...
The code generating the problem is:
$url = iconv("utf-8", "us-ascii//TRANSLIT", $string); // TRANSLIT does the whole job
However, if I use //IGNORE
, I get the following output:
Saint-Cme-du-Mont
The field in the MySQL uses `` collation, and is stored as plain text. I've tried using utf8_encode()
, but the same behaviour is present.
If I use mb_detect_encoding()
on the input string, I get UTF-8
, so it seems to be receiving a string in the correct format.
How can I circumvent the Notice, and still carry out the translit operation?