当我们不能,VS如何检测文件编码? [英] How can VS detect file encoding when we can't?

查看:139
本文介绍了当我们不能,VS如何检测文件编码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据这里的几个答案,例如, 如何检测到的编码/代码页文本文件,无法检索文件的编码。



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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆