設定vscode終端cmd、powshell、cmder編碼為utf-8
- 用vscode遇到的一些問題
- 運行程式時終端cmd顯示的編碼設定為utf-8
- 運行程式時終端powshell顯示的編碼設定為utf-8
- cmder配置成utf-8
用vscode遇到的一些問題
用vscode寫c++程式時,debug除錯和直接運行在終端顯示的編碼格式不一樣,導致亂碼,要經常改右下角的編碼格式,非常麻煩,接下來提供幾種方法
運行程式時終端cmd顯示的編碼設定為utf-8
打開vscode,左上角檔案-首選項-設定,搜索框中搜 setting.json

然后點在setting.json 中編輯
將這段加入配置中
"terminal.integrated.shell.windows":"C:\\WINDOWS\\System32\\cmd.exe",
"terminal.integrated.shellArgs.windows": [ "/K chcp 65001 >nul"],
保存,重啟 一下vscode就好了
運行程式時終端powshell顯示的編碼設定為utf-8
和cmd的差不多
"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
"terminal.integrated.shellArgs.windows": ["-NoExit", "chcp 65001"],
保存重啟就好
cmder配置成utf-8
如果要用cmder做終端,目前官方給了兩種方法,一種是替代cmd的,另外一種是替代powershell的,首先介紹cmd怎樣弄,依舊是編輯setting.json檔案
"terminal.integrated.shell.windows": "cmd.exe",
"terminal.integrated.shellArgs.windows": [
"/K",
"%CMDER_ROOT%\\vendor\\init.bat"
],
然后在cmder存放目錄下找到vendor檔案夾,點進去,右鍵用記事本打開init.bat,在@echo off 后面添加 chcp 65001>nul 保存,重啟vscode就好了,

接下來是powershell的,同理
"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
"terminal.integrated.shellArgs.windows": [
"-ExecutionPolicy", "Bypass",
"-NoLogo", "-NoProfile", "-NoExit",
"-Command", ". '%CMDER_ROOT%\\vendor\\conemu-maximus5\\\\..\\\\profile.ps1'"
]
%CMDER_ROOT%為cmder的存放目錄,然后打開%CMDER_ROOT%\vendor\profile.ps1檔案,在最后添加
$OutputEncoding = [console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding
保存,重啟vscode就大功告成了,
如果在打開檔案后報錯警告:
Missing git support, install posh-git with 'Install-Module posh-git' and restart cmder.
以管理員方式打開powershell,輸入下面命令
Install-Module posh-git -AllowClobber
重啟vscode就好了
不過最好是調debug的編碼格式,可惜不知道怎么調
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/244344.html
標籤:區塊鏈
