isutf8

v4.0.1
Check if a Node.js Buffer or Uint8Array is UTF-8
charset utf-8 is utf is utf-8 is utf8 utf8 unicode is unicode text and 6 more...

NPM Version NPM Downloads Bundlephobia install size

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

License

MIT License

npm i isutf8

Metadata

  • MIT
  • >= 12
  • Denis Seleznev
  • released 8/27/2024

Downloads

Maintainers