5.3 KiB
🔡 Portable ASCII
Description
It is written in PHP (PHP 7+) and can work without "mbstring", "iconv" or any other extra encoding php-extension on your server.
The benefit of Portable ASCII is that it is easy to use, easy to bundle.
The project based on ...
- Sean M. Burke's work (https://metacpan.org/pod/Text::Unidecode)
- Tomaz Solc's work (https://pypi.org/project/Unidecode/)
- Portable UTF-8 work (https://github.com/voku/portable-utf8)
- Daniel St. Jules's work (https://github.com/danielstjules/Stringy)
- Johnny Broadway's work (https://github.com/jbroadway/urlify)
- and many cherry-picks from "github"-gists and "Stack Overflow"-snippets ...
Index
- Alternative
- Install
- Why Portable ASCII?
- Requirements and Recommendations
- Usage
- Class methods
- Unit Test
- License and Copyright
Alternative
If you like a more Object Oriented Way to edit strings, then you can take a look at voku/Stringy, it's a fork of "danielstjules/Stringy" but it used the "Portable ASCII"-Class and some extra methods.
// Portable ASCII
use voku\helper\ASCII;
ASCII::to_transliterate('déjà σσς iıii'); // 'deja sss iiii'
// voku/Stringy
use Stringy\Stringy as S;
$stringy = S::create('déjà σσς iıii');
$stringy->toTransliterate(); // 'deja sss iiii'
Install "Portable ASCII" via "composer require"
composer require voku/portable-ascii
Why Portable ASCII?
I need ASCII char handling in different classes and before I added this functions into "Portable UTF-8", but this repo is more modular and portable, because it has no dependencies.
Requirements and Recommendations
- No extensions are required to run this library. Portable ASCII only needs PCRE library that is available by default since PHP 4.2.0 and cannot be disabled since PHP 5.3.0. "\u" modifier support in PCRE for ASCII handling is not a must.
- PHP 7.0 is the minimum requirement
- PHP 8.0 is also supported
Usage
Example: ASCII::to_ascii()
echo ASCII::to_ascii('<27>Düsseldorf<72>', 'de');
// will output
// Duesseldorf
echo ASCII::to_ascii('<27>Düsseldorf<72>', 'en');
// will output
// Dusseldorf
Portable ASCII | API
The API from the "ASCII"-Class is written as small static methods.
Class methods
%functions_index__voku\helper\ASCII%
%functions_list__voku\helper\ASCII%
Unit Test
- Composer is a prerequisite for running the tests.
composer install
- The tests can be executed by running this command from the root directory:
./vendor/bin/phpunit
Support
For support and donations please visit Github | Issues | PayPal | Patreon.
For status updates and release announcements please visit Releases | Twitter | Patreon.
For professional support please contact me.
Thanks
- Thanks to GitHub (Microsoft) for hosting the code and a good infrastructure including Issues-Managment, etc.
- Thanks to IntelliJ as they make the best IDEs for PHP and they gave me an open source license for PhpStorm!
- Thanks to Travis CI for being the most awesome, easiest continous integration tool out there!
- Thanks to StyleCI for the simple but powerful code style check.
- Thanks to PHPStan && Psalm for really great Static analysis tools and for discover bugs in the code!
License and Copyright
Released under the MIT License - see LICENSE.txt
for details.