Wrong text encoding of read local files
Simply use fetch
for example: fetch(url).then(r => r.text()).then(text => { console.log(text) })
Fetch doesnot work for me on local files
Yep, I forgot about that.
Well, you can override the encoding in XHR:
var xhr = new XMLHttpRequest();
xhr.open('GET', url);
xhr.overrideMimeType('text/plain; charset=UTF-8');
Hi,
As FileReader.readAsText(..., 'UTF-8'), as XHR return local content in forced singlebyte encoding, even for files saved in UTF-8, resulting in malformed words like "Meldinš", "bâtard" and similar.
I'd like to ask for a working method how to read local files in UTF8 the proper way. by setting concerned functions properly, or converting the charset ex-post, whatever works. Thanks for any ideas