I managed to read the text file byte by byte and to change the charset from windows-1251 to Unicode for a file loaded from the end user's computer via an input element and FileReader. Now I want to do the same thing for a file from my server, via fetch. Is it possible to do that? (The fetch would be in a page served via HTTP and the URL would be relative, e.g. fetch("raw/graph_tab.txt") — I'm not trying to read a file directly from the end user's machine as I was with an input field and FileReader).
Chunks of working code ('windows-1251.js' library is created by Mathias Bynens):
<input type="file" id="file"/>
<script type="text/javascript">
document.getElementById("file").addEventListener("change", readFile, false);
function readFile (evt) {
var files = evt.target.files;
var file = files[0];
var reader = new FileReader();
reader.onload = function(event) {
console.log(windows1251.decode(event.target.result));
}};