
Many components use own unicode support functions. There is no clear way what extension should be used for multibyte, some components use iconv some mbstring.
* byteorder
Many components need byteorder dependent way to work with binary data. Right now custom functions are in: {{Pdf/BinaryParser}}, {{Serializer}}, {{Amf/Util/BinaryStream}}, {{Filter/Compress}}, and many others.
* machine byteorder dependent behaviour of {{pack/unpack()}}
From PHP manual: "PHP internally stores integral values as signed. If you unpack a large unsigned long and it is of the same size as PHP internally stored values the result will be a negative number even though unsigned unpacking was specified."
BinUtils could address that with wrapper function.
* unified way to get int/float from binary representation
Right now custom functions for this are in: {{Pdf/BinaryParser}}, {{Serializer}}
* unified way to perform bitwise operations on binary data
functions like {{setBit}}, {{clearBit}}, {{testBit}}
h2. Prototype
[https://github.com/marc-mabe/zf2/tree/env/library/Zend/Stdlib]
{code}
namespace Zend\Stdlib;
class Enviroment
{
public static function is32Bit();
public static function is64Bit();
public static function isWindows();
/*
public static function isUnix();
public static function isLinux();
public static function isBsd();
public static function isSolaris();
public static function isDarwin();
public static function isCygwin()
...
*/
}
class StringUtils
{
public static function hasMbString();
public static function hasIconv();
public static function isPcreUnicodeAware();
public static function isSingleByteCharset($charset);
public static function length($input, $charset = 'utf-8');
public static function indexOf($haystack, $needle, $offset = 0, $charset = 'utf-8');
public static function lastIndexOf($haystack, $needle, $offset = 0, $charset = 'utf-8');
public static function subset($input, $offset, $length = 0, $charset = 'utf-8');
// moved from Zend\Text\MultiByte
public static function wordWrap($string, $width = 75, $break = "\n", $cut = false, $charset = 'utf-8');
public static function strPad($input, $padLength, $padString = ' ', $padType = STR_PAD_RIGHT, $charset = 'utf-8');
}
class BinaryUtils
{
const BYTEORDER_MACHINE = 0;
const BYTEORDER_LE = 1;
const BYTEORDER_BE = 2;
public static function isLittleEndian();
public static function isBigEndian();
public static function length($input);
public static function indexOf($haystack, $needle, $offset = 0);
public static function lastIndexOf($haystack, $needle, $offset = 0);
public static function subset($input, $offset, $length = 0);
}
{code}