/** * Encoding Multi-byte Integers from Section 5.1 */ public static function intToMBUInt32(&$out, $i) { if ($i > 268435455) { $bytes0 = 0 | Horde_Xml_Wbxml::getBits(0, $i); $bytes1 = 128 | Horde_Xml_Wbxml::getBits(1, $i); $bytes2 = 128 | Horde_Xml_Wbxml::getBits(2, $i); $bytes3 = 128 | Horde_Xml_Wbxml::getBits(3, $i); $bytes4 = 128 | Horde_Xml_Wbxml::getBits(4, $i); $out .= chr($bytes4) . chr($bytes3) . chr($bytes2) . chr($bytes1) . chr($bytes0); } elseif ($i > 2097151) { $bytes0 = 0 | Horde_Xml_Wbxml::getBits(0, $i); $bytes1 = 128 | Horde_Xml_Wbxml::getBits(1, $i); $bytes2 = 128 | Horde_Xml_Wbxml::getBits(2, $i); $bytes3 = 128 | Horde_Xml_Wbxml::getBits(3, $i); $out .= chr($bytes3) . chr($bytes2) . chr($bytes1) . chr($bytes0); } elseif ($i > 16383) { $bytes0 = 0 | Horde_Xml_Wbxml::getBits(0, $i); $bytes1 = 128 | Horde_Xml_Wbxml::getBits(1, $i); $bytes2 = 128 | Horde_Xml_Wbxml::getBits(2, $i); $out .= chr($bytes2) . chr($bytes1) . chr($bytes0); } elseif ($i > 127) { $bytes0 = 0 | Horde_Xml_Wbxml::getBits(0, $i); $bytes1 = 128 | Horde_Xml_Wbxml::getBits(1, $i); $out .= chr($bytes1) . chr($bytes0); } else { $bytes0 = 0 | Horde_Xml_Wbxml::getBits(0, $i); $out .= chr($bytes0); } }