mirror of
https://github.com/denoland/deno.git
synced 2025-08-01 09:32:28 +00:00
Add ASCII support to TextDecoder
This commit is contained in:
parent
6cc89b9e27
commit
568ac0c902
2 changed files with 127 additions and 13 deletions
|
@ -48,6 +48,23 @@ test(function textDecoder2() {
|
|||
assertEqual(decoder.decode(fixture), "𝓽𝓮𝔁𝓽");
|
||||
});
|
||||
|
||||
test(function textDecoderASCII() {
|
||||
const fixture = new Uint8Array([0x89, 0x95, 0x9f, 0xbf]);
|
||||
const decoder = new TextDecoder("ascii");
|
||||
assertEqual(decoder.decode(fixture), "‰•Ÿ¿");
|
||||
});
|
||||
|
||||
test(function textDecoderErrorEncoding() {
|
||||
let didThrow = false;
|
||||
try {
|
||||
const decoder = new TextDecoder("foo");
|
||||
} catch (e) {
|
||||
didThrow = true;
|
||||
assertEqual(e.message, "The encoding label provided ('foo') is invalid.");
|
||||
}
|
||||
assert(didThrow);
|
||||
});
|
||||
|
||||
test(function textEncoder() {
|
||||
const fixture = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
||||
const encoder = new TextEncoder();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue