Socket
Socket
Sign inDemoInstall

is-utf8

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Protect your apps from supply chain attacks

Install

is-utf8

Detect if a buffer is utf8 encoded.

    0.2.1latest
    GitHub
    npm

Version published
Maintainers
1
Weekly downloads
7,999,125
increased by3.95%

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 installs a GitHub app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the 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