Make git diff show UTF8 encoded characters properly

后端 未结 3 1283
轻奢々
轻奢々 2020-11-30 02:25

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 c

相关标签:
3条回答
  • 2020-11-30 02:49

    @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

    0 讨论(0)
  • 2020-11-30 02:53

    git log will be opened by less not vi.

    So you should set lang to less.

    $ export LESSCHARSET=utf-8 && git log

    0 讨论(0)
  • 2020-11-30 03:09

    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
    
    0 讨论(0)
提交回复
热议问题