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

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

yarri/utf8-cleaner
==================

Removes invalid UTF-8 characters from the given text

v1.1(6y ago)16.1k↓53.3%1MITPHPPHP &gt;=5.3.0

Since Jan 7Pushed 7mo agoCompare

[ Source](https://github.com/yarri/Utf8Cleaner)[ Packagist](https://packagist.org/packages/yarri/utf8-cleaner)[ Docs](https://github.com/yarri/Utf8Cleaner)[ RSS](/packages/yarri-utf8-cleaner/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (2)Versions (3)Used By (1)

Utf8Cleaner
===========

[](#utf8cleaner)

[![Build Status](https://camo.githubusercontent.com/93cbe987121044d58b3555e0f02a0a24b259964f7db3e3681a710a8306711fbb/68747470733a2f2f6170702e7472617669732d63692e636f6d2f79617272692f55746638436c65616e65722e7376673f6272616e63683d6d6173746572)](https://app.travis-ci.com/yarri/Utf8Cleaner)

Removes invalid UTF-8 byte sequences from the given text.

Utf8Cleaner is inspired by

Usage
-----

[](#usage)

Consider you have a string with an illegal UTF-8 byte sequence.

```
$invalid_char = chr(200).chr(200); // invalid byte sequence for UTF-8
$malformed_text = "Příliš žluťoučk$invalid_char kůň";

$text = \Yarri\Utf8Cleaner::Clean($malformed_text);

```

By default, each invalid byte sequence is replaced with � (i.e. a black diamond with a white question mark - REPLACEMENT CHARACTER used to replace an unknown, unrecognized or unrepresentable character, U+FFFD).

```
echo $text; // "Příliš žluťoučk� kůň"

```

The default replacement can be overridden by an option.

```
$text = \Yarri\Utf8Cleaner::Clean($malformed_text,["replacement" => "?"]);
// or
$text = \Yarri\Utf8Cleaner::Clean($malformed_text,"?");

echo $text; // "Příliš žluťoučk? kůň"

```

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

[](#installation)

The best way how to install Utf8Cleaner is to use the Composer:

```
composer require yarri/utf8-cleaner

```

Testing
-------

[](#testing)

```
composer update --dev
./vendor/bin/run_unit_tests test/

```

License
-------

[](#license)

Utf8Cleaner is free software distributed [under the terms of the MIT license](http://www.opensource.org/licenses/mit-license)

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance44

Moderate activity, may be stable

Popularity23

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

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

Total

2

Last Release

2324d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/974278?v=4)[Jaromir Tomek](/maintainers/yarri)[@yarri](https://github.com/yarri)

---

Top Contributors

[![yarri](https://avatars.githubusercontent.com/u/974278?v=4)](https://github.com/yarri "yarri (17 commits)")

---

Tags

utf-8utf8cleancleanerfixremoverglitchglitches

### Embed Badge

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

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

###  Alternatives

[voku/portable-utf8

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

52323.5M49](/packages/voku-portable-utf8)[nette/utils

🛠 Nette Utils: lightweight utilities for string &amp; array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.

2.1k430.4M1.7k](/packages/nette-utils)[danielstjules/stringy

A string manipulation library with multibyte support

2.4k26.3M192](/packages/danielstjules-stringy)[voku/portable-ascii

Portable ASCII library - performance optimized (ascii) string functions for php.

576437.1M171](/packages/voku-portable-ascii)[clue/utf8-react

Streaming UTF-8 parser, built on top of ReactPHP.

6611.0M4](/packages/clue-utf8-react)[opis/string

Multibyte strings as objects

7626.6M9](/packages/opis-string)

PHPackages © 2026

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