ActiveResource\ActiveResource::_unicode_ord PHP Метод

_unicode_ord() публичный метод

Returns the unicode value of the string
См. также: http://www.php.net/manual/en/function.ord.php#78032
Автор: kerry at shetline dot com
Автор: Dom Hastings - modified to suit my needs
public _unicode_ord ( string &$c, integer &$i ) : integer
$c string The source string
$i integer The index to get the char from (passed by reference for use in a loop)
Результат integer The value of the char at $c[$i]
    public function _unicode_ord(&$c, &$i = 0)
    {
        // get the character length
        $l = strlen($c);
        // copy the offset
        $index = $i;
        // check it's a valid offset
        if ($index >= $l) {
            return false;
        }
        // check the value
        $o = ord($c[$index]);
        // if it's ascii
        if ($o <= 0x7f) {
            return $o;
            // not sure what it is...
        } elseif ($o < 0xc2) {
            return false;
            // if it's a two-byte character
        } elseif ($o <= 0xdf && $index < $l - 1) {
            $i += 1;
            return ($o & 0x1f) << 6 | ord($c[$index + 1]) & 0x3f;
            // three-byte
        } elseif ($o <= 0xef && $index < $l - 2) {
            $i += 2;
            return ($o & 0xf) << 12 | (ord($c[$index + 1]) & 0x3f) << 6 | ord($c[$index + 2]) & 0x3f;
            // four-byte
        } elseif ($o <= 0xf4 && $index < $l - 3) {
            $i += 3;
            return ($o & 0xf) << 18 | (ord($c[$index + 1]) & 0x3f) << 12 | (ord($c[$index + 2]) & 0x3f) << 6 | ord($c[$index + 3]) & 0x3f;
            // not sure what it is...
        } else {
            return false;
        }
    }