N
N
Nikita Souvel2016-03-11 17:46:55
PHP
Nikita Souvel, 2016-03-11 17:46:55

How to change file encoding?

How can I change the encoding of a file.
What we have:
The file is generated by the following code:

$fp = @fopen($log_file, 'w');
foreach ($list as $fields) {
  @fputcsv($fp, $fields, ';');
}
@fclose($fp);

The string can also contain Russian letters.
website encoded in UTF-8.
Is it possible to somehow set the encoding of this particular file to cp1251 . in excel there is a kvakozyabra.
Tell me please

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Melkij, 2016-03-11
@Souvel1

iconv as usual for manipulating encodings.

V
Viktor, 2016-03-11
@master2016

process the file in utf-8
and before writing to Excel (before creating an object) try to specify the locale something like this
$validLocale = PHPExcel_Settings::setLocale('ru');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question