gpt4 book ai didi

c++ - VS2010不理解自己文件的字符串编码

转载 作者:行者123 更新时间:2023-11-30 02:46:00 24 4
gpt4 key购买 nike

我正在使用 VS2010 项目 Unicode,一切正常。当我删除我的本地文件并从源代码管理 (Perforce) 下载它的新拷贝时,resource.h 文件读取错误(中文)。

//{{no_dependencies}}}਍਍挀爀猀漀昀琀猀甀愀氀䌀最最攀渀攀爀愀琀攀搀攀//mydemo.rc使用的使用

为什么 VS2010 会那样做?我该如何解决?它本质上是一个相同的文件,但在打开一次实例和一个新实例时,它无法确定文件编码。

虽然这是 MFC 项目,但看起来与此问题无关。

最佳答案

这似乎是 Perforce 的 line ending conversion 的问题并且未能正确推断出 resource.h 的 UTF16 格式

按照步骤 here如果您将来遇到问题,可能会解决该问题:

Problem

On Windows, after syncing "text" (Perforce file type) files containing utf16 encoding, the file in my workspace seems corrupted.

Solution

As the utf16 character encoding is a double byte character encoding and Perforce treats "text" files as single byte, you may encounter rendering or corruption issues in a Windows environment. Windows line endings are not correctly converted within the UTF16 character set for "text" files. This corrupts the utf16 file content.

File revisions with utf16 content should always be submitted using the "utf16" file type (on add, Perforce will automatically detect utf16 files unless the user or a typemap rule overrides this behavior).

In order to fix your issue follow these steps:

  • Edit your workspace specification and change the value of the LineEnding field to "unix"
  • Force sync the file (no line ending conversion will be done)
  • Check that the workspace file is now rendered properly
  • Checkout the file(s), changing the file type to utf16 (change from "text" to "utf16")
  • Edit your workspace specification and change the value of the LineEnding field back to "local"
  • Submit a new revision of the file

Example:

p4 client bruno_ws
LineEnd: unix
p4 sync -f myfile.txt
p4 edit -t utf16 myfile.txt
p4 client bruno_ws
LineEnd: local
p4 submit -d "Fixing unicode file"

关于c++ - VS2010不理解自己文件的字符串编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23958154/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com