git->进程->git 往返文本编码

发布于 2024-09-06 05:10:49 字数 1320 浏览 1 评论 0原文

我正在尝试编写一个实用程序来将代码从我们的自定义源代码管理迁移到 git。

旧系统中的“提交”消息被增量添加到项目路径中的文本文件中,因此我使用 git 将这些文件从一个版本到下一个版本进行比较,然后使用该差异作为提交消息。

不出所料,我在口音方面遇到了麻烦。

测试字符串是: éèàçüûöôëê

  1. 源文本文件是(记事本告诉我的)“ANSI”格式。
  2. 如果我在 msysgit 中进行比较,我会看到这个
  3. 当我使用相同的 diff 命令运行对 git 的 Process 调用时(请参阅 这个问题),我得到:
    1. ÚÞÓþ³1÷¶ÙÛ
    2. ����������StandardOutputEncoding = Encoding.UTF8,根据 这个问题。
    3. éèàçüûöôëêStandardOutputEncoding = Encoding.Default

到目前为止,一切都很好,但是如果我将 éèàçüûöôëê 作为提交消息发送回来,git 会告诉我 警告:提交消息不符合UTF-8。

有关如何使其正常工作的任何指示吗? 这个问题讨论在 StandardInput 上设置编码也是如此,但我的提交消息位于参数中,而不是输入的一部分。

(Git 还说我可以设置配置变量 i18n.commitencoding,但如果可以的话,我宁愿尊重 git 格式)

I'm trying to write a utility to migrate code from our custom source control to git.

The 'commit' messages in the old system were added incrementally to a text file in the project path, so I'm using git to diff these files from one version to the next, then using that diff as a commit message.

Unsurprisingly, I'm having trouble with accents.

The test string is: éèàçüûöôëê

  1. The source text file is (so Notepad tells me) in 'ANSI'.
  2. If I do a diff in msysgit, I see this <E9><E8><E0><E7><FC><FB><F6><F4><EB><EA>
  3. When I run a Process call to git with the same diff command (see this question), I get:
    1. ÚÞÓþ³¹÷¶ÙÛ
    2. ���������� with StandardOutputEncoding = Encoding.UTF8, per this question.
    3. éèàçüûöôëê with StandardOutputEncoding = Encoding.Default

So far, so Good, but if I send éèàçüûöôëê back as a commit message, git tells me Warning: commit message does not conform to UTF-8.

Any pointers as to how to get this working? This question talks about setting encoding on StandardInput too, but my commit message is in the arguments, not part of the input.

(Git also says I can set the config variable i18n.commitencoding, but I'd rather respect the git format if I can)

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

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

发布评论

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

评论(1

情丝乱 2024-09-13 05:10:49

看起来它与 .net 或 Process 甚至 git 无关。据我所知,无论如何都无法在 bash 中输入重音符号。

尽管有来自 git 的警告,但提交消息可以被其他工具(gitk)读取,所以也许一切都很好。

Looks like it's got nothing to do with .net or Process, or maybe even git. As far as I can tell, there's no way to type accents in bash anyway.

And in spite of the warnings from git, the commit messages are readable by other tools (gitk), so maybe all is well.

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