写入文件乱码
var request = require(“request”); var iconv = require(“iconv-lite”); var fs = require(“fs”);
request.get("http://shenzhen.jjshome.com/", {encoding: "binary"}, function (err, response, result) { var c = iconv.decode(new Buffer(result, ‘binary’), ‘utf8’); console.log(typeof c); //打印是正常的 fs.writeFileSync("1.html", result); //写入是乱码 });
乱码的问题我确实很晕, 网上看了很多文章还是很晕, 有木有什么文章系统讲解的了?