$ cnpm install isutf8
Quick check if a Node.js Buffer or Uint8Array is valid UTF-8.
npm install isutf8
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
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
Copyright 2013 - present © cnpmjs.org | Home |