koa2-note icon indicating copy to clipboard operation
koa2-note copied to clipboard

static-server的例子中,读取文件内容的编码不能写死为binary哦

Open zhanyuzhang opened this issue 6 years ago • 0 comments

/demo/static-server/util/file.js 里面有这样的一段代码 :

let content = fs.readFileSync(filePath, 'binary' )

其实,这里需要对文件类型进行判断的,因为中文使用 binary 读取出来会是乱码的。个人觉得只有是图片、视频等才有必要使用 binary 读取。其他的用 utf8 便可。

zhanyuzhang avatar Aug 15 '18 11:08 zhanyuzhang