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

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

问题描述



如果我 cat 我有一个带有瑞典字符的文件(åäö),用UTF8编码。该文件显示正常,但如果我执行 git diff ,则打印特殊字符,例如< F6>。



示例 git diff 输出:

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

看到:

   - 名称:'Magleröd,Söderåsen',

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



我可以做什么来使git diff正确显示åäö?

解决方案

@matt和@twalberg是正确的。该文件实际上并不是UTF-8编码的。我的终端(hterm)无法正确输入(但是可以显示和复制/粘贴它们)...

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

解决了我的问题


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

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

Example git diff output:

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

What I wanted to see:

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

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

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

解决方案

@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

solved my issue

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

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