Fix non-8bit string export problem

This commit is contained in:
Tusooa Zhu 2022-07-16 11:15:08 -04:00
commit 48c474ed3a
No known key found for this signature in database
GPG key ID: 7B467EDE43A08224
3 changed files with 9 additions and 1 deletions

View file

@ -1,9 +1,11 @@
import utf8 from 'utf8'
export const newExporter = ({
filename = 'data',
getExportedObject
}) => ({
exportData () {
const stringified = JSON.stringify(getExportedObject(), null, 2) // Pretty-print and indent with 2 spaces
const stringified = utf8.encode(JSON.stringify(getExportedObject(), null, 2)) // Pretty-print and indent with 2 spaces
// Create an invisible link with a data url and simulate a click
const e = document.createElement('a')