1

when i push a package in nuget server (on a local TFS), it will corrupt file's encoding. of course if i open my index.cshtml in notepad it will show me utf-8 encoding but VS can't show unicode characters in run time and i have to open the cshtml file in notepad and saveAs it by utf-8 encoding.

Morteza
  • 103
  • 1
  • 8

1 Answers1

0

Do you mean that VS can not show the unicode characters correctly, but they can be showed correctly in VS after saving the file with utf-8 encoding?

In order to run UTF-8, you need a Byte Order Mark (BOM) sometimes called a signature. According to the description in this MSDN article:

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 try to recreate the nuget package in VS with the utf-8 encoding files, then publish it to the server, then try it again. While please note below things:

  • Use the UTF-8 character encoding for the *.nuspec

  • Do not save your *.nuspec files with a Byte Order Mark (BOM). A BOM is neither required nor recommended for UTF-8, because it can lead to several issues.

  • Specify the UTF-8 encoding in the first line of your *.nuspec files like so: <?xml version="1.0" encoding="utf-8"?>.

Also reference this thread: UTF-8 without BOM

Community
  • 1
  • 1
Andy Li-MSFT
  • 28,712
  • 2
  • 33
  • 55