diff options
author | Tomohito Nakayama <nkym.tmht@gmail.com> | 2019-10-02 09:08:51 +0900 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-10-01 20:08:51 -0400 |
commit | a646c2a88505819e07b5b967b9f8afacbac5aeef (patch) | |
tree | 4ca7f99e29fc59c7efa1d16261579bb6bba6c4c9 /js/text_encoding_test.ts | |
parent | 75eeac03f31521dff1ef7db9ff2a9cb32a97b111 (diff) |
Implement ignoreBOM option of UTF8Decoder in text_encoding (#3040)
Diffstat (limited to 'js/text_encoding_test.ts')
-rw-r--r-- | js/text_encoding_test.ts | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/js/text_encoding_test.ts b/js/text_encoding_test.ts index 727424749..aaa9e6b9d 100644 --- a/js/text_encoding_test.ts +++ b/js/text_encoding_test.ts @@ -74,6 +74,32 @@ test(function textDecoder2(): void { assertEquals(decoder.decode(fixture), "𝓽𝓮𝔁𝓽"); }); +test(function textDecoderIgnoreBOM(): void { + // prettier-ignore + const fixture = new Uint8Array([ + 0xef, 0xbb, 0xbf, + 0xf0, 0x9d, 0x93, 0xbd, + 0xf0, 0x9d, 0x93, 0xae, + 0xf0, 0x9d, 0x94, 0x81, + 0xf0, 0x9d, 0x93, 0xbd + ]); + const decoder = new TextDecoder("utf-8", { ignoreBOM: true }); + assertEquals(decoder.decode(fixture), "𝓽𝓮𝔁𝓽"); +}); + +test(function textDecoderNotBOM(): void { + // prettier-ignore + const fixture = new Uint8Array([ + 0xef, 0xbb, 0x89, + 0xf0, 0x9d, 0x93, 0xbd, + 0xf0, 0x9d, 0x93, 0xae, + 0xf0, 0x9d, 0x94, 0x81, + 0xf0, 0x9d, 0x93, 0xbd + ]); + const decoder = new TextDecoder("utf-8", { ignoreBOM: true }); + assertEquals(decoder.decode(fixture), "ﻉ𝓽𝓮𝔁𝓽"); +}); + test(function textDecoderASCII(): void { const fixture = new Uint8Array([0x89, 0x95, 0x9f, 0xbf]); const decoder = new TextDecoder("ascii"); |