# to-utf-8

> Detect input encoding and convert to utf-8 if needed

Latest version **1.3.0** (published 2016-11-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install to-utf-8
pnpm add to-utf-8
yarn add to-utf-8
bun add to-utf-8
```

Provides the command `to-utf-8`.

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.0 |
| Published | 2016-11-27 |
| First published | 2014-11-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 26 |
| Author | Finn Pauls |
| Maintainers | finnpauls |
| Keywords | utf8, encoding, detection |

## Links

- npm: https://www.npmjs.com/package/to-utf-8
- Repository: https://github.com/finnp/to-utf-8
- Issues: https://github.com/finnp/to-utf-8/issues
- npm.io page: https://npm.io/package/to-utf-8

## Dependencies (5)

- [minimist](https://npm.io/package/minimist.md) ^1.1.0
- [iconv-lite](https://npm.io/package/iconv-lite.md) ^0.4.4
- [peek-stream](https://npm.io/package/peek-stream.md) ^1.1.1
- [stream-splicer](https://npm.io/package/stream-splicer.md) ^1.3.1
- [charset-detector](https://npm.io/package/charset-detector.md) 0.0.2

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K 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

## Recent versions

- 1.3.0 (latest) — 2016-11-27
- 1.2.0 — 2016-04-15
- 1.1.0 — 2014-11-06
- 1.0.1 — 2014-11-05
- 1.0.0 — 2014-11-05

## README

# to-utf-8

Install with `npm install to-utf-8` and optionally use the `-g` flag to install the
command line utility.

[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)

## Usage
```js
var utf8 = require('to-utf-8')
var fs = require('fs')

fs.createReadStream('weirdencoding.txt')
  .pipe(utf8())
  .pipe('utf8encoded.txt')
```

You can also provide the encoding, if known:

```js
var utf8 = require('to-utf-8')
var fs = require('fs')

fs.createReadStream('utf16-le-file.txt')
  .pipe(utf8('utf16-le'))
  .pipe('utf8encoded.txt')
```

You can also pass an options object instead with the following keys:
* `confidence` Minimum confidence for the detected source encoding. If not reached assume `utf-8`
* `encoding` Same as passing a string directly. Use the given encoding instead of detecting it.
* `newline` Use input text until newline is reached to detect encoding (default `true`)
* `detectSize` Maximum size from input to detect encoding (default `65535`)

## CLI

This modules includes a `to-utf-8` command line tool. It listens for a stream from
stdin and converts it to utf-8 to stdout like:

```
to-utf-8 < weirdencoding.txt > utf8encoded.txt
```

You can specify the source encoding with the `--enc` flag.

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