Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hcodes/isutf8
Quick check if a Node.js Buffer or Uint8Array is UTF-8
https://github.com/hcodes/isutf8
buffer javascript nodejs uint8array utf-8
Last synced: about 6 hours ago
JSON representation
Quick check if a Node.js Buffer or Uint8Array is UTF-8
- Host: GitHub
- URL: https://github.com/hcodes/isutf8
- Owner: hcodes
- License: mit
- Created: 2014-11-12T12:49:22.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2024-09-24T04:21:33.000Z (about 2 months ago)
- Last Synced: 2024-11-06T00:32:20.660Z (7 days ago)
- Topics: buffer, javascript, nodejs, uint8array, utf-8
- Language: TypeScript
- Homepage: https://www.npmjs.org/package/isutf8
- Size: 1.09 MB
- Stars: 21
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[![NPM Version](https://img.shields.io/npm/v/isutf8.svg?style=flat)](https://www.npmjs.org/package/isutf8)
[![NPM Downloads](https://img.shields.io/npm/dm/isutf8.svg?style=flat)](https://www.npmjs.org/package/isutf8)
[![Bundlephobia](https://badgen.net/bundlephobia/minzip/isutf8)](https://bundlephobia.com/result?p=isutf8)
[![install size](https://packagephobia.com/badge?p=isutf8)](https://packagephobia.com/result?p=isutf8)isutf8
======Quick check if a Node.js Buffer or Uint8Array is valid UTF-8.
## Advantages
- Ultra-small package size
- No dependencies
- No pre-compilation## Install
`npm install isutf8`## Usage
### CommonJS
```js
const isUtf8 = require('isutf8');const buf = Buffer.from([0xd0, 0x90]);
console.log(isUtf8(buf)); // => boolean// or
const arr = new Uint8Array([0xd0, 0x90]);
console.log(isUtf8(arr)); // => boolean```
### ES Modules or TypeScript
```js
import isUtf8 from 'isutf8';const buf = Buffer.from([0xd0, 0x90]);
console.log(isUtf8(buf)); // => boolean// or
const arr = new Uint8Array([0xd0, 0x90]);
console.log(isUtf8(arr)); // => boolean
```## License
[MIT License](./LICENSE)