# utf8-stream

> buffer utf8 characters that would otherwise span chunk boundaries

Latest version **0.0.0** (published 2013-07-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install utf8-stream
pnpm add utf8-stream
yarn add utf8-stream
bun add utf8-stream
```

## 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.0 |
| Published | 2013-07-19 |
| First published | 2013-07-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | James Halliday |
| Maintainers | substack |
| Keywords | utf8, unicode, chunk, boundary, encoding, buffer, toString |

## Links

- npm: https://www.npmjs.com/package/utf8-stream
- Repository: https://github.com/substack/utf8-stream
- Issues: https://github.com/substack/utf8-stream/issues
- npm.io page: https://npm.io/package/utf8-stream

## Dependencies (1)

- [readable-stream](https://npm.io/package/readable-stream.md) ~1.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

- 0.0.0 (latest) — 2013-07-19

## README

# utf8-stream

buffer utf8 characters that would otherwise span chunk boundaries

[![build status](https://secure.travis-ci.org/substack/utf8-stream.png)](http://travis-ci.org/substack/utf8-stream)

# example

Here we'll write some chinese characters at random byte offsets:

``` js
var utf8Stream = require('utf8-stream');
var through = require('through');

var u8 = utf8Stream();
u8.pipe(through(function (buf) {
    var s = buf.toString('utf8');
    this.queue(s.split('').join('\n') + '\n');
})).pipe(process.stdout);

u8.write(Buffer([ 0xe9, 0x81 ]));
u8.write(Buffer([ 0x99, 0xe9, 0x81, 0xa0, 0xe6 ]));
u8.write(Buffer([ 0x9c, 0xaa, 0xe4, 0xbe ]));
u8.write(Buffer([ 0x86, 0xe7, 0x9a, 0x84, 0xe4, 0xba, 0x8b ]));
u8.write(Buffer([ 0xe4, 0xbb, 0xb6 ]));
u8.end();
```

Inside the `through(function (buf) {})`, each `buf` will never span a utf8
multi-byte character so we can just call `.toString('utf8')`.

output:

```
遙
遠
未
來
的
事
件
```

# methods

``` js
var utf8Stream = require('utf8-stream')
```

## var u8 = utf8Stream()

Return a through stream `u8` that will never emit a chunk that spans a utf8
multi-byte character.

# install

With [npm](https://npmjs.org) do:

```
npm install utf8-stream
```

# license

MIT

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