title: Why French characters don't work using utf-8 with Java?
body: <p>I have a HTML file with some French character in it. I need to replace some string inside that file, so I do the following:</p>
  
  <pre><code>public static void replaceStringInFile(String filePath, String oldText, String newText)
  {
      try
      {
          Path path = Paths.get(filePath);
          Charset charset = StandardCharsets.UTF_8;
          String content = new String(Files.readAllBytes(path), charset);
          content = content.replace(oldText, newText);
          Files.write(path, content.getBytes(charset));
      }
      catch(Exception e)
      {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>My strings are replaced, but the French character are not there, replaced with ï¿½</p>
  
  <p>If I replace UTF_8 with ISO_8859_1, it's working. </p>
  
  <p>I thought UTF_8 was universal? Should work with French? I tried to specify utf-8 in the html file header:</p>
  
  <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="utf-8"/&gt;
  ....
  &lt;/style&gt;
  </code></pre>
  
  <p></p>
  
  <p>I would like to understand why UTF_8 isn't keeping my French characters...</p>