Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
zhanyuzhang opened this issue Aug 15, 2018 · 0 comments

Comments

@zhanyuzhang
Copy link

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

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant