diff options
-rw-r--r-- | op_crates/web/08_text_encoding.js | 19 |
1 files changed, 1 insertions, 18 deletions
diff --git a/op_crates/web/08_text_encoding.js b/op_crates/web/08_text_encoding.js index 1fda1a816..980de339c 100644 --- a/op_crates/web/08_text_encoding.js +++ b/op_crates/web/08_text_encoding.js @@ -4212,25 +4212,8 @@ class TextEncoder { encoding = "utf-8"; encode(input = "") { - input = String(input); // Deno.core.encode() provides very efficient utf-8 encoding - if (this.encoding === "utf-8") { - return core.encode(input); - } - - const encoder = new UTF8Encoder(); - const inputStream = new Stream(stringToCodePoints(input)); - const output = []; - - while (true) { - const result = encoder.handler(inputStream.read()); - if (result === "finished") { - break; - } - output.push(...result); - } - - return new Uint8Array(output); + return core.encode(String(input)); } encodeInto(input, dest) { if (!(dest instanceof Uint8Array)) { |