Visual Studio (MSVC) Text Encoding
Microsoft can never escape the historical burden of code pages.


Compiler warning C4819: The file contains a character that cannot be represented in the current code page (932). Save the file in Unicode format to prevent data loss.

In Visual Studio 2026, newly created C++ source files have the default text encoding of UTF-8 (without BOM). However, the default compiler (MSVC) configuration in a new project can only parse source files either in the current OS code page or as UTF-8 with BOM. The discrepancy in default configuration causing new source code files being saved as UTF-8, but processed by compiler as the current OS code page.
In the first example, the compiler is parsing the UTF-8 source as Windows 1252, which can parse most valid UTF-8 bytes as Windows 1252 bytes, thus passing the compiler validation silently. In the second example, the compiler is parsing the source as CP 932 (Shift-JIS), which has a stricter set of rules of valid byte sequences, thus triggering compiler warning when parsing UTF-8 bytes.