最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - — character showing instead of em dash (—)? - Stack Overflow

programmeradmin4浏览0评论

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
Add a ment  | 

1 Answer 1

Reset to default 5

That 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.

发布评论

评论列表(0)

  1. 暂无评论