zendframework/zf2 — pull request #3110 by marc-mabe (2012-11-30 08:50:10+00:00)
Title: [WIP] Stdlib\StringUtils

This class provides some basic handling of strings of different character encodings.
It comes with string wrappers for `iconv`, `mbstring`, `intl` (`grapheme_*` functions) and a wrapper for native string functions. Wrapped functions are: `strlen`, `strpos`, `substr`, `strpad`, `wordwrap`, `convert`.

So it will be up to the user which PHP extension will be used supporting the required character encoding and which one is the best for a given character encoding.

**Wrapper usage:**

The following command returns an instance of the best available string wrapper supporting all given character encodings. (If no one was found an exception will be thrown)

StringUtils::getWrapper('supported encoding'[, 'another supported encoding' [, ...]]) : StringWrapperInterface

The returned `StringWrapperInterface` simply wrappes the string functions -- there will be no error handling because of the heavy use of string functions (like in a loop) this should be up the consumer.

**More helpful methods:**

StringUtils::isSingleByteEncoding() : boolean
StringUtils::getSingleByteEncodings() : string[]
StringUtils::isValidUtf8() : boolean // using preg_match
StringUtils::registerWrapper()
StringUtils::getRegisteredWrappers() : StringWrapperInterface[]

PS:
* Character encodings are case-insensitive and will be handled in upper-case internally.
* The default order of registered wrappers are: `intl`, `mbstring`, `iconv`, `native`
* `Zend\Text\MultiByte` will be deprecated and redirected using the string wrapper
(all tests has been moved)