npm.io
2.0.1 • Published 1 year ago

uint8-encoding

Licence
MIT
Version
2.0.1
Deps
0
Size
3 kB
Vulns
0
Weekly
0
Stars
4

Uint8 Encoding

Uint8 encoding, a simple way to convert strings to Uint8Arrays and vice versa.

It's just a simple wrapper around TextEncoder and TextDecoder, but it provides a cleaner API and it handles nuances like the BOM character for you.

Install

npm install uint8-encoding

Usage

import U8 from 'uint8-encoding';

// Encoding

const raw = 'Hello 😃';
const encoded = U8.encode ( raw );
console.log ( encoded ); // => Uint8Array(10) [72, 101, 108, 108, 111,  32, 240, 159, 152, 131]

// Decoding

const decoded = U8.decode ( encoded );
console.log ( decoded ); // => 'Hello 😃'

License

MIT Fabio Spampinato

Keywords