问题:在vscode中使用arduino,编译还是操作,输出都是 乱码,如下:

解决办法:
在vscode的扩展目录,arduino扩展的util.js文件。如\extensions\vsciot-vscode.vscode-arduino-0.5.0-win32-x64\out\src\common\util.js
,其中0.5.0
是当前arduino扩展版本。
搜索”if (os.platform() === "win32") {
“,不同版本这块的代码有所不同,0.4版代码如下:
if (os.platform() === "win32") {
try {
const chcp = child_process.execSync("chcp.com");
codepage = chcp.toString().split(":").pop().trim();
}
catch (error) {
outputChannel_1.arduinoChannel.warning(`Defaulting to code page 850 because chcp.com failed.\
\rEnsure your path includes %SystemRoot%\\system32\r${error.message}`);
codepage = "850";
}
}
0.5版的代码如下:
if (os.platform() === "win32") {
codepage = getArduinoL4jCodepage(command.replace(/.exe$/i, ".l4j.ini"));
if (!codepage) {
try {
const chcp = child_process.execSync("chcp.com");
codepage = chcp.toString().split(":").pop().trim();
}
catch (error) {
outputChannel_1.arduinoChannel.warning(`Defaulting to code page 850 because chcp.com failed.\
\rEnsure your path includes %SystemRoot%\\system32\r${error.message}`);
codepage = "850";
}
}
}
将上面的代码注释掉

然后重启vscode就可以正常输出了。
