https://github.com/linusu/encode-utf8
Turn a string into an ArrayBuffer by using the UTF8 encoding
https://github.com/linusu/encode-utf8
Last synced: about 1 year ago
JSON representation
Turn a string into an ArrayBuffer by using the UTF8 encoding
- Host: GitHub
- URL: https://github.com/linusu/encode-utf8
- Owner: LinusU
- License: mit
- Created: 2017-10-31T12:03:56.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-06-16T12:53:08.000Z (about 4 years ago)
- Last Synced: 2025-04-10T04:41:01.602Z (about 1 year ago)
- Language: JavaScript
- Size: 37.1 KB
- Stars: 11
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Encode UTF8
Turn a string into an ArrayBuffer by using the UTF8 encoding.
## Installation
```js
npm install --save encode-utf8
```
## Usage
```js
import encodeUtf8 from 'encode-utf8'
console.log(encodeUtf8('Hello, World!'))
//=> ArrayBuffer { byteLength: 13 }
console.log(encodeUtf8('🐵 🙈 🙉 🙊'))
//=> ArrayBuffer { byteLength: 19 }
```
## API
### `encodeUtf8(input)`
- `input` (`string`, required)
- returns `ArrayBuffer` - an ArrayBuffer with the `input` string represented as UTF8 encoded data