B
B
bichukov2021-11-24 13:33:04
1C-Bitrix
bichukov, 2021-11-24 13:33:04

How to transcode text when creating csv file?

From the order I take the values.
$arSelectFields = Array('ID','DATE_INSERT_FORMAT','USER_NAME','USER_EMAIL','PRICE','CURRENCY');
$interenc = mb_internal_encoding();

$db_sales = CSaleOrder::GetList(array("DATE_INSERT" => "ASC"), $arrFilterCurDate ,'','',$arSelectFields);
while ($ar_sales = $db_sales->Fetch())
{

$collections[$ar_sales['ID']] = $ar_sales;

}

and then transfer them to the created CSV file.

$interenc = mb_internal_encoding();
$inputenc = mb_convert_variables($interenc, "UTF-8,",$collections);

$fileWithPropsValue = '/upload/pai/collections.csv';
if(!
IO\Directory::createDirectory(Application::getDocumentRoot() . '/upload/pai/');
}
$file = new IO\File(Application::getDocumentRoot() . $fileWithPropsValue);
$file->putContents(''); // clear file

putDataToCSV(Application::getDocumentRoot().$fileWithPropsValue,$collections);

but in the toga the entire Cyrillic alphabet is Сергей

How could this be corrected or recoded?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bichukov, 2021-11-24
@bichukov

everything was solved like this
$collections = mb_convert_encoding($collections, "Windows-1251");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question