PHPackages                             webpatser/portable-ascii - 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. webpatser/portable-ascii

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

webpatser/portable-ascii
========================

Portable ASCII library - modernized for PHP 8.1+ with performance optimizations.

00PHPCI passing

Since Apr 27Pushed 1mo agoCompare

[ Source](https://github.com/webpatser/portable-ascii)[ Packagist](https://packagist.org/packages/webpatser/portable-ascii)[ RSS](/packages/webpatser-portable-ascii/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

webpatser/portable-ascii
========================

[](#webpatserportable-ascii)

Modernized drop-in replacement for [`voku/portable-ascii`](https://github.com/voku/portable-ascii) — requires PHP 8.1+.

Why?
----

[](#why)

The original `voku/portable-ascii` package (471M+ installs) still requires PHP 7.0 and has unresolved [PHP 8.4 deprecation warnings](https://github.com/voku/portable-ascii/issues/106). This fork modernizes the codebase, fixes transliteration bugs, and is **36-50% faster** while keeping full API compatibility.

**Zero breaking changes.** Same namespace, same methods, same behavior.

What changed
------------

[](#what-changed)

- PHP 8.1 minimum (was 7.0)
- Typed properties and return types throughout
- Fixed implicit nullable parameter deprecation (`to_transliterate()`)
- Replaced O(n\*m) character replacement loop with `strtr()` — single C-level pass
- Adaptive sparse/dense detection for optimal replacement strategy
- `mb_str_split()` replacing `preg_match_all` for character splitting (when ext-mbstring available)
- Cascading transliteration: ext-intl -&gt; ext-iconv -&gt; manual byte decoding
- Inlined `is_ascii()` regex for faster hot-path checks
- Fixed Bulgarian, Ukrainian, Austrian (Eszett), and Hindi transliteration mappings
- Test suite ported to Pest 4 (247 tests, 1602 assertions)

Performance
-----------

[](#performance)

Benchmarked on PHP 8.5 with real-world inputs (German/French/Russian blog titles, product names, URL slugs, long text). Each profile was run in an isolated process with 20s CPU cooldown between runs, 5000 iterations, median of 5 runs.

Profileto\_asciito\_slugifyto\_transliterateTotalvs Original**original** (voku 2.0.3)742 ms936 ms1554 ms3953 ms—**fork** (no extensions)268 ms382 ms1540 ms2455 ms**-38%****fork** + mbstring265 ms378 ms1174 ms2073 ms**-48%****fork** + all extensions270 ms371 ms1171 ms2072 ms**-48%**The `to_ascii()` and `to_slugify()` improvements are pure PHP — no extensions needed. `ext-mbstring` accelerates `to_transliterate()` by 24% via `mb_str_split()` replacing `preg_match_all` for character splitting.

Run the benchmark yourself:

```
php benchmark/run.php 5000           # fork vs original (side by side)
php benchmark/run-profiles.php 5000  # extension profile comparison
```

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

[](#installation)

```
composer require webpatser/portable-ascii
```

This automatically replaces `voku/portable-ascii` via Composer's `replace` directive. No code changes needed — `\voku\helper\ASCII` continues to work.

For best transliteration performance, install ext-mbstring:

```
sudo apt install php-mbstring
```

Usage
-----

[](#usage)

```
use voku\helper\ASCII;

// Transliterate to ASCII
ASCII::to_ascii('Düsseldorf', 'de');  // 'Duesseldorf'

// Check if string is ASCII
ASCII::is_ascii('hello');  // true

// Transliterate with fallback character
ASCII::to_transliterate('こんにちは', '?');  // 'konnichiha'

// Generate URL slug
ASCII::to_slugify('Hello Wörld!');  // 'hello-woerld'
```

Compatibility
-------------

[](#compatibility)

Works with Laravel 11, 12, and 13. All extensions are optional — the library auto-detects what's available and uses the fastest path.

ExtensionImpactUsed byext-mbstring**-24%** on `to_transliterate()``mb_str_split()` for character splittingext-intlFastest transliteration via ICU`to_transliterate()` in strict mode onlyCredits
-------

[](#credits)

This package is a modernized fork of [voku/portable-ascii](https://github.com/voku/portable-ascii) by [Lars Moelleken](https://github.com/voku). The original work, including all 193 Unicode-to-ASCII data tables and the transliteration engine, is his. Licensed under MIT.

License
-------

[](#license)

MIT

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance60

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 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.

### Community

Maintainers

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

---

Top Contributors

[![webpatser](https://avatars.githubusercontent.com/u/25720?v=4)](https://github.com/webpatser "webpatser (14 commits)")

### Embed Badge

![Health badge](/badges/webpatser-portable-ascii/health.svg)

```
[![Health](https://phpackages.com/badges/webpatser-portable-ascii/health.svg)](https://phpackages.com/packages/webpatser-portable-ascii)
```

###  Alternatives

[spatie/laravel-enum

Laravel Enum support

3655.7M34](/packages/spatie-laravel-enum)[kartik-v/php-date-formatter

A Javascript datetime formatting and manipulation library using PHP date-time formats.

461.6M3](/packages/kartik-v-php-date-formatter)

PHPackages © 2026

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