/validate-charset (Validate for compatible characters)
This compiler option validates that the source file text contains only characters representable as UTF-8.
You can use the
/validate-charset option to validate that the source code contains only characters that can be represented in both the source character set and the execution character set. This check is enabled automatically when you specify
/utf-8 compiler options. To explicitly disable this check, specify the
By default, Visual Studio detects a byte-order mark to determine if the source file is in an encoded Unicode format, for example, UTF-16 or UTF-8. If no byte-order mark is found, it assumes that the source file is encoded in the current user code page, unless you have specified a code page by using
/utf-8 or the
/source-charset option. Visual Studio allows you to save your C++ source code in any of several character encodings. For information about source and execution character sets, see Character sets in the language documentation. For a list of supported code page identifiers and character set names, see Code Page Identifiers.
Visual Studio uses UTF-8 as the internal character encoding during conversion between the source character set and the execution character set. If a character in the source file can't be represented in the execution character set, the UTF-8 conversion substitutes a question mark (
?) character. If a substitution occurs, the
/validate-charset option causes the compiler to report a warning.
To set this compiler option in the Visual Studio development environment
Open the Property Pages dialog box for the project. For more information, see Set C++ compiler and build properties in Visual Studio.
Select the Configuration Properties > C/C++ > Command Line property page.
In Additional Options, add the
Choose OK to save your changes.
MSVC compiler options
MSVC compiler command-line syntax
/execution-charset (Set execution character set)
/source-charset (Set source character set)
/utf-8 (Set source and execution character sets to UTF-8)
Submit and view feedback for