diff --git a/dist/cjs/utils/bufferedString.js b/dist/cjs/utils/bufferedString.js index 82f710a018f9771fe10335e2dcacd75d707d9062..f3cfa64cefa967d7a83c328e1abb9246135b067b 100644 --- a/dist/cjs/utils/bufferedString.js +++ b/dist/cjs/utils/bufferedString.js @@ -16,7 +16,7 @@ class NonBufferedString { constructor() { // fatal: true makes invalid byte sequences (e.g. a lead byte followed by a // non-continuation byte) throw instead of silently decoding to U+FFFD. - this.decoder = new TextDecoder("utf-8", { fatal: true }); + this.decoder = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }); // Pieces appended since the last toString(), not yet folded into `string`. this.pending = []; this.string = ""; @@ -66,7 +66,7 @@ class BufferedString { constructor(bufferSize) { // fatal: true makes invalid byte sequences (e.g. a lead byte followed by a // non-continuation byte) throw instead of silently decoding to U+FFFD. - this.decoder = new TextDecoder("utf-8", { fatal: true }); + this.decoder = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }); this.bufferOffset = 0; this.string = ""; this.byteLength = 0; diff --git a/dist/mjs/utils/bufferedString.js b/dist/mjs/utils/bufferedString.js index 0fb208d8615f5e20a086f75a37bef928b155c47c..0d8ca407d594d61798eca7f7253e1dfc1770d291 100644 --- a/dist/mjs/utils/bufferedString.js +++ b/dist/mjs/utils/bufferedString.js @@ -13,7 +13,7 @@ export class NonBufferedString { constructor() { // fatal: true makes invalid byte sequences (e.g. a lead byte followed by a // non-continuation byte) throw instead of silently decoding to U+FFFD. - this.decoder = new TextDecoder("utf-8", { fatal: true }); + this.decoder = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }); // Pieces appended since the last toString(), not yet folded into `string`. this.pending = []; this.string = ""; @@ -62,7 +62,7 @@ export class BufferedString { constructor(bufferSize) { // fatal: true makes invalid byte sequences (e.g. a lead byte followed by a // non-continuation byte) throw instead of silently decoding to U+FFFD. - this.decoder = new TextDecoder("utf-8", { fatal: true }); + this.decoder = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }); this.bufferOffset = 0; this.string = ""; this.byteLength = 0; diff --git a/src/utils/bufferedString.ts b/src/utils/bufferedString.ts index 482c7402899bb157249cfb7882d327b7d9477912..4e45ef5d5bd7ec66776ece54e917282441cededb 100644 --- a/src/utils/bufferedString.ts +++ b/src/utils/bufferedString.ts @@ -40,7 +40,7 @@ export interface StringBuilder { export class NonBufferedString implements StringBuilder { // fatal: true makes invalid byte sequences (e.g. a lead byte followed by a // non-continuation byte) throw instead of silently decoding to U+FFFD. - private decoder = new TextDecoder("utf-8", { fatal: true }); + private decoder = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }); // Pieces appended since the last toString(), not yet folded into `string`. private pending: string[] = []; private string = ""; @@ -90,7 +90,7 @@ export class NonBufferedString implements StringBuilder { export class BufferedString implements StringBuilder { // fatal: true makes invalid byte sequences (e.g. a lead byte followed by a // non-continuation byte) throw instead of silently decoding to U+FFFD. - private decoder = new TextDecoder("utf-8", { fatal: true }); + private decoder = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }); private buffer: Uint8Array; private bufferOffset = 0; private string = "";