当我们不能,VS如何检测文件编码? [英] How can VS detect file encoding when we can't?
问题描述
VS如何做?如果我另存为,并选择使用编码保存,它将显示我的文件的当前编码。
默认情况下,编辑器通过搜索字节顺序标记或字符集标签来检测编码。如果在当前文档中没有找到,代码编辑器会尝试通过扫描字节序列自动检测UTF-8编码。 VS帮助
如果VS无法转换任何字节序列到有效的unicode符号,它以默认系统字符集打开文件。没有魔法的真实。
According to several answers here on SO, eg. 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? 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. VS Help
If VS fails to convert any byte sequences to valid unicode symbols, it opens file in default system character set. No magic realy.
这篇关于当我们不能,VS如何检测文件编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!