Can't fit file encoding when working with Chrome File System API

做~自己de王妃 提交于 2019-12-02 02:50:26
Xan

Problem is, your shifted text is no longer text by readAsText criteria. Trying to read it with any standard codepage is not going to work.

You should read the file as binary with readAsArrayBuffer(), interpret it as unsigned 8-bit int array, shift the bytes, and then convert the result to string.

var buf = new Uint8Array(reader.readAsArrayBuffer(file));
buf = buf.map((byte) => byte-65);
var string = new TextDecoder("ascii").decode(buf);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!