https://github.com/fabiospampinato/uint8-encoding
Uint8 encoding, a simple way to convert strings to Uint8Arrays and vice versa.
https://github.com/fabiospampinato/uint8-encoding
arraybuffer encoding uint8 uint8array
Last synced: 7 months ago
JSON representation
Uint8 encoding, a simple way to convert strings to Uint8Arrays and vice versa.
- Host: GitHub
- URL: https://github.com/fabiospampinato/uint8-encoding
- Owner: fabiospampinato
- License: mit
- Created: 2021-08-14T16:39:41.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-09-24T16:28:51.000Z (over 2 years ago)
- Last Synced: 2024-11-11T20:29:32.656Z (over 1 year ago)
- Topics: arraybuffer, encoding, uint8, uint8array
- Language: JavaScript
- Size: 6.84 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# 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
```sh
npm install uint8-encoding
```
## Usage
```ts
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