diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-07-31 13:04:16 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-31 13:04:16 -0400 |
commit | 454ffaad9658256cb4980ee27eb013606b285edc (patch) | |
tree | 85638439db117db833d15a0184ecd45b1f1a83b6 /ext/js/pages/settings/backup-controller.js | |
parent | 00c5ae79833a641ccc5f7d31b6eea3e91db4cb71 (diff) |
StringUtil (#1861)
* Add StringUtil class
* Use StringUtil
Diffstat (limited to 'ext/js/pages/settings/backup-controller.js')
-rw-r--r-- | ext/js/pages/settings/backup-controller.js | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/ext/js/pages/settings/backup-controller.js b/ext/js/pages/settings/backup-controller.js index 02ad368c..cf1a6b0c 100644 --- a/ext/js/pages/settings/backup-controller.js +++ b/ext/js/pages/settings/backup-controller.js @@ -18,6 +18,7 @@ /* global * DictionaryController * OptionsUtil + * StringUtil */ class BackupController { @@ -317,17 +318,8 @@ class BackupController { return warnings; } - _utf8Decode(arrayBuffer) { - try { - return new TextDecoder('utf-8').decode(arrayBuffer); - } catch (e) { - const binaryString = String.fromCharCode.apply(null, new Uint8Array(arrayBuffer)); - return decodeURIComponent(escape(binaryString)); - } - } - async _importSettingsFile(file) { - const dataString = this._utf8Decode(await this._readFileArrayBuffer(file)); + const dataString = StringUtil.arrayBufferUtf8Decode(await this._readFileArrayBuffer(file)); const data = JSON.parse(dataString); // Type check |