I am currently working on a small function that is meant to fetch the contents of an uploaded text file.
upload() {
let reader = new FileReader();
reader.onload = () => {
console.log(reader.result);
}
reader.readAsText(this.file);
}
Everything functions perfectly when the file uploaded is encoded in UTF8, but I encounter issues with my specific case where it is encoded in UTF16_LE. This results in random spacing between characters, some characters being changed to something different, or even transformed into Chinese characters.
So, my main inquiry is how can I convert reader.result
to UTF8 without the need to manually re-save the file to UTF8?