package
Check if a buffer contains valid UTF-8
npm install utf-8-validateGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Estimated unpacked size across 2 packages.
690.2 kB
Includes dependencies.
Check if a buffer contains valid UTF-8 encoded text.
npm install utf-8-validate --save-optionalThe --save-optional flag tells npm to save the package in your package.json
under the
optionalDependencies
key.
The module exports a single function that takes one argument. To maximize performance, the argument is not validated. It is the caller's responsibility to ensure that it is correct.
isValidUTF8(buffer)Checks whether a buffer contains valid UTF-8.
buffer - The buffer to check.true if the buffer contains only correct UTF-8, else false.
'use strict';
const isValidUTF8 = require('utf-8-validate');
const buf = Buffer.from([0xf0, 0x90, 0x80, 0x80]);
console.log(isValidUTF8(buf));
// => true