2017-07-07 08:02:58 +02:00
2017-02-03 18:14:33 +01:00
2017-03-03 14:52:33 +01:00
2017-02-06 10:55:36 +01:00
2017-02-06 10:55:36 +01:00
2017-05-31 09:25:23 +02:00
2017-05-31 09:25:23 +02:00
2015-01-29 11:01:10 +01:00
2016-11-10 16:14:42 +01:00
2017-07-07 08:02:58 +02:00

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.

Exceptions

Throws a TypeError exception if the first argument is not a buffer.

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%