[Development] MSVC 2015 option /utf8: Qt only or everyone?

Thiago Macieira thiago.macieira at intel.com
Wed May 11 10:19:33 CEST 2016

On quarta-feira, 11 de maio de 2016 07:59:38 PDT Lars Knoll wrote:
> Finally!
> We should certainly turn it on for Qt. 
> User code is a bit more sensitive. What are we currently doing on the other
> compilers? Are we assuming utf8 as the input encoding by default? If yes,
> we should aim for consistency and turn it on for user code on msvc2015 as
> well, but there should be an option to disable it and we'd need to clearly
> document this in the Changelog. 

GCC and Clang on Unix systems already operate like this new MSVC option. They 
do that irrespective of what your locale settings are: sources are assumed to 
be UTF-8, period.

But unlike MSVC now, they only complain about non-UTF8 code if they are 
required to convert/validate it. MSVC is documented to convert to Unicode as 
it parses, so it may fail to compile even where non-UTF8 is found in regular, 
narrow character literals.

If you take the code from the OP and convert to Latin1, then compile, you'll 
get errors. GCC complains about the u and L literals:

error: converting to execution character set: Invalid or incomplete multibyte 
or wide character

Clang complains about all four, with the first one (regular char) just a 
warning: illegal character encoding in string literal [-Winvalid-source-
error: illegal character encoding in string literal

Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center

More information about the Development mailing list