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

Provide a separate configuration that can set the encoding of the console #202691

Closed
WittonBell opened this issue Jan 18, 2024 · 3 comments
Closed
Assignees
Labels
*duplicate Issue identified as a duplicate of another issue(s) *english-please Issue not using English info-needed Issue requires more information from poster translation-required-chinese-simplified

Comments

@WittonBell
Copy link

WittonBell commented Jan 18, 2024

I sumbitted a issue:#195446, set the windows console in settings.json:

"terminal.integrated.profiles.windows": {
    "Command Prompt": {
      "path": [
        "${env:windir}\\Sysnative\\cmd.exe",
        "${env:windir}\\System32\\cmd.exe"
      ],
      // CodeLLDB need it convert console codepage to show chinese corectly
      "args": ["/K chcp 65001>nul"],
      "icon": "terminal-cmd"
    },
  },
  "terminal.integrated.defaultProfile.windows": "Command Prompt",

when set the console args:"args": ["/K chcp 65001>nul"] or "args": ["/K chcp 65001"] or "args": ["/K", "chcp 65001"],execute the shell type task:

{
    "tasks": [
        {
            "label": "echo",
            "type": "shell",
            "command": "echo hello",
        }
    ],
    "version": "2.0.0"
}

An error message will appear: 'Incorrect parameter format -/d', due to a conflict between the Windows command parameters'/K 'and'/D ','/C '.

The '/K chcp 65001' parameter is set to solve the problem that the UTF8 Chinese characters output from the VSCode console are garbled in some cases. For example, some plugins used to debug C/C++ programs, but now Microsoft's official C/C++ plugins can normally output UTF8 Chinese characters in C/C++, but there are still many plugins that may not output normally. Therefore, setting the console code uniformly here is a relatively easy way, #19837 (comment) -This method is also mentioned.

However, after setting this parameter, if you want to run a Shell type task, the error mentioned above will be reported. This is because VSCode adds the '/d /c' parameter directly after executing the command:
image

I have studied the explanation of cmd and tried using the following command in this situation:
cmd /S /D /K "chcp 65001>nul&&echo Hello"
It can output normally.

image

So I have a suggestion that VSCode can intelligently perform some checks when executing Shell type tasks. If it finds that there are already '/K' parameters, it can make adjustments to the command.

It would be best to provide a separate configuration that can set the encoding of the console.

Thank you!

@VSCodeTriageBot VSCodeTriageBot added *english-please Issue not using English translation-required-chinese-simplified info-needed Issue requires more information from poster labels Jan 18, 2024
@VSCodeTriageBot
Copy link
Collaborator

感谢您创建此问题!

然而,由于您没有使用英语,我们很难进行处理。如果可能,请您将此问题描述修改为英文。请您直接编辑此问题,不要提交回复或新问题。

请注意,机器翻译服务通常无法处理用于讨论软件问题所需的技术性语言,所以我们推荐您寻找一位熟悉相关技术的人来协助翻译。

如果您无法做到,没有关系。此问题已经被标记为需要翻译,等待社区成员志愿进行翻译。


Thanks for creating this issue!

Unfortunately, as the description is not in English, it's hard for us to work on. If possible, please edit the original issue to be in English.

In our experience, automatic translation services are not able to handle the technical language needed to effectively communicate about software issues, so we recommend finding a human translator who is familiar with our technology to help.

Otherwise, we have marked this as needing translation and a community member may be able to help out.

@WittonBell WittonBell changed the title 建议对shell类型的task任务执行cmd命令进行一点智能检测 Suggest performing some intelligent detection on shell type tasks by executing cmd commands Jan 18, 2024
@WittonBell WittonBell changed the title Suggest performing some intelligent detection on shell type tasks by executing cmd commands Provide a separate configuration that can set the encoding of the console Jan 18, 2024
@deepak1556 deepak1556 assigned Tyriar and meganrogge and unassigned deepak1556 Jan 18, 2024
@meganrogge
Copy link
Contributor

/duplicate #169821

@VSCodeTriageBot VSCodeTriageBot added the *duplicate Issue identified as a duplicate of another issue(s) label Jan 18, 2024
@WittonBell
Copy link
Author

@meganrogge The focus of these two issues is different, and this would prefer a separate configuration to set the encoding for the Windows console.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
*duplicate Issue identified as a duplicate of another issue(s) *english-please Issue not using English info-needed Issue requires more information from poster translation-required-chinese-simplified
Projects
None yet
Development

No branches or pull requests

6 participants
@deepak1556 @Tyriar @WittonBell @meganrogge @VSCodeTriageBot and others