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.0(3mo ago)4948.6M—5.5%8[2 PRs](https://github.com/zbateson/mb-wrapper/pulls)4BSD-2-ClausePHPPHP &gt;=8.1CI failing

Since Sep 28Pushed 3mo 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 1mo ago

READMEChangelog (10)Dependencies (5)Versions (12)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

66

—

FairBetter than 99% of packages

Maintenance82

Actively maintained with recent releases

Popularity63

Solid adoption and visibility

Community25

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor1

Top contributor holds 66.7% 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 ~299 days

Recently: every ~282 days

Total

10

Last Release

94d 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 (42 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

[jbzoo/utils

Collection of PHP functions, mini classes and snippets for everyday developer's routine life.

8321.5M36](/packages/jbzoo-utils)[ddeboer/transcoder

Better encoding conversion for PHP

16705.6k10](/packages/ddeboer-transcoder)[ptlis/conneg

Tools for performing content negotiation.

364.9k1](/packages/ptlis-conneg)[zbateson/stream-decorators

PHP psr7 stream decorators for mime message part streams

4748.6M6](/packages/zbateson-stream-decorators)[paquettg/string-encode

Facilitating the process of altering string encoding in PHP.

698.7M43](/packages/paquettg-string-encode)[crwlr/query-string

A library for convenient handling of query strings used in HTTP requests.

215.6M4](/packages/crwlr-query-string)

PHPackages © 2026

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