Bash not showing Chinese right in the title #9986

Closed
opened 2026-01-31 02:09:25 +00:00 by claunia · 11 comments
Owner

Originally created by @dxyzx0 on GitHub (Aug 4, 2020).

Environment

Windows build number: Microsoft Windows NT 10.0.18363.0
Windows Terminal version (if applicable): 1.1.2021.0

Any other software?
Git for windows `Git-2.28.0-64-bit.exe`

Steps to reproduce

install git for windows and add bash in settings.json profiles as the following stackoverflow page

    {
        "guid": "{00000000-0000-0000-ba54-000000000002}",
        "acrylicOpacity" : 0.75,
        "closeOnExit" : true,
        "colorScheme" : "Campbell",
        "commandline" : "\"%PROGRAMFILES%\\git\\usr\\bin\\bash.exe\" -i -l",
        "cursorColor" : "#FFFFFF",
        "cursorShape" : "bar",
        "fontFace" : "Consolas",
        "fontSize" : 10,
        "historySize" : 9001,
        "icon" : "%PROGRAMFILES%\\Git\\mingw64\\share\\git\\git-for-windows.ico",
        "name" : "Bash",
        "padding" : "0, 0, 0, 0",
        "snapOnInput" : true,
        "startingDirectory" : "%USERPROFILE%",
        "useAcrylic" : true
    },

Expected behavior

The title should be right instead of meaningless letters.

Actual behavior

The title is wrong when the path contains Chinese letters.
image
But in the bash terminal everything seems fine. I think it's an encoding and decoding problem, but I have no idea how to resolve it.

Originally created by @dxyzx0 on GitHub (Aug 4, 2020). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> <!-- This bug tracker is monitored by Windows Terminal development team and other technical folks. **Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues**. Instead, send dumps/traces to secure@microsoft.com, referencing this GitHub issue. If this is an application crash, please also provide a Feedback Hub submission link so we can find your diagnostic data on the backend. Use the category "Apps > Windows Terminal (Preview)" and choose "Share My Feedback" after submission to get the link. Please use this form and describe your issue, concisely but precisely, with as much detail as possible. --> # Environment ```none Windows build number: Microsoft Windows NT 10.0.18363.0 Windows Terminal version (if applicable): 1.1.2021.0 Any other software? Git for windows `Git-2.28.0-64-bit.exe` ``` # Steps to reproduce <!-- A description of how to trigger this bug. --> install git for windows and add bash in `settings.json` profiles as the [following stackoverflow page](https://stackoverflow.com/questions/56839307/adding-git-bash-to-the-new-windows-terminal) ``` { "guid": "{00000000-0000-0000-ba54-000000000002}", "acrylicOpacity" : 0.75, "closeOnExit" : true, "colorScheme" : "Campbell", "commandline" : "\"%PROGRAMFILES%\\git\\usr\\bin\\bash.exe\" -i -l", "cursorColor" : "#FFFFFF", "cursorShape" : "bar", "fontFace" : "Consolas", "fontSize" : 10, "historySize" : 9001, "icon" : "%PROGRAMFILES%\\Git\\mingw64\\share\\git\\git-for-windows.ico", "name" : "Bash", "padding" : "0, 0, 0, 0", "snapOnInput" : true, "startingDirectory" : "%USERPROFILE%", "useAcrylic" : true }, ``` # Expected behavior <!-- A description of what you're expecting, possibly containing screenshots or reference material. --> The title should be right instead of meaningless letters. # Actual behavior <!-- What's actually happening? --> The title is wrong when the path contains Chinese letters. ![image](https://user-images.githubusercontent.com/28868457/89278272-770d4780-d678-11ea-80aa-7f08e77e2da9.png) But in the bash terminal everything seems fine. I think it's an encoding and decoding problem, but I have no idea how to resolve it.
claunia added the Needs-TriageIssue-BugArea-VTResolution-ExternalPriority-2 labels 2026-01-31 02:09:25 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Aug 4, 2020):

I'm sorry if I'm missing this but what is the title actually supposed to be? like, what is it in the git bash window?

Is the title just being truncated? Maybe setting "tabWidthMode": "titleLength" might help?

@zadjii-msft commented on GitHub (Aug 4, 2020): I'm sorry if I'm missing this but what is the title actually supposed to be? like, what is it in the git bash window? Is the title just being truncated? Maybe setting [`"tabWidthMode": "titleLength"`](https://docs.microsoft.com/en-us/windows/terminal/customize-settings/global-settings#tab-width-mode) might help?
Author
Owner

@dxyzx0 commented on GitHub (Aug 4, 2020):

Sorry, it's an encoding problem. The title is not meaningful Chinese letters. 


该邮件从移动设备发送

--------------原始邮件--------------
发件人:"Mike Griese "<notifications@github.com>;
发送时间:2020年8月4日(星期二) 晚上7:16
收件人:"microsoft/terminal" <terminal@noreply.github.com>;
抄送:"DingXiangYuanZhiXing "<151120093@smail.nju.edu.cn>;"Author "<author@noreply.github.com>;
主题:Re: [microsoft/terminal] Bash not showing Chinese right in the title (#7172)

I'm sorry if I'm missing this but what is the title actually supposed to be? like, what is it in the git bash window?

Is the title just being truncated? Maybe setting "tabWidthMode": "titleLength" might help?

@dxyzx0 commented on GitHub (Aug 4, 2020): Sorry, it's an encoding problem. The title is not meaningful Chinese letters.&nbsp; ---------- 该邮件从移动设备发送 --------------原始邮件-------------- 发件人:"Mike Griese "<notifications@github.com&gt;; 发送时间:2020年8月4日(星期二) 晚上7:16 收件人:"microsoft/terminal" <terminal@noreply.github.com&gt;; 抄送:"DingXiangYuanZhiXing "<151120093@smail.nju.edu.cn&gt;;"Author "<author@noreply.github.com&gt;; 主题:Re: [microsoft/terminal] Bash not showing Chinese right in the title (#7172) ----------------------------------- I'm sorry if I'm missing this but what is the title actually supposed to be? like, what is it in the git bash window? Is the title just being truncated? Maybe setting "tabWidthMode": "titleLength" might help?
Author
Owner

@dxyzx0 commented on GitHub (Aug 4, 2020):

In the bash shell the path is correct but I don't want reveal my company name. It's not the length.


该邮件从移动设备发送

--------------原始邮件--------------
发件人:"Mike Griese "<notifications@github.com>;
发送时间:2020年8月4日(星期二) 晚上7:16
收件人:"microsoft/terminal" <terminal@noreply.github.com>;
抄送:"DingXiangYuanZhiXing "<151120093@smail.nju.edu.cn>;"Author "<author@noreply.github.com>;
主题:Re: [microsoft/terminal] Bash not showing Chinese right in the title (#7172)

I'm sorry if I'm missing this but what is the title actually supposed to be? like, what is it in the git bash window?

Is the title just being truncated? Maybe setting "tabWidthMode": "titleLength" might help?

@dxyzx0 commented on GitHub (Aug 4, 2020): In the bash shell the path is correct but I don't want reveal my company name. It's not the length. ---------- 该邮件从移动设备发送 --------------原始邮件-------------- 发件人:"Mike Griese "<notifications@github.com&gt;; 发送时间:2020年8月4日(星期二) 晚上7:16 收件人:"microsoft/terminal" <terminal@noreply.github.com&gt;; 抄送:"DingXiangYuanZhiXing "<151120093@smail.nju.edu.cn&gt;;"Author "<author@noreply.github.com&gt;; 主题:Re: [microsoft/terminal] Bash not showing Chinese right in the title (#7172) ----------------------------------- I'm sorry if I'm missing this but what is the title actually supposed to be? like, what is it in the git bash window? Is the title just being truncated? Maybe setting "tabWidthMode": "titleLength" might help?
Author
Owner

@zadjii-msft commented on GitHub (Aug 4, 2020):

Okay well, maybe we can try and debug a test string that's not your company's name?

In every shell, you can set the tab title manually using a command - see this doc for details. Could you try executing those commands in each of their corresponding shells with some test string that has meaningful Chinese in it, and see what the tab title ends up changing to? Maybe we can figure out if this problem is local to git bash or if it's something lower down in the stack.

@zadjii-msft commented on GitHub (Aug 4, 2020): Okay well, maybe we can try and debug a test string that's not your company's name? In every shell, you can set the tab title manually using a command - see [this doc](https://docs.microsoft.com/en-us/windows/terminal/tutorials/tab-title#set-the-shells-title) for details. Could you try executing those commands in each of their corresponding shells with some test string that has meaningful Chinese in it, and see what the tab title ends up changing to? Maybe we can figure out if this problem is local to git bash or if it's something lower down in the stack.
Author
Owner

@dxyzx0 commented on GitHub (Aug 4, 2020):

@zadjii-msft I have tested in 3 shells. The command works in Powershell and CMD but not in Git Bash.

  • $Host.UI.RawUI.WindowTitle = "你好,中国" works well in powershell.
  • TITLE "你好,中国" works well in cmd BUT it shouldn't include double quote "". It should be TITLE 你好,中国, otherwise there will be "" in the title like this.
    image
  • In git bash, both echo -ne "\033]0;你好,中国\a" and PS1=$ PROMPT_COMMAND= echo -ne "\033]0;你好,中国\a" DO NOT work for Chinese. Nothing happened after the command. But it works for English letters.
    image
@dxyzx0 commented on GitHub (Aug 4, 2020): @zadjii-msft I have tested in 3 shells. The command works in Powershell and CMD but not in Git Bash. * `$Host.UI.RawUI.WindowTitle = "你好,中国"` works well in powershell. * `TITLE "你好,中国"` works well in cmd BUT it shouldn't include double quote `""`. It should be `TITLE 你好,中国`, otherwise there will be `""` in the title like this. ![image](https://user-images.githubusercontent.com/28868457/89290912-2a336c00-d68c-11ea-848f-08bd7dd45eb3.png) * In git bash, both `echo -ne "\033]0;你好,中国\a"` and `PS1=$ PROMPT_COMMAND= echo -ne "\033]0;你好,中国\a"` DO NOT work for Chinese. Nothing happened after the command. But it works for English letters. ![image](https://user-images.githubusercontent.com/28868457/89291526-471c6f00-d68d-11ea-8122-94ad5e450655.png)
Author
Owner

@zadjii-msft commented on GitHub (Aug 4, 2020):

Huh, it looks like it works in an Ubuntu tab for me: image

which when combined with the above, makes me think that this is a git bash specific problem. What is $LANG set to in git bash? (also check LC_ALL and LANGUAGE)

@zadjii-msft commented on GitHub (Aug 4, 2020): Huh, it looks like it works in an Ubuntu tab for me: ![image](https://user-images.githubusercontent.com/18356694/89296817-85cc0e00-d628-11ea-8d17-e60228f91a54.png) which when combined with the above, makes me think that this is a git bash specific problem. What is `$LANG` set to in git bash? (also check `LC_ALL` and `LANGUAGE`)
Author
Owner

@dxyzx0 commented on GitHub (Aug 4, 2020):

@zadjii-msft
image

@dxyzx0 commented on GitHub (Aug 4, 2020): @zadjii-msft ![image](https://user-images.githubusercontent.com/28868457/89300418-c19fbb80-d69a-11ea-8260-3df2caaca679.png)
Author
Owner

@zadjii-msft commented on GitHub (Aug 5, 2020):

Huh, that's definitely weird. From all I can tell, this is a git bash issue, not a Terminal one. I wonder why the mintty window (the default git bash terminal) works with this?

I guess I'll leave this open to try and debug further on our end. Thanks!

@zadjii-msft commented on GitHub (Aug 5, 2020): Huh, that's definitely weird. From all I can tell, this is a git bash issue, not a Terminal one. I wonder why the mintty window (the default git bash terminal) works with this? I guess I'll leave this open to try and debug further on our end. Thanks!
Author
Owner

@dxyzx0 commented on GitHub (Aug 5, 2020):

@zadjii-msft I tried in the Git Bash Mintty terminal and it works fine.

@dxyzx0 commented on GitHub (Aug 5, 2020): @zadjii-msft I tried in the Git Bash Mintty terminal and it works fine.
Author
Owner

@DHowett commented on GitHub (Aug 10, 2020):

I've got bad news! This works in the msys runtime shipped with git-2.27 but not in the one shipped with git-2.28. This is external.

@DHowett commented on GitHub (Aug 10, 2020): I've got bad news! This works in the msys runtime shipped with git-2.27 but not in the one shipped with git-2.28. This is external.
Author
Owner

@DHowett commented on GitHub (Aug 10, 2020):

msys is no longer setting the console codepage to 65001. Evidenced by running "cmd /s /c chcp 65001" before setting the title.

@DHowett commented on GitHub (Aug 10, 2020): msys is no longer setting the console codepage to 65001. Evidenced by running "cmd /s /c chcp 65001" before setting the title.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#9986