Skip to content
Detect if a buffer is utf8 encoded.
JavaScript
Branch: master
Clone or download
Latest commit cc4c44c Dec 19, 2015
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE add license Dec 19, 2015
README.md Mininum amount of bytes is 4 Dec 19, 2015
ansi.txt change interface to a single function Sep 12, 2012
is-utf8.js change interface to a single function Sep 12, 2012
package.json publish to npm Dec 19, 2015
test.js change interface to a single function Sep 12, 2012
utf8.txt change interface to a single function Sep 12, 2012

README.md

#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
You can’t perform that action at this time.