compared with
Current by Marc Bennewitz (private)
on Jul 13, 2012 07:15.

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

Changes (23)

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>
There is another extension ext/mbstring that can be used, too. As Fallback build-in functions can be used to handle single byte character sets.

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

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.

This should solve the hard requirement of ext/iconv so users can choose the favorite extension for working with different character sets.
<h2>What should the utility solve and contain.</h2>

h2. Where should the class live in?
<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>

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>This should solve the hard requirement of ext/iconv so users can choose the favorite extension for working with different character sets.</p>

h3. How should it be implemented
<h2>Where should the class live in?</h2>

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.
<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>

The current implementation is available @ https://github.com/marc-mabe/zf2/blob/string/library/Zend/Stdlib/StringUtils.php
<h3>How should it be implemented</h3>

<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>