Portable ASCII
Dependency-free PHP library for fast ASCII string transliteration and cleaning.
Repository Health
Technical Analysis
Portable ASCII is a performance-optimized PHP library that provides ASCII-oriented string functions without requiring the mbstring, iconv, or any other encoding extension. Its headline capability is transliterating UTF-8 and other multibyte text down to plain ASCII — turning accented and non-Latin characters into their closest ASCII equivalents — plus utilities to detect and strip non-ASCII characters.
Because it works purely in PHP and bundles its own character maps, it is trivial to install and runs consistently across servers regardless of installed extensions. It is widely used as the transliteration backbone for higher-level string libraries and for generating clean slugs, filenames, and search keys.
What You Get
- toAscii() transliteration of UTF-8 and other characters into closest ASCII equivalents
- Language-aware transliteration maps for many scripts and locales
- Detection of whether a string contains only ASCII characters
- Removal or replacement of non-ASCII and control characters
- A clean() helper for normalizing and sanitizing text
- Zero required extensions — works without mbstring or iconv
Common Use Cases
- Generating URL slugs and filenames from arbitrary user text
- Normalizing accented names and addresses to ASCII for matching
- Cleaning imported data with mixed or unknown encodings
- Producing ASCII search keys for indexing and deduplication
Under The Hood
Architecture - The library centers on a single voku\helper\ASCII class exposing static methods (to_ascii, is_ascii, to_transliterate, clean, and helpers). Transliteration is data-driven: large bundled PHP arrays map Unicode code points and language-specific characters to ASCII replacements, and the class selects and applies the appropriate maps at runtime, lazily loading map files to keep memory reasonable.
Tech Stack - Pure PHP (100% of the codebase) targeting PHP 7+, with no required runtime dependencies and deliberately no reliance on mbstring or iconv. It ships extensive generated character-map data files and is validated across CI providers (GitHub Actions, AppVeyor) for Linux and Windows.
Code Quality - The project reports high code coverage and grades via Codecov and Codacy, uses StyleCI for consistent formatting, and is actively maintained with frequent commits. The large map data is generated rather than hand-written, and the small public surface keeps the core logic focused and well tested.
API Design - The API is a set of clearly named static methods on one class, so typical usage is a single call such as ASCII::to_ascii($str, $language). Optional parameters control language and strictness, but sensible defaults mean most callers need no configuration.