Horrible combination, spent all day on this!
My goal was to take some data (which contain UTF-8 unicode characters), generate a CSV file using PHP and send it via mail. The problem is that Microsoft Excel doesn`t accept UTF-8 CSV files.
Some people suggest using
mb_convert_encoding($contents, "ISO-8859-1", "UTF-8"); or
mb_convert_encoding($contents, "UTF-16LE", "UTF-8");, neither worked for me, though I have multibyte extension installed
It seems that the solution is different by server setups. This solution worked for me:
$message= iconv("UTF-8","WINDOWS-1257",html_entity_decode( $message ,ENT_COMPAT,'utf-8'));
You might want to change “WINDOWS-1257” to something else, like WINDOWS-1255 or WINDOWS-1252 or ISO-8859-1, etc.. My server did not have the “iconv” function enabled, so I asked server administrator to enable it and it worked!