0.1.1 • Published 10 years ago

guess-encoding v0.1.1

Weekly downloads
1
License
MIT
Repository
github
Last release
10 years ago

Guess encoding

Guess encoding in an super fast speed!

Install

npm install guess-encoding

Example

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) {
    console.log(encode)
    // result:
    // { language: '', charset: 'UTF-8', confidence: 80 }
    // { language: 'es', charset: 'ISO-8859-1', confidence: 30 }
}

// start guessing
guess;

How it work

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 :)

License

MIT