彻底解决VSCode中文乱码问题

AisDaeun 12 2024-01-08

1、集成终端乱码

在settings.json中更改:

  "terminal.integrated.profiles.windows": {
    "Command Prompt": {
      "args": ["/K", "chcp 65001 > nul"],
      "icon": "terminal-cmd",
      "path": [
        "${env:windir}/Sysnative/cmd.exe",
        "${env:windir}/System32/cmd.exe"
      ]
    },
    "PowerShell": {
      "args": ["-NoExit", "/C", "chcp 65001 > nul"],
      "icon": "terminal-powershell",
      "source": "PowerShell"
    }
  }

但是这样还不够,使用Code Runner插件时仍然会乱码。

2、Code Runer乱码

在参数前添加:

  "code-runner.executorMap": {
    "c": "chcp 65001 > nul; cd $dir && clang -g -stdlib=libc \"$fileName\" -o $workspaceRoot\\build\\executable.exe && $workspaceRoot\\build\\executable.exe",
    "cpp": "chcp 65001 > nul; cd $dir && clang++ -g -stdlib=libc++ -std=c++14 -Wall \"$fileName\" -o $workspaceRoot\\build\\executable.exe && $workspaceRoot\\build\\executable.exe"
  }