Skip to content

heldinz/gulp-convert-encoding

Repository files navigation

gulp-convert-encoding

NPM version Downloads Build Status Coveralls Status

Convert character encodings using iconv-lite. Supports streams.

Install

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

Usage

import gulp from 'gulp';
import convertEncoding from 'gulp-convert-encoding';

export default () =>
	gulp
		.src('src/file.txt')
		.pipe(convertEncoding({ from: 'iso-8859-1' }))
		.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.