0.0.5 • Published 10 years ago
smart-encoding-convert v0.0.5
smart-encoding-convert
Inspired by buffer-encoding, but with clearer interface and minConfidence support.
Install
npm install smart-encoding-convert
Usage
import fs from 'fs';
import convert from 'smart-encoding-convert';
var buf = fs.readFileSync('someFile');
var buf1 = convert(buf);
var buf2 = convert(buf, { minConfidence: 0.96, mightFrom: 'gb2312'});
var buf3 = convert(buf, { from: 'gb2312', to: 'utf-8' });convert: (buf: Buffer, opts: ConvertOptions) => BufferOptions
minConfidence: If jschardet detects a buffer with confidence less thanminConfidence, the detected encoding would be overridden by themightFromoptions. Default is0.96.mightFrom: If the detected confidence is less thanminConfidence, it will use this option as the incoming buffer's encoding. Default isutf-8.to: To which encoding the original buffer should convert. Default isutf-8.from: If present, there would be no auto-detect process and this option would be set as the incoming buffer's encoding. Default isundefined.