简体   繁体   English

我们不能在VS检测文件编码时如何?

[英]How can VS detect file encoding when we can't?

According to several answers here on SO, eg. 根据SO的几个答案,例如。 How can I detect the encoding/codepage of a text file it is not possible to retrieve the encoding of a file. 如何检测文本文件的编码/代码页,无法检索文件的编码。

How does VS do it then? VS怎么做呢? If I "Save as", and select "Save with encoding" it shows the current encoding of my file. 如果我“另存为”,并选择“使用编码保存”,则会显示我文件的当前编码。

By default, the editor detects encoding by searching for byte order marks or charset tags. 默认情况下,编辑器通过搜索字节顺序标记或字符集标记来检测编码。 If neither is found in the current document, the code editor attempts to auto-detect UTF-8 encoding by scanning byte sequences. 如果在当前文档中都找不到,则代码编辑器尝试通过扫描字节序列来自动检测UTF-8编码。 VS Help VS帮助

If VS fails to convert any byte sequences to valid unicode symbols, it opens file in default system character set. 如果VS无法将任何字节序列转换为有效的unicode符号,则会在默认系统字符集中打开文件。 No magic realy. 没有魔法真的。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM