浏览代码

fix: add BOM and charset when making Blob

Yukun Guo 5 年之前
父节点
当前提交
3c291e06e2
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      src/main/frontend/handler/export.cljs

+ 2 - 2
src/main/frontend/handler/export.cljs

@@ -44,8 +44,8 @@
   [file-path]
   (when-let [repo (state/get-current-repo)]
     (when-let [content (db/get-file repo file-path)]
-      (let [data (js/Blob. (array content)
-                           (clj->js {:type "text/plain"}))]
+      (let [data (js/Blob. ["\ufeff" (array content)] ; prepend BOM
+                           (clj->js {:type "text/plain;charset=utf-8,"}))]
         (let [anchor (gdom/getElement "download")
               url (js/window.URL.createObjectURL data)]
           (.setAttribute anchor "href" url)