PHPackages                             grandt/binstring - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. grandt/binstring

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

grandt/binstring
================

A class for working around the use of mbstring.func\_override

1.0.0(10y ago)7872.1k—9.9%26LGPL-2.1PHPPHP &gt;=5.0

Since Aug 5Pushed 10y ago1 watchersCompare

[ Source](https://github.com/Grandt/PHPBinString)[ Packagist](https://packagist.org/packages/grandt/binstring)[ Docs](https://github.com/Grandt/PHPBinString)[ RSS](/packages/grandt-binstring/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)DependenciesVersions (4)Used By (6)

Binary Safe String functions
============================

[](#binary-safe-string-functions)

If you use PHP's mbstring.func\_overload, or the server you are running on has it enabled, you are in trouble. Especially if you are relying on being able to parse binary data and protocols.

Introduction
------------

[](#introduction)

To the question "Should I use multi-byte overloading (mbstring.func\_overload)?". user 'gphilip' said it well on this StackOverflow post:

> My answer is: definitely not!
>
> The problem is that there is no easy way to "reset" str\* functions once they are overloaded.
>
> For some time this can work well with your project, but almost surely you will run into an external library that uses string functions to, for example, implement a binary protocol, and they will fail. They will fail and you will spend hours trying to find out why they are failing.

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

[](#description)

This class is a wrapper for string functions, in cases where the mbstring.func\_overload tripe have been enabled. Be warned, use this class ONLY if you have to, as it *will* affect performance a bit. For some functions, a lot, though that is due to problems in mb\_string, not this class. Function calls in PHP are fairly expensive on their own, and if func\_overload is enabled, it'll use mb\_string functions exclusively in place of the built-in PHP string, to parse them as 'latin1', which is also expensive, cpu wise.

### Why the potential performance impact?

[](#why-the-potential-performance-impact)

PHP, like Java, have length aware strings, meaning the object header knows how long your string is. They are binary safe, and not null (0x00) terminated.

mb\_string functions ignore that, and parse the entirety of the string, to figure out what is what. strlen(string) simply tells you how many bytes are in it, mb\_strlen will parse it, to find multi byte characters, and tell you how many characters there are. That is great for handling multi-byte encoded strings correctly, such as UTF-8, it sucks for binary data handling, as multi-byte sequences are bound to occur by random chance, in any large enough binary data set.

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity44

Moderate usage in the ecosystem

Community16

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~186 days

Total

3

Last Release

3932d ago

Major Versions

0.2.0.x-dev → 1.0.02015-08-13

### Community

Maintainers

![](https://www.gravatar.com/avatar/617ced39b5ad622d3e86329053bfa3749718e8597b2fcb8137cb40b796b8604a?d=identicon)[Grandt](/maintainers/Grandt)

---

Top Contributors

[![Grandt](https://avatars.githubusercontent.com/u/1094427?v=4)](https://github.com/Grandt "Grandt (8 commits)")

---

Tags

mbstringbinary strings

### Embed Badge

![Health badge](/badges/grandt-binstring/health.svg)

```
[![Health](https://phpackages.com/badges/grandt-binstring/health.svg)](https://phpackages.com/packages/grandt-binstring)
```

###  Alternatives

[symfony/polyfill-mbstring

Symfony polyfill for the Mbstring extension

7.8k1.2B515](/packages/symfony-polyfill-mbstring)

PHPackages © 2026

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