Recommend this page to a friend! |
Classes of Lars Moelleken | portable ascii | README.md | Download |
|
Download
? Portable ASCIIDescriptionIt 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 ... + 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
AlternativeIf 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.
Install "Portable ASCII" via "composer require"
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
UsageExample: ASCII::to_ascii()
Portable ASCII | APIThe API from the "ASCII"-Class is written as small static methods. Class methodscharsArray(bool $withExtras = false): arrayReturns an replacement array for ASCII methods.
charsArrayWithMultiLanguageValues(bool $withExtras = false): arrayReturns an replacement array for ASCII methods with a mix of multiple languages.
charsArrayWithOneLanguage(string $language = 'en', bool $withExtras = false): array {
Returns an replacement array for ASCII methods with one language. For example, German will map 'ä' to 'ae', while other languages will simply return e.g. 'a'.
charsArrayWithSingleLanguageValues(bool $withExtras = false): array
Returns an replacement array for ASCII methods with multiple languages.
is_ascii(string $str) : boolChecks if a string is 7 bit ASCII.
normalize_msword(string $str) : stringNormalize some MS Word special characters.
normalize_whitespace(string $str, bool $keepNonBreakingSpace = false, bool $keepBidiUnicodeControls = false) : stringNormalize the whitespace.
to_ascii(string $str, string $language = 'en', bool $removeUnsupported = true): stringConvert a string into language specific ASCII.
to_filename(string $str, bool $use_transliterate = false, string $fallback_char = '-'): stringConvert given string to safe filename (and keep string case).
to_transliterate(string $str, string $unknown = '?', bool $strict) : stringConvert a string into ASCII.
Unit Test1) Composer is a prerequisite for running the tests.
2) The tests can be executed by running this command from the root directory:
SupportFor 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
License and CopyrightReleased under the MIT License - see |