Set execution character set for Visual C++ compiler

前端 未结 1 415
一整个雨季
一整个雨季 2021-01-26 06:36

Is it possible to set the execution character set for Visual C++ compiler?

Problem

When trying to convert an (UCN) string literal to a wide string, a

相关标签:
1条回答
  • 2021-01-26 07:02

    Since Visual Studio 2015 Update 2, it is possible to set the execution character set to UTF-8 using the compiler option /utf-8. Then the conversion of narrow string literals, that don't use u8, will work. This is because those string literals are then converted to UTF-8 instead of the system's codepage (which is the default behaviour of Visual C++ compiler).

    The option /utf-8 is a synonym for /source-charset:utf-8 and /execution-charset:utf-8. From the link above:

    In those cases where BOM-less UTF-8 files already exist or where changing to a BOM is a problem, use the /source-charset:utf-8 option to correctly read these files.

    Use of /execution-charset or /utf-8 can help when targeting code between Linux and Windows as Linux commonly uses BOM-less UTF-8 files and a UTF-8 execution character set.

    PS: Don't confuse this with the character set setting in the common project configuration page which only sets the Macros Unicode/MBCS (historical reasons).

    0 讨论(0)
提交回复
热议问题