title: Non-UTF8 files (Google CSV file)
body: <p>I'm running into weird encoding issues when handling uploaded files.</p>
  
  <p>I need to accept any sort of text file, and be able to read the contents. Specifically having trouble with files downloaded from a Google Contacts export.</p>
  
  <p>I've done the usual utf8_encode/decode, mb_detect_encoding, etc. Always returns as if the string is UTF-8, and tried many iconv options to try and revert encoding, but unsuccessful.</p>
  
  <p><strong>test.php</strong></p>
  
  <pre><code>header('Content-type: text/html; charset=UTF-8');
  
  if ($stream = fopen($_FILES['list']['tmp_name'], 'r'))
  {
      $string = stream_get_contents($stream);
  
      fclose($stream);
  }
  
  echo substr($string, 0, 50);
  var_dump(substr($string, 0, 50));
  echo base64_encode(serialize(substr($string, 0, 50)));
  </code></pre>
  
  <p><strong>Output</strong></p>
  
  <pre><code>��N�a�m�e�,�G�i�v�e�n� �N�a�m�e�,�A�d�d�i�t�i�o�n�
  ��N�a�m�e�,�G�i�v�e�n� �N�a�m�e�,�A�d�d�i�t�i�o�n�
  czo1MDoi//5OAGEAbQBlACwARwBpAHYAZQBuACAATgBhAG0AZQAsAEEAZABkAGkAdABpAG8AbgAiOw==
  </code></pre>