How could i translate this PHP-Code to Java Code?
protected function readInt24()
{
$ret = 0;
if (strlen($this->_input) >= 3)
{
$ret = ord(substr($this->_input, 0, 1)) << 16;
$ret |= ord(substr($this->_input, 1, 1)) << 8;
$ret |= ord(substr($this->_input, 2, 1)) << 0;
$this->_input = substr($this->_input, 3);
}
return $ret;
}
$input is a quite crazy String which contains utf characters (afaik): �8� or so
The 3
ord(substr($this->_input, ..., ...))retrieves the ASCII values of the three first characters of the string. For each there is then a left shift which is then or’ed with return.This would translate in Java as something like:
Note that the PHP code then truncates the instance variable
_inputto be just 3 char long.