使 git diff 正确显示 UTF8 编码的字符 [英] Make git diff show UTF8 encoded characters properly

查看:40
本文介绍了使 git diff 正确显示 UTF8 编码的字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文件,其中包含用 UTF8 编码的瑞典语字符 (åäö).

I have a file with Swedish characters in it (åäö) encoded with UTF8.

如果我 cat 文件显示正常,但如果我执行 git diff 特殊字符被打印,例如,作为 <F6>.

If I cat the file it displays fine, but if I do git diff the special characters are printed, for example, as <F6>.

示例 git diff 输出:

-            name: 'Magler<F6>d, S<F6>der<E5>sen',

我想看到的:

-            name: 'Magleröd, Söderåsen',

我发现了另一个与 git 和编码问题相关的问题:git,msysgit,口音,utf-8,最终答案它说所有问题都应该在 git 版本 1.7.10 中修复.我有 1.8.1.2 版本

I found another question related to git and encoding problems: git, msysgit, accents, utf-8, the definitive answers It says all problems should be fixed in git version 1.7.10. I have version 1.8.1.2

我该怎么做才能让 git diff 正确显示 åäö?

What can I do to make git diff properly display åäö?

推荐答案

@matt 和 @twalberg 是正确的.该文件实际上不是 UTF-8 编码的.由于我的终端 (hterm) 无法正确输入 åäö(但它可以显示和复制/粘贴它们),试图弄清楚这一点并没有帮助...

@matt and @twalberg were correct. The file wasn't actually UTF-8 encoded. Trying to figure this out wasn't helped by the fact that my terminal (hterm) can't input åäö properly (but it can display and copy/paste them)...

iconv -f ISO-8859-1 -t UTF-8 in.txt > out_utf-8.txt

解决了我的问题

这篇关于使 git diff 正确显示 UTF8 编码的字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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