PHPackages                             enorris/mbstring-stream - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. enorris/mbstring-stream

ActiveLibrary

enorris/mbstring-stream
=======================

An mbstring stream conversion filter.

v3.0.2(1y ago)291.0k↓100%4[1 issues](https://github.com/ericnorris/mbstring-stream/issues)MITPHPPHP 8.1.x|8.2.x|8.3.x

Since Mar 21Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ericnorris/mbstring-stream)[ Packagist](https://packagist.org/packages/enorris/mbstring-stream)[ RSS](/packages/enorris-mbstring-stream/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (1)Versions (6)Used By (0)

Multibyte String Stream Filter [![Build Status](https://github.com/ericnorris/mbstring-stream/actions/workflows/ci.yml/badge.svg)](https://github.com/ericnorris/mbstring-stream/actions/workflows/ci.yml/badge.svg)
====================================================================================================================================================================================================================

[](#multibyte-string-stream-filter-)

A `php_user_filter` implementation for quickly converting stream character sets without loading the entire string into memory.

**Note:** this library does not have the ability to persist state for *stateful* character sets, and as such, could potentially lose data. See [\#1](https://github.com/ericnorris/mbstring-stream/issues/1) for an open issue, and [this document](https://www.debian.org/doc/manuals/intro-i18n/ch-coding.en.html#s-stateful) for more info about stateful character sets.

Example
-------

[](#example)

```
// Not required if the file was autoloaded (e.g. using composer)
MultibyteStringStream::registerStreamFilter();

$native_file = fopen('iso-8859-1-file.txt', 'r');

stream_filter_append($native_file, 'convert.mbstring.UTF-8/ISO-8859-1');

$unicode_file = fopen('utf8-file.txt', 'w');

stream_copy_to_stream($native_file, $unicode_file);
```

mbstring-stream also works as a write filter:

```
$native_file  = fopen('sjis-file.txt', 'r');
$unicode_file = fopen('utf8-file.txt', 'w');

stream_filter_append($unicode_file, 'convert.mbstring.UTF-8/SJIS');

stream_copy_to_stream($native_file, $unicode_file);
```

Usage
-----

[](#usage)

```
/**
 * resource   $stream        The stream to filter.
 * string     $to_encoding   The encoding to convert to.
 * string     $from_encoding The encoding to convert from. Optional, defaults to mb_internal_encoding()
 * int        $read_write    See http://php.net/manual/en/function.stream-filter-append.php
 * string|int $sub_char      The substitute character to use. Optional, defaults to mb_substitute_character()
 */
stream_filter_append($stream, "convert.mbstring.$to_encoding/$from_encoding", $read_write, $sub_char);
```

Note: Be careful when using on streams in 'r+' or 'w+' (or similar) modes; by default PHP will assign the filter to both the reading and writing chain. This means it will attempt to convert the data twice - once when writing to the stream, and once when reading from it.

###  Health Score

43

—

FairBetter than 90% of packages

Maintenance29

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity82

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 83.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~786 days

Total

5

Last Release

554d ago

Major Versions

v1.0.0 → v2.0.02018-02-25

v2.0.0 → v3.0.02022-12-05

PHP version history (4 changes)v2.0.0PHP &gt;=7.0

v3.0.0PHP 8.1.x

v3.0.1PHP 8.1.x|8.2.x

v3.0.2PHP 8.1.x|8.2.x|8.3.x

### Community

Maintainers

![](https://www.gravatar.com/avatar/d999b5c746c9bc3f1ce91339cf207848a0e5fcdfd74d401b6f77b5a073abb0f5?d=identicon)[ericnorris](/maintainers/ericnorris)

---

Top Contributors

[![ericnorris](https://avatars.githubusercontent.com/u/1906605?v=4)](https://github.com/ericnorris "ericnorris (26 commits)")[![paxal](https://avatars.githubusercontent.com/u/1848817?v=4)](https://github.com/paxal "paxal (5 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/enorris-mbstring-stream/health.svg)

```
[![Health](https://phpackages.com/badges/enorris-mbstring-stream/health.svg)](https://phpackages.com/packages/enorris-mbstring-stream)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
