vscode powershell中文乱码问题

1. powershell设置

  1)新建如下文件:C:\Users\用户名\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

  2)在文件中加入如下脚本

[Console]::OutputEncoding = [System.Text.Encoding]::Default
$OutputEncoding = [console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding

  3)重启powershell

 

2. vscode设置

  1)setting.json添加如下设置

    "files.encoding": "utf8",

    "java.jdt.ls.vmargs": "-Dfile.encoding=UTF-8",

    "spring-boot.ls.java.vmargs": ["-Dfile.encoding=UTF-8"],

    "java.debug.settings.vmArgs": "-Dfile.encoding=UTF-8",
"terminal.integrated.profiles.windows": {
    "PowerShell": {
      "source": "PowerShell",
      "overrideName": true,
      "args": ["-NoExit", "-file", "C:/Users/用户名/Documents/WindowsPowerShell/Microsoft.PowerShell_profile.ps1"],
      "icon": "terminal-powershell",
      "env": {
        "TEST_VAR": "value"
      }
    }
  },
 
  2)launch.json添加设置("vmArgs": "-Dfile.encoding=UTF-8"),如下所示:
{
    "configurations": [
        {
            "type": "java",
            "name": "Spring Boot-xxxxxApplication<xxxxx>",
            "request": "launch",
            "cwd": "${workspaceFolder}",
            "mainClass": "com.xxx.xxxx.xxxApplication",
            "projectName": "xxxxx",
            "args": "",
            "envFile": "${workspaceFolder}/.env",
            "vmArgs": "-Dfile.encoding=UTF-8"
        }
    ]
}

posted on 2023-08-28 14:09  叮糖小葱  阅读(774)  评论(0)    收藏  举报

导航