Displaying Unicode in visual studio

2019-08-12 19:03发布

I've tried almost anything to display Unicode in Visual Studio 2013, C++.

Starting with:

cmd /K chcp 65001

to changing the 'Character Set' in visual studio.

I'll be glad to get some help, of what I should do.

1条回答
够拽才男人
2楼-- · 2019-08-12 19:09

In order to run UTF-8, you need a Byte Order Mark (BOM) sometimes called a signature.

Per the MSDN:

Unicode characters are now supported in identifiers, macros, string and character literals, and in comments. Universal character names are also now supported.

Unicode can be input into a source code file in the following encodings:

  • UTF-16 little endian with or without byte order mark (BOM)
  • UTF-16 big endian with or without BOM
  • UTF-8 with BOM

For the love of all things decent, do NOT use "UTF-8 with BOM!"

You can do what was done here and simply save the file you need by going to "Advanced Save Options" and selection "UTF-8 without BOM" (signature). This only works on a file by file basis, but there is a discussion about installing something called File Fix Encoding, which will take off the BOM on ALL files.

In other words -- you can only display UTF-8 on a file-by-file basis unless you install File Fix Encoding.

Hope this helps.

查看更多
登录 后发表回答