97

I have file names in UTF-8, git handles them O.K, it will create files properly and github pages also display it right. Except that it will display it in console like below. Is it possible to make git display UTF-8 encoded characters beyond ASCII 127 in console properly?

git status
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   .gitignore
#       modified:   editfile.js
#       modified:   "\321\203\321\201\321\202\320\260\320\275\320\276\320\262"
#
no changes added to commit (use "git add" and/or "git commit -a")

UPDATE

I have been asked about my locale, here is the output of locale command

LANG=en_US.UTF-8
LANGUAGE=
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=
Amedee Van Gasse
  • 7,280
  • 5
  • 55
  • 101
exebook
  • 32,014
  • 33
  • 141
  • 226

1 Answers1

183

git has always used octal utf8 display, and one way to show the actual name is by using printf in a bash shell.

According to this comment, this works even in a Windows msysgit bash, which does include printf (and can be used as in "How do I use octal characters in a git checkout?").

But that doesn't change the output of commands like git status or git ls-files. However, since Git 1.7.10 introduced the support of unicode, this wiki page mentions:

By default, git will print non-ASCII file names in quoted octal notation, i.e. "\nnn\nnn...". This can be disabled with:

 git config core.quotepath off

Or for all repositories using:

 git config --global core.quotepath off

Keep in mind that:

The default console font does not support Unicode. Change the console font to a TrueType font such as Lucida Console or Consolas.
The setup program can do this automatically, but only for the installing user.

Dave Jarvis
  • 30,436
  • 41
  • 178
  • 315
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 4
    See also [commit 3a59e59](https://github.com/git/git/commit/3a59e5954ef19ac94522219c2f29d49a187d31d8) (01 Jul 2015) by [Karsten Blees (`kblees`)](https://github.com/kblees). (Merged by [Junio C Hamano -- `gitster` --](https://github.com/gitster) in [commit 81bc521](https://github.com/git/git/commit/81bc521af22a6549e93d33e57de40d335e0ee65b), 03 Aug 2015) – VonC Aug 16 '15 at 19:07
  • I've change my `core.quotepath` to `off`. My `locale` is UTF-8 I use Git Bash on Windows 10, Git Bash's text font set to be Consolas. But my Japanese file name `初めに.txt` showed up as `σê¥πéüπü½.txt` Can you give it a look: https://gist.github.com/long-nguyenxuan/18c2e85bf29f1fb91cef0250bd5082ec/edit – Luke Aug 07 '20 at 10:10
  • 1
    @Luke Is is possible to include that gist content in a new separate question? Others will be able to answer it. Plus, gist.github.com is blocked at work, so I cannot properly give it a look. – VonC Aug 07 '20 at 10:13