vscode shellArgs.windows参数如何设置使得powershell终端字符集编码为UTF-8?

网上的大部分是这个答案:

"terminal.integrated.shellArgs.windows": ["-NoExit", "/c", "chcp 65001"]

如果你觉得不行,请用这个

"terminal.integrated.shellArgs.windows": ["chcp 65001", ";", "powershell", "-NoLogo"]

下面解释原因

 

如果你需要使用 tasks.json ,

而且里面需要用到 "type": "shell" ,那么他们是不兼容的,会显示这个 参数格式不正确 - -Command ,我当时的感觉是 搞死人了。

 

先解释下这个报错,你加了上面那个shellArgs后会自动带上一个 -Command -

然后执行tasks"type": "shell"时又会自动带上 -Command

最终的命令变成了 powershell chcp 65001 -Command - -Command "你的命令"

所以提示 参数格式不正确 - -Command

 

附:看powershell可用参数 powershell -?

补充一个简化版:

"terminal.integrated.shellArgs.windows": ["chcp 65001; powershell -NoLogo"]

 

VSCode的设置更新了,我跟进一版最新的

"terminal.integrated.profiles.windows": {
"powershell": {
"source": "PowerShell",
"args": ["chcp 65001; powershell -NoLogo"]
}
},
"terminal.integrated.defaultProfile.windows": "powershell",

posted @ 2022-04-20 10:13  Recco_Do  阅读(632)  评论(0)    收藏  举报