node-uchardet
Native uchardet Binding for Node
For more information on the native binding: https://www.freedesktop.org/wiki/Software/uchardet/
Install
via npm
npm install -S node-uchardet@icemanbeta/uchardet
via yarn
yarn add node-uchardet@icemanbeta/uchardet
Usage
Getting Started
CommonJS
const UChardet = require('uchardet');
const uchardet = new UChardet();
const charset = uchardet.detect('/path/to/file');
ES6
import * as UChardet from 'uchardet';
const uchardet = new UChardet();
const charset = uchardet.detect('/path/to/file');
API
detect(file)
-
file
[string]: Relative or absolute path to the file (Note: Relative path is resolved toprocess.cwd()
, resolve prior if this doesn't work for you)
Example:
const source = './test/resources/sample.ssa';
const charset = uchardet.detect(source);
console.log(charset);
// => TIS-620
version()
Example:
console.log(uchardet.version());
// => 0.0.6