title: PHP get content of file in UCS-2 LE BOM encoding and replace strings in it
body: <p>I need to get the content of a .csv file and replace some strings in it. To do that, I use the following simple code:</p>
  
  <pre><code>    $pattern = "test";
      $replacement = "Replacement";
      $string = file_get_contents( "myDoc.csv" );
      $string =  str_replace( $pattern, $replacement, $string );
  </code></pre>
  
  <p>However, what $string holds:</p>
  
  <pre><code>echo $string; // Outputs: This is my test 
  var_dump($string); // Outputs: string(32) "��This is my test" 
  </code></pre>
  
  <p>I found out the file is in UCS-2 LE BOM encoding. If I convert the file to another encoding, I will probably lose some symbols/characters.</p>
  
  <p>It is essential that the file has the same format and the content is not modified in any way (except for the targeted strings).</p>
  
  <p>How should I make the replacement of the strings so that I don't lose information? </p>