mirror of
https://github.com/hanzoai/utf-8-validate.git
synced 2026-09-24 17:03:57 +00:00
405720d38f1130a5146291502ae30a78993db323
github.com has no runner for hanzo-build-linux-amd64, so a caller under .github/workflows is a gate that can never be scheduled. This is the ~7-line caller on the plane that can (git.hanzo.ai git-runner fleet), pinned @v1. Co-authored-by: Hanzo Dev <[email protected]>
utf-8-validate
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
Languages
JavaScript
70.9%
C++
20.1%
Python
9%