0

I'm working on CSV import / export system in persian language.

I have created script for export file. For I have used following header in php:

header('Content-Type: ' . $mime_type);
header('Content-Disposition: attachment; filename="'.$name.'"');
header("Content-Transfer-Encoding: binary");
header('Accept-Ranges: bytes');
header("Cache-control: private");
header('Pragma: private');

but when I try to read exported csv file or any other csv file using fgetcsv function it's return:

???? ?????? ????? ????? ? ???? ?????????? ?????? ?? ??? ????? ???? ??? ?????? ?????? ??? 

Instead of persian language string. I have used following code for read csv file:

if (($handle = fopen($csvfile, "r")) !== FALSE) {
    $max_line_length = defined('MAX_LINE_LENGTH') ? MAX_LINE_LENGTH : 10000;
    $header = fgetcsv($handle, $max_line_length);
    $header_colcount = count($header);
    while (($row = fgetcsv($handle, $max_line_length)) !== FALSE) {
        $row_colcount = count($row);
        if ($row_colcount == $header_colcount) {
            $entry = array_combine($header, $row);
            $csv[] = $entry;
        }
        else {
            error_log("csvreader: Invalid number of columns at line " . ($rowcount + 2) . " (row " . ($rowcount + 1) . "). Expected=$header_colcount Got=$row_colcount");
          return null;
        }
        $rowcount++;
    }
    //echo "Totally $rowcount rows found\n";
    fclose($handle);
}

Thanks

Kevin
  • 41,694
  • 12
  • 53
  • 70
Sandeep Solanki
  • 702
  • 1
  • 6
  • 15

0 Answers0