# gulp-charset

> Convert text encoding and replace charset code

Latest version **0.0.3** (published 2015-08-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install gulp-charset
pnpm add gulp-charset
yarn add gulp-charset
bun add gulp-charset
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2015-08-17 |
| First published | 2015-08-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.10.0 |
| Dependencies | 4 |
| Known vulnerabilities | 0 (+5 in 1 direct dependencies) |
| Install scripts | no |
| Author | Marty |
| Maintainers | yamoo |
| Keywords | gulpplugin, charset, encoding, iconv |

## Links

- npm: https://www.npmjs.com/package/gulp-charset
- npm.io page: https://npm.io/package/gulp-charset

## Dependencies (4)

- [lodash](https://npm.io/package/lodash.md) ^3.10.1
- [through2](https://npm.io/package/through2.md) ^2.0.0
- [gulp-util](https://npm.io/package/gulp-util.md) ^3.0.6
- [iconv-lite](https://npm.io/package/iconv-lite.md) ^0.4.11

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads
- [datasets-fi-postalcodes](https://npm.io/package/datasets-fi-postalcodes.md) — 1.1K weekly downloads

## Recent versions

- 0.0.3 (latest) — 2015-08-17
- 0.0.2 — 2015-08-04
- 0.0.1 — 2015-08-04

## README

# gulp-charset

> Convert text encoding and replace charset code

## Overview
This is a Gulp plugin for converting charset of multiple file types.

* This plugin a remake of [grunt-charset](https://github.com/rakuten-frontend/grunt-charset).

## Getting Started

```shell
npm install gulp-charset --save-dev
```

## Usage

```js
var gulp = require('gulp');
var charset = require('gulp-charset');

gulp.task('default', function() {
  return gulp.src(['./src/**'])
    .pipe(charset())
    .pipe(gulp.dest('./out'));
});
```

### Options

#### from
Type: 'String'
Default: `UTF-8`

Encoding of source charset.
Supported encodings are same as [iconv-lite](https://github.com/ashtuchkin/iconv-lite#supported-encodings) module.

#### to
Type: 'String'
Default: `Shift_JIS`

Encoding of output charset. This also depends on iconv-lite.

#### fileTypes
Type: 'Object'
Default: (See below)

Configuration of charset code replacement.

```js
fileTypes: {
  xml: {
    ext: ['.html'],
    detect: /<\?xml\s+version=["']?1.0["']?\encoding=.+?["']?\s*\?>/i,
    replace: '<?xml version="1.0" encoding="{{charset}}"?>'
  },
  html5: {
    ext: ['.html'],
    detect: /<meta\s+charset=["']?.+?["']?\s*\/?>/i,
    replace: '<meta charset="{{charset}}">'
  },
  html4: {
    ext: ['.html'],
    detect: /<meta\s+http-equiv=["']?Content-Type["']?\scontent=["']?.*?charset=.+?["']?\s*\/?>/i,
    replace: '<meta http-equiv="Content-Type" content="text/html; charset={{charset}}">'
  },
  css: {
    ext: ['.css'],
    detect: /^@charset\s+(".+?"|'.+?')/,
    replace: '@charset "{{charset}}"'
  }
}
```

---
_Source: https://npm.io/package/gulp-charset · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
