UNPKG

397 BMarkdownView Raw
1#utf8 detector
2
3Detect if a Buffer is utf8 encoded.
4It need The minimum amount of bytes is 4.
5
6
7```javascript
8 var fs = require('fs');
9 var isUtf8 = require('is-utf8');
10 var ansi = fs.readFileSync('ansi.txt');
11 var utf8 = fs.readFileSync('utf8.txt');
12
13 console.log('ansi.txt is utf8: '+isUtf8(ansi)); //false
14 console.log('utf8.txt is utf8: '+isUtf8(utf8)); //true
15```
16