1

I'm having trouble exporting CSV data that has non-latin characters.

I am exporting the data as a CSV file using the following headers and PHP code:

    header("Content-type: text/csv; charset=utf-8");
    header("Content-Disposition: attachment; filename=myFile.csv");
    header("Pragma: no-cache");
    header("Expires: 0");

    echo "First Name,Last Name, Email Address\n";
    foreach ($users as $user) {
        echo "{$user['first_name']},{$user['last_name']},{$user['email']}\n";
    }

On Microsoft Excel, Since my data contains non-latin chars (Hebrew) I am seeing a scrambled data like this:

enter image description here

This issue doesn't exists on LibreOffice. any ideas how can I make MS-Excel open the file correctly?

Broshi
  • 3,334
  • 5
  • 37
  • 52
  • Possible duplicate of [How can I output a UTF-8 CSV in PHP that Excel will read properly?](http://stackoverflow.com/questions/4348802/how-can-i-output-a-utf-8-csv-in-php-that-excel-will-read-properly) – Lionel Chan Mar 27 '16 at 12:52

0 Answers0