compared with
Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (27)

View Page History
h2. Introduction
<h2>Introduction</h2>

<p>This document describes a request for a string helper class within Zend Framework. <br />
The reason I wrote this RFC was based on believing working with strings of different and/or multi-byte character sets in PHP isn't that simple as the build-in string functions supported by PHP.</p>

h2. Currently used in Zend Framework
<h2>Currently used in Zend Framework</h2>

<p>Until now ext/iconv is often used to work with character sets within Zend Framework. But sometimes it's not enough because it isn't installed everywhere. You shouldn't hard require ext/iconv.</p>

<ul>
* There <li>There is another extension ext/mbstring that can be used, too.</li>
* For <li>For working with UTF-8 only the grapheme functions of intl should be enough.</li>
* For <li>For working with single byte character sets the native build-in function are better than enough.</li>
</ul>

h2. What should the utility solve and contain.

The utility class (or set of classes) should contain methods to work with different character sets like strlen, substr etc. It should contain methods to identify character set byte lengths and it should be as fast as possible because of high frequency method calls.
<h2>What should the utility solve and contain.</h2>

This should solve the hard requirement of ext/iconv so users can choose the favorite extension for working with different character sets.
<p>The utility class (or set of classes) should contain methods to work with different character sets like strlen, substr etc. It should contain methods to identify character set byte lengths and it should be as fast as possible because of high frequency method calls.</p>

h2. Where should the class live in?
<p>This should solve the hard requirement of ext/iconv so users can choose the favorite extension for working with different character sets.</p>

Because of tons of components working with ext/iconv or ext/mbstring currently the class could live in Zend\Stdlib but Zend\Text or an own namespace could be possible.
<h2>Where should the class live in?</h2>

h3. How should it be implemented
<p>Because of tons of components working with ext/iconv or ext/mbstring currently the class could live in Zend\Stdlib but Zend\Text or an own namespace could be possible.</p>

For now did some performance tests how to make a great performance possible.
The fasted is using an adapter for each wrapper class and a static base class for basic methods like "isCharsetSingleByte()". The static class contains a specialized getter to get the best available wrapper for a given character set to work with.
<h3>How should it be implemented</h3>

The current implementation is available @ https://github.com/marc-mabe/zf2/blob/string/library/Zend/Stdlib/StringUtils.php
<p>For now did some performance tests how to make a great performance possible.<br />
The fasted is using an adapter for each wrapper class and a static base class for basic methods like &quot;isCharsetSingleByte()&quot;. The static class contains a specialized getter to get the best available wrapper for a given character set to work with.</p>

<p>The current implementation is available @ <a class="external-link" href="https://github.com/marc-mabe/zf2/blob/string/library/Zend/Stdlib/StringUtils.php">https://github.com/marc-mabe/zf2/blob/string/library/Zend/Stdlib/StringUtils.php</a></p>