utf8.js 427 B

12345678910111213
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.utf8 = void 0;
  4. exports.encode = encode;
  5. exports.decode = decode;
  6. const index_js_1 = require("../bytes/index.js");
  7. function encode(text) {
  8. return new TextEncoder().encode(text);
  9. }
  10. function decode(data) {
  11. return new TextDecoder("utf-8", { fatal: false }).decode((0, index_js_1.toUint8Array)(data));
  12. }
  13. exports.utf8 = { encode, decode };