I'm trying to download part of text file by fetch with range header property. But I get corrupted character from fetch.
Here part of my text file:
Dalgalan sen de şafaklar gibi ey şanlı hilâl,
Olsun artık dökülen kanlarımın hepsi helâl;
Ebediyen sana yok, ırkıma yok izmihlâl:
Hakkıdır, hür yaşamış bayrağımın hürriyet;
Hakkıdır, Hakk’a tapan milletimin istiklâl!
and my javascript code is:
fetch("https://website.com/images/text.txt", {
headers: {
'content-type': 'text/plain;charset=UTF-8',
'range': 'bytes=17-202'
},
})
.then(response => {
if (response.ok) {
return response.text();
}
})
.then(response => {
console.log(response);
});
The result is:
�afaklar gibi ey şanlı hilâl;
Olsun artık dökülen kanlarımın hepsi helâl.
Ebediyen sana yok, ırkıma yok izmihlâl:
Hakkıdır, hür yaşamış bayrağımın hürriyet;
Hakkıd
As you can see the first character is unknown symbol, question mark, but it has to be ş.
I think non english charecters have 2 bytes so which are splited into. How can I solve this, thank you :)