Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.27.0 cannot show Chinese characters on the console window's title #2738

Closed
1 task done
gdh1995 opened this issue Jul 8, 2020 · 2 comments
Closed
1 task done
Milestone

Comments

@gdh1995
Copy link

gdh1995 commented Jul 8, 2020

  • I was not able to find an open or closed issue matching what I'm seeing

Setup

  • Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
$ git --version --build-options

git version 2.27.0.windows.1.8.ga98b073ae2.20200618202904
cpu: x86_64
built from commit: a98b073ae2b993892641bb1eb6ce707cc673d9ad
sizeof-long: 4
sizeof-size_t: 8
  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
$ cmd.exe /c ver

Microsoft Windows [版本 10.0.19041.329]
  • What options did you set as part of the installation? Or did you choose the
    defaults?
# One of the following:
> type "C:\Program Files\Git\etc\install-options.txt"
> type "C:\Program Files (x86)\Git\etc\install-options.txt"
> type "%USERPROFILE%\AppData\Local\Programs\Git\etc\install-options.txt"
$ cat /etc/install-options.txt

I installed (unzipped) the portable x64 version to `D:\Git`
  • Any other interesting things about your environment that might be related
    to the issue you're seeing?

No

Details

  • Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other

Open bash.exe directly and then bash runs in a console window

PS1='$ '
echo -e '\[\e]0;123 测试\007\]'
  • What did you expect to occur after running these commands?

The console window should update the text on its title bar into "123 测试" (3 English numbers and 2 Chinese characters)

  • What actually happened instead?

The "测试" was converted into a mess (it seemed it was using a wrong coding page)

  • If the problem was occurring with a specific repository, can you provide the
    URL to that repository to help us with testing?

No repo related.

Further tests

Code analysis

iconv.exe can be used to work it around: the code below can make the title show Chinese characters as expected.

PS1='$ '
a=$(iconv.exe -f utf-8 -t gbk <<<测试)
echo -e '\[\e]0;123 '$a'\007\]'

This means my console accepts Chinese characters in the GBK encoding, but the msys2 runtime sent the UTF-8 version.

I think this is a bug of msys2 runtime, and it should do similar conversions as it has done when outputting characters to the console.

@dscho
Copy link
Member

dscho commented Jul 8, 2020

Hmm. It works here:
image

Also, the Portable Git defaults not to use Pseudo Console support. It is actually a bit obscure how to enable it (you have to create a file etc\git-bash.config containing the line MSYS=enable_pcon).

Maybe some of your environment variables have the answer to the riddle?

$ env | grep -e LANG -e TERM -e LC
LANG=en_US.UTF-8
TERM_PROGRAM=mintty
TERM_PROGRAM_VERSION=3.2.0
TERM=xterm

@gdh1995
Copy link
Author

gdh1995 commented Jul 8, 2020

Sorry the MinTTY is not my test environment. I used to call bash.exe from a CMD console: press Win+R, input "cmd.exe", press Enter, input "bash.exe" in the newly opened window and press Enter again. Or you can double click "usr\bin\bash.exe" in the file explorer.

I did apply my customized /etc folder when testing the bare msys-2.0.dll and bash.exe, but I think it doesn't affect the conclusion.

During my test, I added a line of fopen/fprintf/fclose to the call to SetConsoleTitleW in /usr/src/MSYS2-packages/msys2-runtime/src/msys2-runtime/winsup/cygwin/fhandler_console.cc#set_console_title, and no log files were created. Therefore I think this is because of the new APIs of Win10's console.

@gdh1995 gdh1995 changed the title v2.27.0 can now show Chinese characters on the console window's title v2.27.0 cannot show Chinese characters on the console window's title Aug 11, 2020
@dscho dscho added this to the Next release milestone Aug 27, 2020
dscho added a commit to git-for-windows/build-extra that referenced this issue Aug 28, 2020
A [bug](git-for-windows/git#2738) preventing
Unicode characters from being used in the window title of Git Bash
was fixed.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants