The code:
var blob;
blob = new Blob(file, {
encoding: "UTF-8",
type: "text/plain;charset=UTF-8"
});
saveAs(blob, "" + this._id + ".html");
It's strange if I imput an — in the textarea the download file shows a — (on Chrome) even though I specified the encoding and charset as UTF-8 (both textarea and html file viewed in the same browser). What could be the problem?
The code:
var blob;
blob = new Blob(file, {
encoding: "UTF-8",
type: "text/plain;charset=UTF-8"
});
saveAs(blob, "" + this._id + ".html");
It's strange if I imput an — in the textarea the download file shows a — (on Chrome) even though I specified the encoding and charset as UTF-8 (both textarea and html file viewed in the same browser). What could be the problem?
Share Improve this question asked Aug 11, 2014 at 13:24 wycwyc 55.4k82 gold badges256 silver badges439 bronze badges 1-
What is
file
? What "textarea" shows the downloaded blob? – Bergi Commented Aug 11, 2014 at 13:49
1 Answer
Reset to default 5That means you didn't decode the downloaded file; UTF-8 will encode the em-dash as three bytes. That means to read the downloaded file, you need to tell your editor (or whatever tool you use to read the file) that the file content is encoded as UTF-8.