Horde_Xml_Wbxml::intToMBUInt32 PHP Method

intToMBUInt32() public static method

Encoding Multi-byte Integers from Section 5.1
public static intToMBUInt32 ( &$out, $i )
    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);
        }
    }

Usage Example

Ejemplo n.º 1
0
 public function endElement($uri, $name)
 {
     if ($this->_subParser == null) {
         $this->_output .= chr(Horde_Xml_Wbxml::GLOBAL_TOKEN_END);
     } else {
         $this->_subParser->endElement($uri, $name);
         $this->_subParserStack--;
         if ($this->_subParserStack == 0) {
             $this->_output .= chr(Horde_Xml_Wbxml::GLOBAL_TOKEN_OPAQUE);
             Horde_Xml_Wbxml::intToMBUInt32($this->_output, strlen($this->_subParser->getOutput()));
             $this->_output .= $this->_subParser->getOutput();
             $this->_subParser = null;
         }
     }
 }