Skip to content

Commit cd6e2e2

Browse files
authored
fix: Support runtimes without ICU (#2331)
1 parent 6aaee14 commit cd6e2e2

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/util/utf8.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@
77
*/
88
var utf8 = exports,
99
replacementChar = "\ufffd",
10+
strictDecoder;
11+
12+
try {
1013
strictDecoder = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
14+
} catch (err) {
15+
// "fatal" option is not supported on Node.js compiled without ICU
16+
strictDecoder = new TextDecoder("utf-8", { ignoreBOM: true });
17+
}
1118

1219
/**
1320
* Calculates the UTF8 byte length of a string.

0 commit comments

Comments
 (0)