# text-encoding-utf-8

> UTF-8 only polyfill for the Encoding Living Standard's API.

Latest version **1.0.2** (published 2017-11-20) · 0 weekly downloads

## Install

```sh
npm install text-encoding-utf-8
pnpm add text-encoding-utf-8
yarn add text-encoding-utf-8
bun add text-encoding-utf-8
```

## Health

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

Positive: has types package; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2017-11-20 |
| First published | 2015-11-17 |
| Weekly downloads | 0 |
| TypeScript types | separate (@types/text-encoding-utf-8) |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Erik Arvidsson |
| Maintainers | arv |
| Keywords | encoding, decoding, living standard |

## Links

- npm: https://www.npmjs.com/package/text-encoding-utf-8
- Repository: https://github.com/arv/text-encoding-utf-8
- Issues: https://github.com/arv/text-encoding-utf-8/issues
- npm.io page: https://npm.io/package/text-encoding-utf-8

## 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.0.2 (latest) — 2017-11-20
- 1.0.1 — 2015-11-17
- 1.0.0 — 2015-11-17

## README

text-encoding-utf-8
==============

This is a **partial** polyfill for the [Encoding Living Standard](https://encoding.spec.whatwg.org/)
API for the Web, allowing encoding and decoding of textual data to and from Typed Array
buffers for binary data in JavaScript.

This is fork of [text-encoding](https://github.com/inexorabletash/text-encoding)
that **only** support **UTF-8**.

Basic examples and tests are included.

### Install ###

There are a few ways you can get the `text-encoding-utf-8` library.

#### Node ####

`text-encoding-utf-8` is on `npm`. Simply run:

```js
npm install text-encoding-utf-8
```

Or add it to your `package.json` dependencies.

### HTML Page Usage ###

```html
  <script src="encoding.js"></script>
```

### API Overview ###

Basic Usage

```js
  var uint8array = TextEncoder(encoding).encode(string);
  var string = TextDecoder(encoding).decode(uint8array);
```

Streaming Decode

```js
  var string = "", decoder = TextDecoder(encoding), buffer;
  while (buffer = next_chunk()) {
    string += decoder.decode(buffer, {stream:true});
  }
  string += decoder.decode(); // finish the stream
```

### Encodings ###

Only `utf-8` and `UTF-8` are supported.

### Non-Standard Behavior ###

Only `utf-8` and `UTF-8` are supported.

### Motivation

Binary size matters, especially on a mobile phone. Safari on iOS does not
support TextDecoder or TextEncoder.

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