smart-encoding-convert

0.0.5 • Public • Published

NPM Version Build Status

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) => Buffer

Options

  • minConfidence: If jschardet detects a buffer with confidence less than minConfidence, the detected encoding would be overridden by the mightFrom options. Default is 0.96.
  • mightFrom: If the detected confidence is less than minConfidence, it will use this option as the incoming buffer's encoding. Default is utf-8.
  • to: To which encoding the original buffer should convert. Default is utf-8.
  • from: If present, there would be no auto-detect process and this option would be set as the incoming buffer's encoding. Default is undefined.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.5
    1
    • latest

Version History

Package Sidebar

Install

npm i smart-encoding-convert

Weekly Downloads

1

Version

0.0.5

License

MIT

Last publish

Collaborators

  • soda