Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

gulp-convert-encoding

heldinz9.9kMIT4.0.0TypeScript support: included

Convert character encodings using iconv-lite.

character encoding, character decoding, charset, convert, decoding, encoding, encodings, gulp, gulpplugin, iconv, iconv-lite

readme

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

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 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.

changelog

Changelog

4.0.0 - 2024-11-17

Changed

  • Breaking: Require Node >= 18
  • Breaking: Require gulp v4
  • Breaking: Switch to ESM

Added

  • Add TypeScript type declarations
  • Add warning when from and to options are identical
  • Add warning when iconv option is of the wrong type

3.0.0 - 2022-11-11

Changed

  • Breaking: Require Node >= 14

Fixed

  • Fix broken README links

2.1.0 - 2020-04-03

Changed

  • Breaking: Require Node >= 10
  • Update dependencies

2.0.1 - 2018-11-27

Changed

  • Update dependencies

2.0.0 - 2018-09-23

Changed

1.0.0 - 2016-05-29

Changed

  • Update dependencies

Added

  • Add iconv option to allow passing options to iconv-lite, e.g. for BOM handling

0.0.3 - 2014-12-08

Fixed

  • Fix author and repository metadata in package.json
  • Fix Travis CI links in README

0.0.2 - 2014-10-06

Added

  • Add support for file streams

0.0.1 - 2014-09-19

Initial release with support for file buffers