[MS] Making sure the Microsoft Visual C++ compiler chooses the right source encoding - devamazonaws.blogspot.com
You can tell the Microsoft Visual Studio compiler what encoding to use when reading source files, by means of the /source-charset compiler switch . If you don't specify an encoding, then the compiler tries to guess: If the file begins with a UTF-16 BOM, then the source file is interpreted as UTF-16. If the file begins with a UTF-8 BOM, then the source file is interpreted as UTF-8. Otherwise, the source file is interpreted in the default user code page. These settings are determined by your project configuration, which creates the possibility that they get out of sync with the actual intended file encoding. For C and C++, you can at least assert that the compiler configuration and file encoding match what you intended. That way, if Visual Studio secretly changes the file encoding from CP 1252 to UTF-8, say,¹ you can force a compiler error to alert you that the file encoding is messed up. // If you want to make sure it's CP 1252 static_assert('’' == '\x92...