项目作者: heldinz

项目描述 :
Plugin for gulp to convert files from one encoding to another.
高级语言: JavaScript
项目地址: git://github.com/heldinz/gulp-convert-encoding.git
创建时间: 2014-09-18T21:15:31Z
项目社区:https://github.com/heldinz/gulp-convert-encoding

开源协议:

下载


gulp-convert-encoding

NPM version Downloads Build Status Coveralls Status

Convert character encodings in gulp v4 using iconv-lite. Supports streams.

[!NOTE]
As of gulp v5, this plugin is redundant: gulp v5 includes native support for transcoding text files using iconv-lite.

You can migrate away from this plugin by passing from and to as options.encoding to src and dest respectively. The default encoding is utf8.

Install

  1. npm install --save-dev gulp-convert-encoding

Usage

  1. import gulp from 'gulp';
  2. import convertEncoding from 'gulp-convert-encoding';
  3. export default () =>
  4. gulp
  5. .src('src/file.txt')
  6. .pipe(convertEncoding({ from: 'latin1' }))
  7. .pipe(gulp.dest('dist'));

API

convertEncoding(options)

[!IMPORTANT]
You must provide one or both of the from and to options.
Supported encodings are listed on the iconv-lite wiki.

options

Type: object

from

Type: string
Default: utf8

The current character encoding.

to

Type: string
Default: utf8

The target character encoding.

iconv

Type: object
Default: { decode: {}, encode: {} }

Allows you to pass additional options (e.g. for BOM Handling) into iconv-lite.