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: 3 months 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 (over 10 years ago)
- Default Branch: master
- Last Pushed: 2024-09-24T04:21:33.000Z (10 months ago)
- Last Synced: 2025-03-29T05:08:13.995Z (4 months ago)
- Topics: buffer, javascript, nodejs, uint8array, utf-8
- Language: TypeScript
- Homepage: https://www.npmjs.org/package/isutf8
- Size: 1.09 MB
- Stars: 21
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://www.npmjs.org/package/isutf8)
[](https://www.npmjs.org/package/isutf8)
[](https://bundlephobia.com/result?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)