PHPackages                             fab2s/utf8 - 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. fab2s/utf8

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

fab2s/utf8
==========

A purely static UTF8 Helper based on mb\_string and ext-intl

1.0.1(4y ago)2310.6k↓24.5%[1 PRs](https://github.com/fab2s/Utf8/pulls)1MITPHPPHP ^7.2|^8.0

Since Sep 20Pushed 3y ago1 watchersCompare

[ Source](https://github.com/fab2s/Utf8)[ Packagist](https://packagist.org/packages/fab2s/utf8)[ RSS](/packages/fab2s-utf8/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (4)Used By (1)

Utf8
====

[](#utf8)

[![Build Status](https://camo.githubusercontent.com/6112037dc4b073b2b1345173c76e7c9345a302444f60b6b317cc411ad7dbc8cd/68747470733a2f2f7472617669732d63692e636f6d2f66616232732f557466382e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/fab2s/Utf8) [![Total Downloads](https://camo.githubusercontent.com/7cce2760b7908fd60e8116d7c56529db0a2c0c4f07f886ebfe5fa79795c8e685/68747470733a2f2f706f7365722e707567782e6f72672f66616232732f757466382f646f776e6c6f616473)](//packagist.org/packages/fab2s/utf8) [![Monthly Downloads](https://camo.githubusercontent.com/4b6314b9b37fd1af327cc1a15969801bc67fe6b41f22bd5813d85a1f7d8183e3/68747470733a2f2f706f7365722e707567782e6f72672f66616232732f757466382f642f6d6f6e74686c79)](//packagist.org/packages/fab2s/utf8) [![Latest Stable Version](https://camo.githubusercontent.com/d328de9486715c1c4b0d19dd4d9a31dac1bb381e07f798474379960c0f932d9d/68747470733a2f2f706f7365722e707567782e6f72672f66616232732f757466382f762f737461626c65)](https://packagist.org/packages/fab2s/utf8) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/21f12d84f896c2d3b9f694c83d78ef8e4a2b142dcf5d86028472c7c8494c3cb0/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f66616232732f557466382f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/fab2s/Utf8/?branch=master) [![PRs Welcome](https://camo.githubusercontent.com/7d9ed3c8f22eceb1711573169b1390cc0b1194467340dc815205060c162b5309/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5052732d77656c636f6d652d627269676874677265656e2e7376673f7374796c653d666c6174)](http://makeapullrequest.com) [![License](https://camo.githubusercontent.com/9bbf8da2483428214d7f6b9bd673ac90a37c39f031c2d743159234457a8de842/68747470733a2f2f706f7365722e707567782e6f72672f66616232732f757466382f6c6963656e7365)](https://packagist.org/packages/fab2s/utf8)

A purely static UTF-8 Helper based on [mb\_string](https://php.net/mb_string) and [ext-intl](https://php.net/intl)

> For sure this is not new, and there is better out there, but this is small and does the job without a lot of noise

Installation
------------

[](#installation)

`Utf8` can be installed using composer:

```
composer require "fab2s/utf8"

```

`Utf8` is also included in [OpinHelper](https://github.com/fab2s/OpinHelpers) which packages several bellow "Swiss Army Knife" level Helpers covering some of the most annoying aspects of php programing, such as UTF8 string manipulation, high precision Mathematics or properly locking a file

Should you need to work with php bellow 7.1, you can still use [OpinHelper](https://github.com/fab2s/OpinHelpers) `0.x`

Prerequisites
-------------

[](#prerequisites)

`Utf8` requires [mb\_string](https://php.net/mb_string), [ext-intl](https://php.net/intl) is auto detected and used when available for UTF-8 Normalization

In practice
-----------

[](#in-practice)

`Utf8` offers replacement for most native string functions with support for UTF-8:

- `Utf8::strrpos(string string $str, string $needle, int $offset = null):int|false`

    UTF-8 aware [strrpos()](https://php.net/strrpos) replacement
- `Utf8::strpos(string $str, string $needle, int $offset = 0):int|false`

    UTF-8 aware [strpos()](https://php.net/strpos) replacement
- `Utf8::strtolower(string $str):string`

    UTF-8 aware [strtolower()](https://php.net/strtolower) replacement
- `Utf8::strtoupper(string $str):string`

    UTF-8 aware [strtoupper()](https://php.net/strtoupper) replacement
- `Utf8::substr(string $str, int $offset, int $length = null):string`

    UTF-8 aware [substr()](https://php.net/substr) replacement
- `Utf8::strlen(string $str):int`

    UTF-8 aware [strlen()](https://php.net/strlen) replacement
- `Utf8::ucfirst(string $str):string`

    UTF-8 aware [ucfirst()](https://php.net/ucfirst) replacement
- `Utf8::ucwords(string $str):string`

    UTF-8 aware [ucwords()](https://php.net/ucwords) replacement
- `Utf8::ord(string $chr):int|false`

    UTF-8 aware [ord()](https://php.net/ord) replacement
- `Utf8::chr(int $num):string|false`

    UTF-8 aware [chr()](https://php.net/chr) replacement

And some simple utility methods:

- `Utf8::normalize(string $string, int $canonicalForm = self::NORMALIZE_NFC):string`

    UTF-8 [ext-intl](https://php.net/intl) [Normalizer](https://php.net/normalizer.normalize)

    > **WARNING**: This method will do nothing in case `ext-intl` is not installed on the host This means it is up to you to make sure about it using `Utf8::normalizerSupport`or by adding `ext-intl` as a requirement to your project's `composer.json` file
- `Utf8::hasUtf8(string $string):bool`

    Tells if the input string contains some UTF-8
- `Utf8::isUtf8(string $string):bool`

    Tells if the input string is valid UTF-8
- `Utf8::replaceMb4(string $string, string $replace = ''):string`

    Replaces all [Utf8Mb4](https://stackoverflow.com/a/30074553/7630496) characters (aka mostly [emoji](https://en.wikipedia.org/wiki/Emoji))
- `Utf8::normalizerSupport(bool $disable = false):bool`

    Tells if [Normalizer](https://php.net/normalizer.normalize) is available or disable Normalizer support

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

[](#requirements)

`Utf8` is tested against php 7.2, 7.3, 7.4, 8.0 and 8.1

Contributing
------------

[](#contributing)

Contributions are welcome, do not hesitate to open issues and submit pull requests.

License
-------

[](#license)

`Utf8` is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT)

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity65

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 ~635 days

Total

2

Last Release

1797d ago

PHP version history (2 changes)1.0.0PHP &gt;=7.1

1.0.1PHP ^7.2|^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7323989?v=4)[fab2s](/maintainers/fab2s)[@fab2s](https://github.com/fab2s)

---

Top Contributors

[![fab2s](https://avatars.githubusercontent.com/u/7323989?v=4)](https://github.com/fab2s "fab2s (9 commits)")

---

Tags

helperintlmb-stringnfcnfdnormalizationphpsimpleutf-8phpnormalizeintlhelperutf-8utf8Simplemb\_stringnfcnfd

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/fab2s-utf8/health.svg)

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

###  Alternatives

[voku/portable-utf8

Portable UTF-8 library - performance optimized (unicode) string functions for php.

52322.4M40](/packages/voku-portable-utf8)[zjkal/time-helper

一个简单快捷的PHP日期时间助手类库。 a smart PHP datetime helper library.

21128.6k1](/packages/zjkal-time-helper)[fab2s/souuid

Simple Ordered Uuid Generator in PHP

13573.2k1](/packages/fab2s-souuid)

PHPackages © 2026

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