title: How to convert a file to UTF-8 in php?
body: <p>Is it possible to convert a file into UTF-8 on my end?</p>
  
  <p>If I have an access on the file after the submission with</p>
  
  <pre><code>$_FILES['file']['tmp_name']
  </code></pre>
  
  <p><strong>Note:</strong> The user can upload a CSV file with any kind of charset, I usually encounter an <strong>unknown 8-bit</strong> charset.</p>
  
  <p>I try</p>
  
  <pre><code>$row = array();
  $datas = file($_FILES['file']['tmp_name']);
  foreach($datas as $data) {
      $data = mb_convert_encoding($data, 'UTF-8');
      $row[] = explode(',', $data);
  }
  </code></pre>
  
  <p>But the problem is, this code remove special characters like single quote.</p>
  
  <p>My first question is <a href="https://stackoverflow.com/questions/46823873/htmlspecialchars-remove-the-value-inside-the-array/46824852?noredirect=1#comment80608968_46824852">htmlspecialchars remove the value inside the array?</a></p>
  
  <p>I put it for additional information. Thanks for those who can help!</p>