D
D
dimavfox2019-07-15 00:22:29
PHP
dimavfox, 2019-07-15 00:22:29

How to fix encoding when writing to csv file?

When writing to a csv file, the Russian text is written in krakozyabry.
How to fix?

$fp = fopen('importf.csv', 'w');
$list = array(
        'Category,Brand,Product,Variant,SKU,Price,Old price,Currency ID,Weight,Stock,Units,Visible,Featured,Meta title,Meta keywords,Meta description,Annotation,Description,Images,URL, Производитель, Платформа',
        $category.','.$brand.','.$name.', , ,'.$price.', ,2, , , ,1, ,'.$name.', , , , , ,'.$chp.",".$brand
      );
foreach($list as $line)
      {
        fputcsv($fp, explode(',', $line), ";");
      }
fclose($fp);

Ргровые приставки

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
xmoonlight, 2019-07-15
@xmoonlight

IW: I can't swear aloud...
1. Find out the encoding of the imported file
2. Convert or throw an error.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question