我正在使用 nodeJs npm fs模块使用utf-8 编码读取和写入文件。文件读写操作成功完成。但是当我在 Windows 写字板中打开文件时,摄氏度(°C)符号为(°C)。如果我在 VS 代码编辑器中打开相同的文件并且记事本摄氏度(°C)符号正确,则问题仅出在 Windows 写字板应用程序上。
这是节点 Js 中的文件写入代码。
var fs = require('fs');
let data="Temperature is 25°C";
fs.writeFile("./output.txt", data, 'utf8', function (err) {
if (err) {
console.error("Error while writing the output file");
} else {
console.log("File write operation done!");
}
});