zandGitHub d6c8425956 Delete upstream workflows
This fork does not ship upstream's releases, and its hosted-runner jobs
never start here.

Claude-Session: https://claude.ai/code/session_01HuMDfgFssPUptYUzgZ6Cp8
2026-09-24 10:03:53 -07:00
2018-07-05 08:41:38 +02:00
2020-04-25 16:40:33 +02:00
2021-05-03 19:10:02 +02:00
2018-07-05 08:41:38 +02:00
2023-01-03 21:15:36 +01:00

utf-8-validate

Version npm Linux/macOS/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 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.

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

S
Description
Check if a buffer contains valid UTF-8
Readme MIT
244 KiB
Languages
JavaScript 70.9%
C++ 20.1%
Python 9%