title: VS2019 compiler misinterprets UTF8 without BOM file as ANSI
body: <p>I used to compile my C++ wxWidgets-3.1.1 application (Win10x64) with VS2015 Express. I wanted to upgrade my IDE to VS2019 community, which seemed to work quite well.
  My project files are partly from older projects, so their encoding differs (Windows-1252, UTF-8 without BOM, ANSI).</p>
  
  <p>With VS2015 I was able to compile and give out messages (hardcoded in my .cpp files), which displayed unicode characters correctly.
  The same app compiled with VS2019 community shows for example the german word "übergabe" as "Ã¼bergabe" which is uninterpreted UTF8.</p>
  
  <p>Saving the .cpp file, which contains the unicode, explicitly as UTF8 WITH BOM solves this issue. But I don't want run through all files in all projects. Can I change the expected input from a "without BOM" file to UTF-8 to get the same behaviour that VS2015 had?</p>
  
  <p><strong>[EDIT]</strong>
  It seems there is no such option. As I said before, converting all .cpp/.h files to UTF-8-BOM is a solution.
  Thus, so far the only suitable way is to loop through the directory, rewrite the files in UTF-8 while prepending the BOM.</p>
  
  <p>Using C++ wxWidgets, this is (part of) my attempt to automate the process:</p>
  
  <pre><code>//Read in the file, convert its content to UTF8 if necessary
  wxFileInputStream fis(fileFullPath);
  wxFile file(fileFullPath);
  size_t dataSize = file.Length();
  void* data = malloc(dataSize);
  if (!fis.ReadAll(data, dataSize))
  {
      wxString sErr;
      sErr &lt;&lt; "Couldn't read file: " &lt;&lt; fileFullPath;
      wxLogError(sErr);
  }
  else
  {
      wxString sData((char*)data, dataSize);
      wxString sUTF8Data;
      if (wxEmptyString == wxString::FromUTF8(sData))
      {
          sUTF8Data = sData.ToUTF8();
      }
      else
      {
          sUTF8Data = sData;
      }
      wxFFileOutputStream out(fileFullPath);
  
      wxBOM bomType = wxConvAuto::DetectBOM(sUTF8Data, sUTF8Data.size());
      if (wxBOM_UTF8 != bomType)
      {
          if (wxBOM_None == bomType)
          {
              unsigned char utf8bom[] = { 0xEF,0xBB,0xBF };
              out.Write((char*)utf8bom, sizeof(utf8bom));
          }
          else
          {
              wxLogError("File already contains a different BOM: " + fileFullPath);
          }
      }
  }
  </code></pre>
  
  <p>Note that this can not convert all encodings, basically afaik it can only convert ANSI files or add the BOM to UTF-8 files without BOM. For all other encodings, I open the project in VS2019, select the file and go (freely translated into english, names might differ):
  -> File -> XXX.cpp save as... -> Use the little arrow in the "Save" button -> Save with encoding... -> Replace? Yes! -> "Unicode (UTF-8 with signature) - Codepage 65001"
  (Don't take "UTF-8 without signature" which is also Codepage 65001, though!)</p>