I need to convert a CSV file from UCS-2LE
to UTF-8
encoding. So far I've tried the following:
$str = file_get_contents($file);
$str = mb_convert_encoding($str, 'UTF-8', 'UCS-2LE');
file_put_contents($newfile, $str);
But the problem is PHP encoding the new file as UTF-8 BOM
instead of pure UTF-8
(according to Notepad++).
Notepad++ also have options to set encoding as UTF-8
(without the BOM).
I don't understand why PHP adding BOM
on UTF-8
even when I explicitly instructed it to UTF-8
only.