Download the PHP package patchwork/utf8 without Composer

On this page you can find all versions of the php package patchwork/utf8. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.


After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

All versions of utf8 with dependencies

Informations about the package utf8

Patchwork UTF-8 for PHP

Latest Stable Version Total Downloads Build Status SensioLabsInsight

Patchwork UTF-8 gives PHP developpers extensive, portable and performant handling of UTF-8 and grapheme clusters.

It provides both :

It can also serve as a documentation source referencing the practical problems that arise when handling UTF-8 in PHP: Unicode concepts, related algorithms, bugs in PHP core, workarounds, etc.

Version 1.2 adds best-fit mappings for UTF-8 to Code Page approximations. It also adds Unicode filesystem access under Windows, using preferably wfio or a COM based fallback otherwise.


Unicode handling in PHP is best performed using a combo of mbstring, iconv, intl and pcre with the u flag enabled. But when an application is expected to run on many servers, you should be aware that these 4 extensions are not always enabled.

Patchwork UTF-8 provides pure PHP implementations for 3 of those 4 extensions. pcre compiled with unicode support is required but is widely available. The following set of portability-fallbacks allows an application to run on a server even if one or more of those extensions are not enabled:


Grapheme clusters should always be considered when working with generic Unicode strings. The Patchwork\Utf8 class implements the quasi-complete set of native string functions that need UTF-8 grapheme clusters awareness. Function names, arguments and behavior carefully replicates native PHP string functions.

Some more functions are also provided to help handling UTF-8 strings:

Mirrored string functions are: strlen, substr, strpos, stripos, strrpos, strripos, strstr, stristr, strrchr, strrichr, strtolower, strtoupper, wordwrap, chr, count_chars, ltrim, ord, rtrim, trim, str_ireplace, str_pad, str_shuffle, str_split, str_word_count, strcmp, strnatcmp, strcasecmp, strnatcasecmp, strncasecmp, strncmp, strcspn, strpbrk, strrev, strspn, strtr, substr_compare, substr_count, substr_replace, ucfirst, lcfirst, ucwords, number_format, utf8_encode, utf8_decode, json_decode, filter_input, filter_input_array.

Notably missing (but hard to replicate) are printf-family functions.

The implementation favors performance over full edge cases handling. It generally works on UTF-8 normalized strings and provides filters to get them.

As the turkish locale requires special cares, a Patchwork\TurkishUtf8 class is provided for working with this locale. It clones all the features of Patchwork\Utf8 but knows about the turkish specifics.


The recommended way to install Patchwork UTF-8 is through composer. Just create a composer.json file and run the php composer.phar install command to install it:

    "require": {
        "patchwork/utf8": "~1.2"

Then, early in your bootstrap sequence, you have to configure your environment:

Run phpunit to see the code in action.

Make sure that you are confident about using UTF-8 by reading Character Sets / Character Encoding Issues and Handling UTF-8 with PHP, or PHP et UTF-8 for french readers.

You should also get familiar with the concept of Unicode Normalization and Grapheme Clusters.

Do not blindly replace all use of PHP's string functions. Most of the time you will not need to, and you will be introducing a significant performance overhead to your application.

Screen your input on the outer perimeter so that only well formed UTF-8 pass through. When dealing with badly formed UTF-8, you should not try to fix it (see Unicode Security Considerations). Instead, consider it as CP-1252 and use Patchwork\Utf8::utf8_encode() to get an UTF-8 string. Don't forget also to choose one unicode normalization form and stick to it. NFC is now the defacto standard. Patchwork\Utf8::filter() implements this behavior: it converts from CP1252 and to NFC.

This library is orthogonal to mbstring.func_overload and will not work if the php.ini setting is enabled.


Patchwork\Utf8 is free software; you can redistribute it and/or modify it under the terms of the (at your option):

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.

I hope many projects could adopt this code and together help solve the unicode subject for PHP.

Requires php Version >=5.3.0
lib-pcre Version >=7.3

The package patchwork/utf8 contains the following files

Loading the files please wait ....