如何防止“svn diff”来自在 Windows 上生成 Unicode 输出

发布于 2024-09-11 03:13:31 字数 551 浏览 2 评论 0原文

在我的 Windows 机器上,我尝试使用命令 svn diff > 创建 Subversion 补丁; my_patch.diff。生成的文件是用 UTF-16 编码的,而不是 UTF-8 或 ASCII,因此当我尝试使用 patch (来自 GnuWin32) 来应用补丁,但没有成功。

我能够通过在记事本中打开补丁文件并将其保存为所需的格式来将其转换为 UTF8,之后 patch 处理得很好。但是,有没有办法让 svn diff 在 Windows 上生成 UTF8 呢?


更新:正如我的回答所示,事实证明该问题实际上与 Subversion、diffpatch 无关。 PowerShell 非常有帮助地将输出转换为 Unicode。我将问题按原样保留,以便有类似问题的人可能会偶然发现它。

On my Windows box, I tried to create a Subversion patch by using the command svn diff > my_patch.diff. The resulting file was encoded with UTF-16, rather than UTF-8 or ASCII, so when I tried to use patch (from GnuWin32) to apply the patch, it didn't work.

I was able to convert the patch file to UTF8 by opening it in Notepad and saving as the desired format, and patch handled it fine after that. But, is there a way to get svn diff to generate UTF8 on Windows?


Update: As my answer indicates, it turns out that the problem is really unrelated to Subversion, diff, or patch. It was PowerShell that was oh-so-helpfully converting the output to Unicode. I'm leaving the question as-is so that someone with a similar problem might stumble upon it.

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

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

发布评论

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

评论(1

烂柯人 2024-09-18 03:13:31

经过多次绞尽脑汁并尝试不同的 diff 实用程序后,我发现了这一点:

我是在 PowerShell 命令窗口中运行我的 svn diff 。 PowerShell 的输出重定向运算符将输出转换为Unicode

如果我运行 svn diff > my_patch.diff 在 cmd.exe shell 中,然后一切正常。

要在 PowerShell 中实现此功能,必须使用如下命令:

svn diff | out-file -encoding ascii my_patch.diff

我确信 Microsoft 中有人认为这种行为真的很棒。

After much head-scratching and experimenting with different diff utilities, I figured this out:

I was running my svn diff in a PowerShell command window. PowerShell's output redirection operators convert the output to Unicode.

If I run svn diff > my_patch.diff in a cmd.exe shell, then everything works fine.

To make this work in PowerShell, one must use a command like this:

svn diff | out-file -encoding ascii my_patch.diff

I'm sure there is somebody at Microsoft who thinks this behavior is really awesome.

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