IO_Bit 2.2.1 をリリースしました
getSI16BE と getSI32BE を追加しました。(getSI16LE, getSI32LE は前からあります)
IO_ICC で必要だったので追加。
追加イメージ
function getUI16BE() { $this->byteAlign(); if (strlen($this->_data) < $this->_byte_offset + 2) { $data_len = strlen($this->_data); $offset = $this->_byte_offset; throw new IO_Bit_Exception("getUI16BE: $data_len < $offset + 2"); } $ret = unpack('n', substr($this->_data, $this->_byte_offset, 2)); $this->_byte_offset += 2; return $ret[1]; } function getSI16BE() { $value = $this->getUI16BE(); if ($value < 0x8000) { return $value; } return $value - 0x10000; // 2-negative } function getUI32BE() { $value = $this->getSI32BE(); // PHP bugs if ($value < 0) { $value += 4294967296; } return $value; } function getSI32BE() { $this->byteAlign(); if (strlen($this->_data) < $this->_byte_offset + 4) { $data_len = strlen($this->_data); $offset = $this->_byte_offset; throw new IO_Bit_Exception("getUI32BE: $data_len < $offset + 4"); } $ret = unpack('N', substr($this->_data, $this->_byte_offset, 4)); $this->_byte_offset += 4; $value = $ret[1]; return $value; }