Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
663 views
in Technique[技术] by (71.8m points)

encoding - Make git diff show UTF8 encoded characters properly

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 ????

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

git is dumping out raw bytes. In this case, it doesn't care what your file's encoding is. The highlighted <F6> you're seeing is coming from less, which is presumably configured as your PAGER. Try setting:

LESSCHARSET=UTF-8

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...