Reputation: 4636
I need your help to finish my project. I take the data from my json files, some of which consist of chinese characters, but when I try to write to .csv it does not display properly.
This is my code
function writeCsv()
{
$resource = fopen('c:/xampp/test.json','w');
$csvBodyData = [ 'item'=> '逆始感録機政'];
fputcsv($resource, $csvBodyData);
}
I have tried the following solution but it's still not working.
write utf-8 characters to file with fputcsv in php
I got this character "???".
Upvotes: 1
Views: 1391
Reputation: 2287
In your case the problem was not in PHP. When you open a csv file in Excel it shows you a window, where you can setup CSV importing options like delimiter and encoding. You should choose UTF-8
encoding to view those Chinese characters.
Upvotes: 2