Package Exports
- isutf8
- isutf8/dist/index.esm.js
- isutf8/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (isutf8) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
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
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
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