JSPM

is-utf8

0.2.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 7629435
  • Score
    100M100P100Q257826F
  • License MIT

Detect if a buffer is utf8 encoded.

Package Exports

  • is-utf8

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (is-utf8) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

#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