简体   繁体   English

Visual Studio自动生成文件开头的那些字符是什么?

[英]What are those characters at the beginning of Visual Studio auto-generated files?

When Visual Studio generates, eg, a C# source file, if you edit it in an ASCII text editor, you'll see something that looks like the following character sequence: 当Visual Studio生成例如C#源文件时,如果在ASCII文本编辑器中编辑它,您将看到类似于以下字符序列的内容:

 一世”

Deleting these bytes doesn't seem to harm anything, but why are they put there in the first place? 删除这些字节似乎没有任何损害,但为什么它们首先放在那里?

This is a byte order marker (BOM). 这是一个字节顺序标记(BOM)。 It is used to indicate the encoding of the file. 它用于指示文件的编码。

More info: 更多信息:

That is the Unicode Byte-Ordering-Mark (BOM). 这就是Unicode Byte-Ordering-Mark(BOM)。 I believe Visual Studio by default creates files in the UTF-8 encoding with BOM. 我相信Visual Studio默认使用BOM创建UTF-8编码的文件。 If you treat the UTF-8 BOM as ASCII, it will display those characters. 如果将UTF-8 BOM视为ASCII,它将显示这些字符。 http://en.wikipedia.org/wiki/Byte-order_mark http://en.wikipedia.org/wiki/Byte-order_mark

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 自动生成的代码在Visual Studio 2015中引发很多警告 - auto-generated code throw lots of warning in visual studio 2015 如何模拟Visual Studio自动生成的SOAP客户端? - How to mock SOAP client that was auto-generated by Visual Studio? 在 Visual Studio 中包含自动生成的静态内容 - Including auto-generated static content in Visual Studio 为什么 Visual-Studio 为一个应用程序自动生成 app.config 而不是另一个应用程序? - Why has Visual-Studio auto-generated app.config for one application but not for another? Visual Studio服务参考和自动生成的代理类-为什么不应该在您的类/项目中传递它们? - Visual Studio Service Reference, and Auto-Generated Proxy Classes - Why should they not be passed around your classes/projects? WPF中自动生成的代码显示错误。 (C#,WPF,Visual Studio社区2013) - Auto-generated code in WPF shows error. (C#, WPF, Visual Studio Community 2013) 自动生成的代码 - auto-generated Code 如何获取VC#来重建自动生成的.cs文件? - How to get VC# to rebuild auto-generated .cs files? SonarQube无法分析自动生成的目标框架绰号文件 - SonarQube failing to analyze auto-generated target framework moniker files 自动生成类的反序列化 - Deserialization of Auto-Generated Classes
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM