node package manager


guessing encoding in a quick speed

Guess encoding

Guess encoding in an super fast speed!

npm install guess-encoding
var guess = require('guess-encoding')
// first argument is the file you want to guess 
// and the callback function will pass the result of the guessing and second argument is the buffer :) 
var guess = guess('./test/100000.csv', cb);
function cb(encode, chunk) {
    // result: 
    // { language: '', charset: 'UTF-8', confidence: 80 } 
    // { language: 'es', charset: 'ISO-8859-1', confidence: 30 } 
// start guessing 

Streaming the first chunk of data in memory and only detect for the first few buffer and detected the encoding. So this will work in super large files, cause we are not loading all the data from origin, only a few buffers :)