Recommend this page to a friend! |
Classes of Lars Moelleken | Portable UTF-8 | build/docs/base.md | Download |
|
![]() ? Portable UTF-8DescriptionIt 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 UTF-8 is that it is easy to use, easy to bundle. This library will also auto-detect your server environment and will use the installed php-extensions if they are available, so you will have the best possible performance. As a fallback we will use Symfony Polyfills, if needed. (https://github.com/symfony/polyfill) The project based on ... + Hamid Sarfraz's work - portable-utf8 + Nicolas Grekas's work - tchwork/utf8 + Behat's work - Behat/Transliterator + Sebastián Grignoli's work - neitanod/forceutf8 + Ivan Enderlin's work - hoaproject/Ustring + and many cherry-picks from "GitHub"-gists and "Stack Overflow"-snippets ... DemoHere you can test some basic functions from this library and you can compare some results with the native php function results. 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 UTF-8"-Class and some extra methods.
Install "Portable UTF-8" via "composer require"
If your project do not need some of the Symfony polyfills please use the
Why Portable UTF-8?[]()PHP 5 and earlier versions have no native Unicode support. To bridge the gap, there exist several extensions like "mbstring", "iconv" and "intl". The problem with "mbstring" and others is that most of the time you cannot ensure presence of a specific one on a server. If you rely on one of these, your application is no more portable. This problem gets even severe for open source applications that have to run on different servers with different configurations. Considering these, I decided to write a library: Requirements and Recommendations
UsageExample 1: UTF8::cleanup()
Example 2: UTF8::strlen()
Example 3: UTF8::fix_utf8()
Portable UTF-8 | APIThe API from the "UTF8"-Class is written as small static methods that will match the default PHP-API. Class methods%__functions_index__voku\helper\UTF8__% %__functions_list__voku\helper\UTF8__% 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 Copyright"Portable UTF8" is free software; you can redistribute it and/or modify it under the terms of the (at your option): - Apache License v2.0, or - GNU General Public License v2.0. Unicode handling requires tedious work to be implemented and maintained on the long run. As such, contributions such as unit tests, bug reports, comments or patches licensed under both licenses are really welcomed. |