Answer the question
In order to leave comments, you need to log in
How to open correctly a file saved in cp1251 on a site where all the encoding is utf8?
In general, the essence is that the file is submitted and processed, it is a CSV file, and since it is saved in Excel, it is encoded in cp1251 at the output, and the entire site is encoded in utf8, how can this problem be correctly solved?
Answer the question
In order to leave comments, you need to log in
For example, you can do this:
$fh = fopen("file.csv", "r");
while (false !== $row = fgetcsv($fh, ...)) {
foreach ($row as &$rowItem) {
$rowItem = mb_convert_encoding($rowItem, "utf8", "cp1251");
}
unset($rowItem);
...
}
fclose($fh);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question