title: Encoding French Characters, csv - PHP
body: <p>I am working on a project that exports a simple CSV. So far, my code works and generates the CSV as long as I use English characters. </p>
  
  <p>Some column names will be in French and would like to be able to encode that. </p>
  
  <p>Here's what I have:</p>
  
  <pre><code>&lt;?php 
      // open the file "demosaved.csv" for writing
      $file = fopen('myfrench-export.csv', 'w');
      // save the column headers
      fputcsv($file, array('Question', 'Réponse 1/4', 'Réponse 2/4', 'Réponse 3/4', 'Réponse 4/4', 'Total completé', 'Total non-completé', 'Total cumulatif'));
  
      // Sample data. This can be fetched from mysql too
      $data = array(
          array('Data 11', 'Data 12', 'Data 13', 'Data 14', 'Data 15'),
          array('Data 21', 'Data 22', 'Data 23', 'Data 24', 'Data 25'),
          array('Data 31', 'Data 32', 'Data 33', 'Data 34', 'Data 35'),
          array('Data 41', 'Data 42', 'Data 43', 'Data 44', 'Data 45'),
          array('Data 51', 'Data 52', 'Data 53', 'Data 54', 'Data 55'),
          array('Data 51', 'Data 52', 'Data 53', 'Data 54', 'Data 55'),
          array('Data 51', 'Data 52', 'Data 53', 'Data 54', 'Data 55'),
          array('Data 51', 'Data 52', 'Data 53', 'Data 54', 'Data 55'),
      );
  
      // save each row of the data
      foreach ($data as $row)
      {
          fputcsv($file, $row);
      }
  
      // Close the file
      fclose($file); ?&gt;
  </code></pre>