PHPackages                             zbateson/mb-wrapper - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. zbateson/mb-wrapper

ActiveLibrary[HTTP &amp; Networking](/categories/http)

zbateson/mb-wrapper
===================

Wrapper for mbstring with fallback to iconv for encoding conversion and string manipulation

3.0.1(1w ago)4952.7M↓25.4%8[2 PRs](https://github.com/zbateson/mb-wrapper/pulls)4BSD-2-ClausePHPPHP &gt;=8.1CI passing

Since Sep 28Pushed 1w ago2 watchersCompare

[ Source](https://github.com/zbateson/mb-wrapper)[ Packagist](https://packagist.org/packages/zbateson/mb-wrapper)[ GitHub Sponsors](https://github.com/zbateson)[ RSS](/packages/zbateson-mb-wrapper/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (10)Versions (13)Used By (4)

zbateson/mb-wrapper
===================

[](#zbatesonmb-wrapper)

Charset conversion and string manipulation wrapper with a large defined set of aliases.

[![Build Status](https://github.com/zbateson/mb-wrapper/actions/workflows/tests.yml/badge.svg)](https://github.com/zbateson/mb-wrapper/actions/workflows/tests.yml)[![Total Downloads](https://camo.githubusercontent.com/a7a4a3649c68a3de3918e9f9c2b90dce9088ec9658722f3c031915d0a893e761/68747470733a2f2f706f7365722e707567782e6f72672f7a62617465736f6e2f6d622d777261707065722f646f776e6c6f616473)](https://packagist.org/packages/zbateson/mb-wrapper)[![Latest Stable Version](https://camo.githubusercontent.com/0490085423241c711eccc33de289ce802be4f533070ca6d470910e9c52f37365/68747470733a2f2f706f7365722e707567782e6f72672f7a62617465736f6e2f6d622d777261707065722f76657273696f6e)](https://packagist.org/packages/zbateson/mb-wrapper)

```
composer require zbateson/mb-wrapper

```

Sponsors
--------

[](#sponsors)

[![SecuMailer](https://camo.githubusercontent.com/74de27677ddf07fa571fcca6558d34be0fa6486bf473de73261461b89b12e8c5/68747470733a2f2f6d61696c2d6d696d652d7061727365722e6f72672f73706f6e736f72732f6c6f676f2d736563756d61696c65722e706e67)](https://secumailer.com)

A huge thank you to [all my sponsors](https://github.com/sponsors/zbateson). &lt;3

If this project's helped you, please consider [sponsoring me](https://github.com/sponsors/zbateson).

Requirements
------------

[](#requirements)

PHP 8.1 or newer. Tested on PHP 8.1, 8.2, 8.3, 8.4, and 8.5.

Description
-----------

[](#description)

MbWrapper is intended for use wherever `mb_*` or `iconv_*` is used. It scans supported charsets returned by `mb_list_encodings()`, and prefers `mb_*` functions, but will fallback to `iconv` if a charset isn't supported by the `mb_*` functions.

A list of aliased charsets is maintained for both `mb_*` and `iconv`, where a supported charset exists for an alias. This is useful for mail and http parsing as other systems may report encodings not recognized by `mb_*` or `iconv`.

Charset lookup is done by removing non-alphanumeric characters as well, so `UTF8` will always be matched to `UTF-8`, etc.

Usage
-----

[](#usage)

The following wrapper methods are exposed:

- `mb_convert_encoding`, `iconv` with `MbWrapper::convert`
- `mb_substr`, `iconv_substr` with `MbWrapper::getSubstr`
- `mb_strlen`, `iconv_strlen` with `MbWrapper::getLength`
- `mb_check_encoding`, `iconv` (for verification) with `MbWrapper::checkEncoding`

```
$mbWrapper = new \ZBateson\MbWrapper\MbWrapper();
$fromCharset = 'ISO-8859-1';
$toCharset = 'UTF-8';

$mbWrapper->convert('data', $fromCharset, $toCharset);
$mbWrapper->getLength('data', 'UTF-8');
$mbWrapper->substr('data', 'UTF-8', 1, 2);

if ($mbWrapper->checkEncoding('data', 'UTF-8')) {
    echo 'Compatible';
}
```

License
-------

[](#license)

BSD licensed - please see [license agreement](https://github.com/zbateson/mb-wrapper/blob/master/LICENSE).

###  Health Score

71

—

ExcellentBetter than 100% of packages

Maintenance98

Actively maintained with recent releases

Popularity63

Solid adoption and visibility

Community26

Small or concentrated contributor base

Maturity78

Established project with proven stability

 Bus Factor1

Top contributor holds 68.2% 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 ~282 days

Recently: every ~206 days

Total

11

Last Release

9d ago

Major Versions

1.2.1 → 2.0.02024-03-20

2.0.1 → 3.0.02026-02-13

PHP version history (4 changes)1.0.0PHP &gt;=5.4

1.2.0PHP &gt;=7.1

2.0.0PHP &gt;=8.0

3.0.0PHP &gt;=8.1

### Community

Maintainers

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

---

Top Contributors

[![zbateson](https://avatars.githubusercontent.com/u/8356974?v=4)](https://github.com/zbateson "zbateson (45 commits)")[![phpfui](https://avatars.githubusercontent.com/u/7434059?v=4)](https://github.com/phpfui "phpfui (14 commits)")[![Nielsvanpach](https://avatars.githubusercontent.com/u/10651054?v=4)](https://github.com/Nielsvanpach "Nielsvanpach (2 commits)")[![fkoyer](https://avatars.githubusercontent.com/u/8293789?v=4)](https://github.com/fkoyer "fkoyer (1 commits)")[![taylorvance](https://avatars.githubusercontent.com/u/33555535?v=4)](https://github.com/taylorvance "taylorvance (1 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (1 commits)")[![hazington](https://avatars.githubusercontent.com/u/83652897?v=4)](https://github.com/hazington "hazington (1 commits)")[![owenvoke](https://avatars.githubusercontent.com/u/1899334?v=4)](https://github.com/owenvoke "owenvoke (1 commits)")

---

Tags

charsetcharset-conversionemailhttpmime-charsetsmultibytestringstring-manipulationmbstringhttpstringmailmimeiconvencodingmultibytembcharsetmb\_convert\_encoding

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/zbateson-mb-wrapper/health.svg)

```
[![Health](https://phpackages.com/badges/zbateson-mb-wrapper/health.svg)](https://phpackages.com/packages/zbateson-mb-wrapper)
```

###  Alternatives

[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[symfony/http-foundation

Defines an object-oriented layer for the HTTP specification

8.6k910.8M6.5k](/packages/symfony-http-foundation)[symfony/mime

Allows manipulating MIME messages

2.8k716.9M1.4k](/packages/symfony-mime)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M733](/packages/sylius-sylius)[symfony/string

Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way

1.8k777.3M1.3k](/packages/symfony-string)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6942.5M419](/packages/drupal-core-recommended)

PHPackages © 2026

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