奇思妙想 · 2024年 4月 14日 0

Visual Studio默认源代码编码格式?

57 次浏览

VS检测源代码编码格式优先级如下:

  • 默认情况下,Visual Studio 会检测文件开头的byte-order标记,以确定源文件是否采用Unicode 格式,例如 UTF-16 或 UTF-8.
  • 如果编译选项指定/utf-8 或 /source-charset 选项指定了编码,按照编译选项为准。
  • 如上两个都未找到,则假定源文件使用当前用户代码页(Code Page)中编码。

/utf-8 == /source-charset:utf-8 /execution-charset:utf-8

参考:/utf-8 (Set source and execution character sets to UTF-8) | Microsoft Learn