似乎在开启windows的beta版,使用unicode utf-8之后,我在vscode中的gcc就会出现中文乱码了,但是只有报错信息会出现乱码。
这里放个图片示例

如图所示,绿色框部分就是正常出现的中文,蓝色框部分出现的就是乱码的中文信息。
这里考虑了很多原因:task.json 没有配置好,setting.json 没有配置好,输入输出的字符集不匹配,终端输出的字符集和vscode的字符集不匹配,系统环境变量中的语言设置 折腾了快一两个星期了,实在是走投无路,问题始终无法解决。
这里我把相关的内容设置和截图陈列出来
task.json:
{
"tasks": [
{
"type": "cppbuild",
"label": "gcc.exe build active file",
"command": "E:/MinGW/bin/gcc.exe",
"args": [
"-fdiagnostics-color=always",
"-fexec-charset=utf-8",
"-finput-charset=UTF-8",
"-g",
// "${file}",
"${fileDirname}\\*.c",
"-Wall",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"chcp":"65001",
"cwd": "E:/MinGW/bin"
},
"problemMatcher": [
"$gcc"
],
"group": {
"chcp":"65001",
"kind": "build",
"isDefault": true
},
"detail": "调试器生成的任务。"
}
],
"version": "2.0.0"
}
setting.json:
{
"workbench.colorTheme": "Default Dark+",
"C_Cpp.vcFormat.newLine.beforeOpenBrace.block": "sameLine",
"C_Cpp.vcFormat.space.pointerReferenceAlignment": "right",
"[c]": {
"editor.defaultFormatter": "ms-vscode.cpptools",
"files.encoding": "utf8"
},
"editor.defaultFormatter": "ms-vscode.cpptools",
"editor.formatOnType": true,
"C_Cpp.formatting": "vcFormat",
"code-runner.runInTerminal": true,
"[html]": {
"editor.defaultFormatter": "vscode.html-language-features"
},
"editor.formatOnSave": true,
"C_Cpp.vcFormat.indent.caseLabels": true,
"C_Cpp.vcFormat.indent.accessSpecifiers": true,
"C_Cpp.vcFormat.newLine.beforeOpenBrace.function": "newLine",
"C_Cpp.vcFormat.newLine.beforeOpenBrace.namespace": "sameLine",
"C_Cpp.vcFormat.newLine.beforeOpenBrace.type": "sameLine",
"C_Cpp.vcFormat.newLine.beforeOpenBrace.lambda": "sameLine",
"editor.fontLigatures": false,
"terminal.integrated.profiles.windows": {
"Command Prompt": {
"path": "C:\\Windows\\System32\\cmd.exe",
"args": ["-NoExit", "/K", "chcp 936"]
},
"PowerShell": {
"path": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
"args": ["-NoExit", "/K", "chcp 65001"]
}
},
"terminal.integrated.defaultProfile.windows": "Command Prompt",
"code-runner.executorMap": {
"javascript": "node",
"java": "cd $dir && javac $fileName && java $fileNameWithoutExt",
"c": "cd $dir && gcc *.c -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
"cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
"objective-c": "cd $dir && gcc -framework Cocoa $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
"php": "php",
"python": "python -u",
"perl": "perl",
"perl6": "perl6",
"ruby": "ruby",
"go": "go run",
"lua": "lua",
"groovy": "groovy",
"powershell": "powershell -ExecutionPolicy ByPass -File",
"bat": "cmd /c",
"shellscript": "bash",
"fsharp": "fsi",
"csharp": "scriptcs",
"vbscript": "cscript //Nologo",
"typescript": "ts-node",
"coffeescript": "coffee",
"scala": "scala",
"swift": "swift",
"julia": "julia",
"crystal": "crystal",
"ocaml": "ocaml",
"r": "Rscript",
"applescript": "osascript",
"clojure": "lein exec",
"haxe": "haxe --cwd $dirWithoutTrailingSlash --run $fileNameWithoutExt",
"rust": "cd $dir && rustc $fileName && $dir$fileNameWithoutExt",
"racket": "racket",
"scheme": "csi -script",
"ahk": "autohotkey",
"autoit": "autoit3",
"dart": "dart",
"pascal": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt",
"d": "cd $dir && dmd $fileName && $dir$fileNameWithoutExt",
"haskell": "runhaskell",
"nim": "nim compile --verbosity:0 --hints:off --run",
"lisp": "sbcl --script",
"kit": "kitc --run",
"v": "v run",
"sass": "sass --style expanded",
"scss": "scss --style expanded",
"less": "cd $dir && lessc $fileName $fileNameWithoutExt.css",
"FortranFreeForm": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
"fortran-modern": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
"fortran_fixed-form": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
"fortran": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
"sml": "cd $dir && sml $fileName"
},
"C_Cpp.loggingLevel": "Warning",
"code-runner.languageIdToFileExtensionMap": {
"bat": ".bat",
"powershell": ".ps1",
"typescript": ".ts"
},
"editor.tabSize": 4,
"files.autoGuessEncoding": true,
"files.encoding": "utf8bom",
"C_Cpp.default.cStandard": "c11",
"debug.onTaskErrors": "showErrors",
"code-runner.saveFileBeforeRun": true,
}
cmd终端字符集是 UTF-8

Powershell终端字符集是 UTF-8

vscode编码的字符集也是UTF-8

环境变量中,用户变量和环境变量我都加上了字符集的设置
