utf8.js 281 B

12345678
  1. import { toUint8Array } from "../bytes/index.js";
  2. export function encode(text) {
  3. return new TextEncoder().encode(text);
  4. }
  5. export function decode(data) {
  6. return new TextDecoder("utf-8", { fatal: false }).decode(toUint8Array(data));
  7. }
  8. export const utf8 = { encode, decode };