diff --git a/lib/core/byte-data.js b/lib/core/byte-data.js index d562fcc9..a1e5db89 100644 --- a/lib/core/byte-data.js +++ b/lib/core/byte-data.js @@ -1,9 +1,13 @@ +const encodeUtf8 = require('encode-utf8') const Mode = require('./mode') function ByteData (data) { this.mode = Mode.BYTE - if (typeof (data) === 'string') { - this.data = new TextEncoder().encode(data) + if (typeof (data) === 'string' && typeof TextEncoder === 'undefined') { + this.data = encodeUtf8(data); + this.data = new Uint8Array(data) + } else if (typeof (data) === 'string') { + this.data = new TextEncoder().encode(data); } else { this.data = new Uint8Array(data) } diff --git a/package.json b/package.json index 6e97c936..66509e7a 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ }, "dependencies": { "dijkstrajs": "^1.0.1", + "encode-utf8": "^1.0.3", "pngjs": "^5.0.0", "yargs": "^15.3.1" },