Is there any convenient way to modify the terminal's encoding? #21721

Closed
opened 2026-01-31 07:53:03 +00:00 by claunia · 5 comments
Owner

Originally created by @stdmkmehp on GitHub (May 15, 2024).

Description of the new feature/enhancement

When I use ssh to connect to remote server in terminal, it is frequent to switch encoding between gbk and utf-8. But it seams that there is no way to do it. This matter is causing me a lot of distress. Plz help me!

Proposed technical implementation details (optional)

Originally created by @stdmkmehp on GitHub (May 15, 2024). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 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! --> # Description of the new feature/enhancement When I use ssh to connect to remote server in terminal, it is frequent to switch encoding between gbk and utf-8. But it seams that there is no way to do it. This matter is causing me a lot of distress. Plz help me! <!-- A clear and concise description of what the problem is that the new feature would solve. Describe why and how a user would use this new functionality (if applicable). --> # Proposed technical implementation details (optional) <!-- A clear and concise description of what you want to happen. -->
claunia added the Issue-FeatureResolution-ExternalNeeds-Tag-Fix labels 2026-01-31 07:53:03 +00:00
Author
Owner

@lhecker commented on GitHub (May 15, 2024):

I'd love to help but can you please write more about what you mean? Ideas:

  • Are you trying to remotely connect to a Windows or Linux system?
  • How are you trying to switch the encoding?
  • What exactly breaks?
  • Can you give us steps so that we can reproduce your issue?
@lhecker commented on GitHub (May 15, 2024): I'd love to help but can you please write more about what you mean? Ideas: * Are you trying to remotely connect to a Windows or Linux system? * How are you trying to switch the encoding? * What exactly breaks? * Can you give us steps so that we can reproduce your issue?
Author
Owner

@stdmkmehp commented on GitHub (May 16, 2024):

I'm try to remotely connect to a Linux system which has env LC_ALL=C. When I do shell cmd with "cat file", the terminal shows garbled characters. The file is encoded with gbk,but it seams that terminal shows as utf-8.
To reproduce the issue, you can cat file_enc_with_gbk.txt. On my terminal, it comes with
image
Obviously it is not what i want.

I have used Xshell before, which can provide a dropdown menu to switch the terminal's encoding. If the file is encode with gbk, I just need switch the terminal's encoding to gbk. If the file is encode with utf-8, I just need switch the terminal's encoding to utf-8. Buf the Windows terminal seems take a default encoding utf-8, and do not support to switch.

file_enc_with_gbk.txt

@stdmkmehp commented on GitHub (May 16, 2024): I'm try to remotely connect to a Linux system which has env LC_ALL=C. When I do shell cmd with "cat file", the terminal shows garbled characters. The file is encoded with gbk,but it seams that terminal shows as utf-8. To reproduce the issue, you can cat file_enc_with_gbk.txt. On my terminal, it comes with ![image](https://github.com/microsoft/terminal/assets/23132434/f411b1ff-1f82-485c-866f-ab6062eb9469) Obviously it is not what i want. I have used Xshell before, which can provide a dropdown menu to switch the terminal's encoding. If the file is encode with gbk, I just need switch the terminal's encoding to gbk. If the file is encode with utf-8, I just need switch the terminal's encoding to utf-8. Buf the Windows terminal seems take a default encoding utf-8, and do not support to switch. [file_enc_with_gbk.txt](https://github.com/microsoft/terminal/files/15329820/file_enc_with_gbk.txt)
Author
Owner

@lhecker commented on GitHub (May 16, 2024):

I'm try to remotely connect to a Linux system which has env LC_ALL=C.

LC_ALL=C in practice tells your system that you want to use ASCII. At a minimum, I would recommend setting it to zh_CN.UTF-8 if possible, or some other variant, to get Unicode support. Of course there's also zh_CN.GBK if you really need GBK encoding anywhere, but I'd recommend against using GKB long term, because it's not Unicode which makes exchanging text difficult.

Buf the Windows terminal seems take a default encoding utf-8, and do not support to switch.

Not quite. You're right in that we don't support switching the encoding (codepage) via a setting. #15678 tracks this feature request. I think it makes sense for us to have such a setting, because Gnome Terminal, Apple's Terminal, and many others got it as well.

However, I believe your issue is because Windows' OpenSSH doesn't support switching the encoding. See here: https://github.com/PowerShell/Win32-OpenSSH/issues/1855#issuecomment-988977866 I can't imagine that this is an inherent limitation and I'm pretty sure support for other encodings could be added to OpenSSH. However, such work doesn't seem to be currently planned.

@lhecker commented on GitHub (May 16, 2024): > I'm try to remotely connect to a Linux system which has env LC_ALL=C. `LC_ALL=C` in practice tells your system that you want to use ASCII. At a minimum, I would recommend setting it to `zh_CN.UTF-8` if possible, or some other variant, to get Unicode support. Of course there's also `zh_CN.GBK` if you really need GBK encoding anywhere, but I'd recommend against using GKB long term, because it's not Unicode which makes exchanging text difficult. > Buf the Windows terminal seems take a default encoding utf-8, and do not support to switch. Not quite. You're right in that we don't support switching the encoding (codepage) via a setting. #15678 tracks this feature request. I think it makes sense for us to have such a setting, because Gnome Terminal, Apple's Terminal, and many others got it as well. However, I believe your issue is because Windows' OpenSSH doesn't support switching the encoding. See here: https://github.com/PowerShell/Win32-OpenSSH/issues/1855#issuecomment-988977866 I can't imagine that this is an inherent limitation and I'm pretty sure support for other encodings could be added to OpenSSH. However, such work doesn't seem to be currently planned.
Author
Owner

@carlos-zamora commented on GitHub (Jun 12, 2024):

Thanks for filing! Regarding what Leonard said above, we're going to close this as a /dup of https://github.com/PowerShell/Win32-OpenSSH/issues/1855.

@carlos-zamora commented on GitHub (Jun 12, 2024): Thanks for filing! Regarding what Leonard said above, we're going to close this as a /dup of https://github.com/PowerShell/Win32-OpenSSH/issues/1855.
Author
Owner

@microsoft-github-policy-service[bot] commented on GitHub (Jun 12, 2024):

Hi! We've identified this issue as a duplicate of one that exists on somebody else's Issue Tracker. Please make sure you subscribe to the referenced external issue for future updates. Thanks for your report!

@microsoft-github-policy-service[bot] commented on GitHub (Jun 12, 2024): Hi! We've identified this issue as a duplicate of one that exists on somebody else's Issue Tracker. Please make sure you subscribe to the referenced external issue for future updates. Thanks for your report! <!-- Policy app identification https://img.shields.io/static/v1?label=PullRequestIssueManagement. -->
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#21721