isutf8

Check if a Node.js Buffer or Uint8Array is UTF-8

MIT 21 个版本
安装
npm install isutf8
yarn add isutf8
pnpm add isutf8
bun add isutf8
README

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

版本列表
4.0.1 2024-08-27
4.0.0 2021-10-31
3.1.1 2020-09-24
3.1.0 2020-09-23
3.0.0 2020-05-09
2.1.0 2019-08-29
2.0.4 2019-06-08
2.0.3 2019-01-16
2.0.2 2018-01-08
2.0.1 2017-03-09
2.0.0 2016-05-28
1.0.11 2015-02-23
1.0.10 2014-12-03
1.0.9 2014-11-22
1.0.8 2014-11-17
1.0.7 2014-11-14
1.0.6 2014-11-13
1.0.5 2014-11-13
1.0.3 2014-11-12
1.0.2 2014-11-12
1.0.1 2014-11-12