gulp-convert-encoding
v4.0.0
Published
Convert character encodings using iconv-lite.
Downloads
8,440
Maintainers
Readme
gulp-convert-encoding
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
andto
asoptions.encoding
tosrc
anddest
respectively. The default encoding isutf8
.
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: 'latin1' }))
.pipe(gulp.dest('dist'));
API
convertEncoding(options)
[!IMPORTANT] You must provide one or both of the
from
andto
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
.