0

I created a text file in PHP stipulating an UTF-8 encoding:

<?php
    // header('Content-Encoding: UTF-8');
    header('Content-Type: text/csv; charset=utf-8');
    header('Content-Disposition: attachment; filename="history.csv"');

    ...

    $fp = fopen('php://output', 'wb');
    fputcsv($fp, array_map('utf8_decode', array($row['item_type']))); // $row['item_type'] = "Ergänzung"
    fclose($fp);
?>

Here are the results, when i open it on my S4:

  • If the cellular is configured in German: Ergänzung

  • If the cellular is configured in French: Ergänzung

  • If the cellular is configured in English: Erg�zung

Strange. For me, even in English the smartphone should use the UTF-8 charset. This does not seem to be the case.

Denis
  • 3,954
  • 4
  • 29
  • 60
  • https://stackoverflow.com/questions/4348802/how-can-i-output-a-utf-8-csv-in-php-that-excel-will-read-properly . Maybe you can find this useful. – G.Spirov Apr 17 '20 at 09:08
  • No. Unfortunately, adding "header('Content-Encoding: UTF-8');" did not help. – Denis Apr 17 '20 at 14:36
  • The problem seems to come from the Samsung S4 itself. I opened the same file on a Samsung A7 and everything was displayed correctly even in English. – Denis Apr 17 '20 at 15:33

0 Answers0