how to show different language characters in git log?

孤街浪徒 提交于 2019-12-01 00:04:40

Make sure that your system supports UTF-8 properly. Most Ubuntu and Fedora boxes do. If you are using terminal or ssh session, make sure that your ssh client is configured to use UTF-8 all the way. For example, if using putty, be sure to configure it to use UTF-8 encoding in preferences - it is not a default setting.

I have relatively old git version 1.7.7.6 on this Fedora 16 box, but it seems to work just fine, as long as I set my locale properly:

$ export LANG=en_US.UTF-8
$ git log
commit 40b8cb9fc58775826a511c5338370f7fd1454481
Author: some guy <someone@somesite.com>
Date:   Wed Jun 5 22:57:10 2013 -0700

welcome
привет
ヘッダのユー

It still works the same if I set locale to Japanese:

$ export LANG=ja_JP.UTF-8
$ git log
commit 40b8cb9fc58775826a511c5338370f7fd1454481
Author: some guy <someone@somesite.com>
Date:   Wed Jun 5 22:57:10 2013 -0700

welcome
привет
ヘッダのユー

But it breaks if I set locale to Posix (C):

$ export LANG=C
$ git log
commit 40b8cb9fc58775826a511c5338370f7fd1454481
Author: some guy <someone@somesite.com>
Date:   Wed Jun 5 22:57:10 2013 -0700

welcome
<D0><BF><D1><80><D0><B8><D0><B2><D0><B5><D1><82>
<E3><83><98><E3><83><83><E3><83><80><E3><81><AE><E3><83><A6><E3><83><BC>

For reference, this is what working locale should look like:

$ locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!