title: Convert data to keep accents before exporting to CSV
body: <p>Using PHP, I'm exporting results of a query to CSV. My problem comes when the data contains accent; they are not exported correctly and I lose them all in the generated file.</p>
  
  <p>I used the <code>utf8_decode()</code> function to manually convert the headers and it worked perfectly, but I don't know how to use it for the results array.</p>
  
  <p>Anyone can help me out please!?</p>
  
  <pre><code>result = db_query($sql);
  if (!$result) die('Couldn\'t fetch records');
  
  $fp = fopen('php://output', 'w');
  if ($fp &amp;&amp; $result) {
   header("Content-type: application/vnd.ms-excel; charset=UTF-8");
   header('Content-Disposition: attachment; filename="adp_enigmes_data.csv"');
   header('Pragma: no-cache');
   header('Expires: 0');
   fputcsv($fp, $headerTitles);
  
   while ($row = $result-&gt;fetch_array(MYSQLI_NUM)) {
       // When I use utf8_decode here, I don't get any results, so I have
          // no idea where to use it!
          fputcsv($fp, utf8_decode(array_values($row)), ',', '"');
   }
   die;
  }
  </code></pre>