Answer the question
In order to leave comments, you need to log in
How to cast attached file to UTF-8 via PHP?
The file below is an example given by google contacts for export. Such contacts are transferred in two clicks from phone to phone.
In fact, it looks like a regular CSV file.
When I opened it with the help of Chrome, Chrome said that it was CP1252 encoding.
Trying to convert it with an ICONV file turned into the ultimate mess.
Who did?
In this case, I do not know in advance what encoding of the input file, but I would like to work with UTF-8 without manual conversions - I uploaded the file, ran the script, and got the output file.
Example file: https://yadi.sk/d/3qr3MUmJsrqrr
I do it like this:
// get file
$content = file_get_contents($filename);
$content = mb_convert_encoding($content, 'UTF-8', 'CP1252');
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question