为什么TortoiseHg认为Resource.h是二进制的?

发布于 2024-12-08 17:34:28 字数 378 浏览 0 评论 0原文

使用 Visual Studio 2010。我有一个 Resource.h 文件,TortoiseHg 认为该文件是二进制的,因此它不会在提交窗口中显示它的差异。我可以轻松地在文本编辑器中打开该文件,并看到它是纯文本。

我看到了一个相关的问题(为什么 Mercurial 认为我的 SQL 文件是二进制?)这表明它与文件编码有关。事实上,在 Notepad++ 中打开文件表明该文件位于“UCS-2 Little Endian”中。我该如何解决这个问题?显然,我不想打破 Visual Studio 的某些期望。

Using Visual Studio 2010. I have a resource.h file which TortoiseHg thinks is binary so it won't display a diff for it in the commit window. I can easily open the file in a text editor and see that it is plain text.

I saw a related question (Why does Mercurial think my SQL files are binary?) which suggests it has to do with file encoding. Indeed opening the file in Notepad++ says the file is in "UCS-2 Little Endian". How can I fix this? I, obviously, don't want to break some Visual Studio expectation.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

旧故 2024-12-15 17:34:28

仅出于显示目的,由于长期存在的 UNIX 约定,Mercurial 将所有包含 NUL 字节 的文件视为二进制文件。这几乎总是正确的.. 除了 UTF-16(以前称为 UCS-2).. 文件的一半是 NUL 字节!

在内部,Mercurial 始终将所有 文件视为二进制文件,因此此问题仅与我们是否尝试显示差异等问题相关。

所以你有两个选择:

  • 忽略它,Mercurial 会很好地工作
  • 使用 UTF-16 以外的编码

一些网络搜索“resource.h utf-16”表明如果你将此文件保存为 UTF-8,VS2010 会很好或 ASCII,这对于 C 源代码来说应该是完美的选择。

http://social.msdn.microsoft.com/Forums/en/vssetup/thread/aff0f96d-16e3-4801-a7a2-5032803c8d83

For display purposes only, Mercurial treats all files containing NUL bytes as binary due to long-standing UNIX convention. This is just about always right.. except for UTF-16 (formerly known as UCS-2).. where half your file is NUL bytes!

Internally, Mercurial treats all files as binary all the time, so this issue is only relevant for things like whether or not we try to display diffs.

So you have two options:

  • ignore it, Mercurial will work just fine
  • use an encoding other than UTF-16

Some web searched for "resource.h utf-16" suggest that VS2010 will be just fine if you save this file in UTF-8 or ASCII, which should be perfectly fine choices for C source code.

http://social.msdn.microsoft.com/Forums/en/vssetup/thread/aff0f96d-16e3-4801-a7a2-5032803c8d83

你曾走过我的故事 2024-12-15 17:34:28

尝试显式地将编码转换/更改为 UTF-8 / ASCII 并查看。您可以从 Notepad++ 的 Encoding 菜单中执行此操作(选择“以 UTF-8 编码”),

Visual Studio 将很好地处理 UTF-8 文件。

Try explicitly converting / changing the encoding to UTF-8 / ASCII and see. You can do that from Notepad++'s Encoding menu ( choose Encode in UTF-8)

Visual Studio will work with the UTF-8 file just fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文