I did the search, but only found ways to change the encoding for individual files. I want to start projects with the encoding already configured as UTF-8.
-
2For each each project it is possible with [EditorConfig](https://editorconfig.org/) including `charset = utf-8`, see https://stackoverflow.com/a/51716830/371 – Dave Anderson Aug 06 '18 at 23:26
4 Answers
I found two ways
Alternate
There is alternate way, please try it
Tools->Options->Environment->Documents
The last
If that can't you can try to save it as UTF-8, you can save as with advanced options

- 1
- 1

- 1,966
- 2
- 26
- 42
-
24This option has now been hidden under "Save As...", and then the arrow next to save! – Per Enström Feb 20 '18 at 08:38
-
2The "Save documents as Unicode" doesn't trigger when all of the characters in the file are available in the user's code page. So a file with just a couple common symbols, like a copyright sign or common mathematics symbols, will likely no get converted. – Adrian McCarthy Dec 10 '22 at 16:07
Visual Studio supports EditorConfig files (https://editorconfig.org/)
Visual Studio (VS2017 and later) searches for a file named '.editorconfig' in the directory containing your source files, or anywhere above this directory in the hierarchy. This file can be used to direct the editor to use utf-8. I use the following:
[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4
The [*]
line is a mask and means for all files - the scope of the commands can be reduced using e.g. [*.{h,cpp}]
There are further possibilities, particularly for C# files. Full details can be found at https://learn.microsoft.com/en-us/visualstudio/ide/create-portable-custom-editor-options?view=vs-2019

- 464
- 5
- 6
-
Nice that it's built in to VS and doesn't need a plugin. It works great for controlling the encoding (charset). A couple of the other settings are a little buggy. – Adrian McCarthy Dec 10 '22 at 16:04
It's possible to set the locale code page to 65001, and VS will save all files with utf-8. https://en.wikipedia.org/wiki/Unicode_in_Microsoft_Windows#UTF-8
But since it's a beta function, there will be some bugs.
also reference https://superuser.com/questions/1033088/is-it-possible-to-set-locale-of-a-windows-application-to-utf-8/1451686

- 31
- 3
Tools->Options->Text Editor->General

- 89
- 12
-
2Even in Visual Studio 2019, there isn't an UTF8-default-encoding. The closest option is "Auto-detect UTF-8 encoding without signature", which isn't the same. – César Rodriguez Sep 04 '21 at 15:04