How to change source file encoding in csharp project (visual studio / msbuild machine)?

Is there a way to force VS to use Unicode always and not a weird ISO something?

I am working on winapp csproject using Visual Studio 2008 on Vista (Polish). The problem arises when I create a project on Win Server 2003 (English) - then the Polish diacritics will disappear.

I investigated that the problem was caused by the incorrect encoding of the source file. It appears that the source files do not use UTF-8 encoding.

+50
encoding visual-studio utf-8 localization
May 08 '09 at 2:30 p.m.
source share
3 answers

Problem: A compiler launched from the command line cannot process the source file due to international characters that I just added.

Solution: Save the source file explicitly in UTF-8 encoding to preserve international characters.

How:

  • open the problem file in Visual Studio.
  • From the File menu, select "Advanced save options"
  • in the field "Encoding" select "Unicode (UTF-8 ...").
  • click ok

You are configured. Try to please the assembly of the server and the rest of the team are waiting for the green.

+102
May 8 '09 at
source share

In the latest version of Visual Studio 2017, the interface has changed a little, and you need to select " File → Save [filename] As… Then in the dialog that opens, you can choose Save with Encoding…

enter image description here

+8
Nov 12 '18 at 9:28
source share

I had the same problems with the VS2015 vb.net project, and I decided to add it by adding the <CodePage>1250</CodePage> to your vbproj / csproj file. I did this after the <SchemaVersion> marker, rebuilt the project, and it worked for me. I had problems with Polish letters like ż, ą etc. You can also try UTF-8 - 65001, but I did not check if it works.

+2
Oct 27 '16 at 19:03
source share



All Articles