skip to Main Content

We are trying so many ways tamil content show like in csv file " தூதà¯à®¤à¯à®•à¯à®•à¯à®Ÿà® " please help me .

 mysqli_set_charset($db, "utf8mb4");
$query = $db->query("$reports");

if($query->num_rows > 0){
    $delimiter = ",";
    $filename = "report_" . date('Y-m-d') . ".csv";

    // Create a file pointer
    $f = fopen('php://memory', 'w');

    // Set column headers
    // $fields = array('ID', 'FIRST NAME', 'LAST NAME', 'EMAIL', 'GENDER', 'COUNTRY', 'CREATED', 'STATUS');
    $fields = array('Ticket No','Name','Phone','Zone','Ward','Street','Department','Category','Description','Asgn. Employee','Date','Overdue Date','Status Updated On','Status');

    fputcsv($f, $fields, $delimiter);

    // Output each row of the data, format line as csv and write to file pointer
    while($row = $query->fetch_assoc()){
        $count = 0 ;
        $status = ($row['status'] == 1)?'Active':'Inactive';
        $lineData = array($row['ticket_id'], $row['empname'], $row['COMP_MOB'], $row['zone_name'], $row['ward_name'],$row['ASSN_STREET'], $row['name'], $row['complaint_cat_name'], $row['DEPT_DESCRIPTION'], $row['emp_name'],$row['dateofsubmit'],$row['overdue'],$row['dateofupdate'],$row['STATUS']);
        fputcsv($f, $lineData, $delimiter);
    }

    // Move back to beginning of file
    fseek($f, 0);

    // Set headers to download file rather than displayed
 header('Content-Type: text/csv');
 header('Content-Encoding: UTF-8');
  
    header('Content-Disposition: attachment; filename="' . $filename . '";');
    //output all remaining data on a file pointer

    fpassthru($f);
}
exit;
?>

enter image description here

After export csv we need tamil font

2

Answers


  1. Your export is not using Unicode to write Tamil characters

    Unicode (https://en.wikipedia.org/wiki/Unicode) is the international standard encoding for characters in all languages, and is used by Microsoft Excel and other modern programs.

    Older systems for encoding Tamil include TAM and TSCII (https://en.wikipedia.org/wiki/Tamil_Script_Code_for_Information_Interchange).

    Option 1

    Update the program that is writing the CSV, to use Unicode. This is the best option.

    Option 2

    Try to convert the non-Unicode characters into Unicode. One place to start might be here:

    https://github.com/ThaniThamizhAkarathiKalanjiyam/AnyTaFont2UTF8

    Login or Signup to reply.
  2. This is not issue with the code. Same code worked well in my case. Possibly Excel doesn’t recognize the utf-8. You can try below steps

    1. Open seperate Excel file
    2. Goto Data–>Import External Data –> Import Data csv file
    3. in import wizard, change the File_Origin to "65001 UTF" then load
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search