
This is a collection of functions for working with TextDecoder and TextEncoder.
The encodeText function encodes a string into a Uint8Array.
import { encodeText } from '@aracna/core';
// will log Uint8Array(5) [104, 101, 108, 108, 111]
console.log(encodeText('hello'));The decodeText function decodes a buffer into a string.
import { decodeText } from '@aracna/core';
// will log "hello"
console.log(decodeText(new Uint8Array([104, 101, 108, 108, 111])));The getTextDecoder function returns a new TextDecoder or a stub if the environment does not support it.
import { getTextDecoder } from '@aracna/core';
// will log TextDecoder
console.log(getTextDecoder());The getTextEncoder function returns a new TextEncoder or a stub if the environment does not support it.
import { getTextEncoder } from '@aracna/core';
// will log TextEncoder
console.log(getTextEncoder());