vscode powershell中文乱码问题

发布时间 2023-08-28 14:12:37作者: 叮糖小葱

1. powershell设置

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

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

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

  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",
  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"
        }
    ]
}