I am creating a laravel csv download functionality but I have problem when data has Japanese characters, it is unreadable. Example is somehow like this: Test å·å´Žã‚²ã‚¹ãƒˆãƒã‚¦ã‚¹
which makes the data useless. I have this process when downloading the csv data:
$downloads = $downloads->with('data')->get()->toArray();
$handle = fopen($filename, 'w+');
fputcsv($handle, $columns);
for($i = 0; $i < count($downloads); $i++){
for($j = 0; $j < count($downloads[$i]['data']); $j++ ){
$details = $downloads[$i];
$user = $details['data'][$j];
$name = $user['last_name'] . ', ' . $user['first_name'] . ' ' . $user['middle_name'] ;
fputcsv($handle, array(
$details['id'],
$details['room_name'],
$details['room_code'],
$details['reservation_id'],
$details['registered_name'],
));
}
}
fclose($handle);
$headers = array(
'Content-Type' => 'text/csv',
'Content-transfer-encoding' => 'binary\n'
);
return Response::download($filename, $filename, $headers);
I have tried a lot of suggestions but it's not working on me. ref1 ref2. Any help on this?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire