Socket
Socket
Sign inDemoInstall

is-utf8

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-utf8

Detect if a buffer is utf8 encoded.


Version published
Maintainers
1
Weekly downloads
7,331,344
decreased by-9.1%

Weekly downloads

Package description

What is is-utf8?

The is-utf8 npm package is a simple utility that allows you to check if a given buffer is valid UTF-8 encoded text. It is useful when you need to validate the encoding of text data in Node.js applications.

What are is-utf8's main functionalities?

Check if a buffer is UTF-8

This feature allows you to check if a buffer contains valid UTF-8 encoded text. The code sample demonstrates reading a file into a buffer and then using is-utf8 to check if the buffer is UTF-8.

const isUtf8 = require('is-utf8');
const fs = require('fs');

const buffer = fs.readFileSync('somefile.txt');
const isValidUtf8 = isUtf8(buffer);
console.log(isValidUtf8); // outputs true or false

Other packages similar to is-utf8

Readme

Source

#utf8 detector

Detect if a Buffer is utf8 encoded. It need The minimum amount of bytes is 4.

    var fs = require('fs');
    var isUtf8 = require('is-utf8');
    var ansi = fs.readFileSync('ansi.txt');
    var utf8 = fs.readFileSync('utf8.txt');
    
    console.log('ansi.txt is utf8: '+isUtf8(ansi)); //false
    console.log('utf8.txt is utf8: '+isUtf8(utf8)); //true

Keywords

FAQs

Last updated on 19 Dec 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc