I made a script to edit my subtitles in my browser. not in text editors etc.. so i did everything and i am at the final stage of it, when i click the button 'save' to download my edited version, My browser automatically downloads the SRT file as expected, But however the subtitle is shown as 'Little Square Boxes' instead of the arabic text i wrote and edited..
What i see on VLC Video Player:
What i have in my SRT File:
1
00:00:05,796 --> 00:00:06,888
چیرۆكم پێ بڵێ
2
00:00:07,048 --> 00:00:08,265
چیرۆكم پێ بڵێ
3
00:00:08,424 --> 00:00:09,846
چیرۆكم پێ بڵێ
Code used to generate edited version of subtitle:
// Function to download data to a file
function download(data, filename, type) {
var file = new Blob([data], {type: type});
if (window.navigator.msSaveOrOpenBlob) // IE10+
window.navigator.msSaveOrOpenBlob(file, filename);
else { // Others
var a = document.createElement("a"),
url = URL.createObjectURL(file);
a.href = url;
a.download = filename;
document.body.appendChild(a);
a.click();
setTimeout(function() {
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
}, 0);
}
}
And then:
download(all_str,"anyth.srt","text/html")
The string all_str
is my new edited version of the subtitles.. all separated by new lines, just like the text editor version
The subtitle works with english and other languages except arabic
Things i have done to fix this:
text/html
to text/plain
and text/plain utf-8
and text/plain charset=utf-8
but didn't workI think this has to do something with the encoding type, something i missed or don't know? please fill me in
You're doing everything right, However most of our current operating systems run on Windows-1256.. I have tested your code with this unicode, it works with Arabic and Persian:
Just change:
text/plain;charset=windows-1256
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With