Socket
Book a DemoInstallSign in
Socket

smart-encoding-convert

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

smart-encoding-convert

Auto detect and convert buffer encodings

latest
Source
npmnpm
Version
0.0.5
Version published
Maintainers
1
Created
Source

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.

FAQs

Package last updated on 19 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts