吕君喜 406d880ac6 first há 3 anos atrás
..
prebuilds 406d880ac6 first há 3 anos atrás
src 406d880ac6 first há 3 anos atrás
LICENSE 406d880ac6 first há 3 anos atrás
README.md 406d880ac6 first há 3 anos atrás
binding.gyp 406d880ac6 first há 3 anos atrás
fallback.js 406d880ac6 first há 3 anos atrás
index.js 406d880ac6 first há 3 anos atrás
package.json 406d880ac6 first há 3 anos atrás

README.md

utf-8-validate

Version npm Build Status Windows Build

Check if a buffer contains valid UTF-8 encoded text.

Installation

npm install utf-8-validate --save-optional

The --save-optional flag tells npm to save the package in your package.json under the optionalDependencies key.

API

The module exports a single function which takes one argument.

isValidUTF8(buffer)

Checks whether a buffer contains valid UTF-8.

Arguments

  • buffer - The buffer to check.

Return value

true if the buffer contains only correct UTF-8, else false.

Example

'use strict';

const isValidUTF8 = require('utf-8-validate');

const buf = Buffer.from([0xf0, 0x90, 0x80, 0x80]);

console.log(isValidUTF8(buf));
// => true

License

MIT