Xpressengine\Tag\Decomposer::ord PHP Method

ord() protected method

Return ASCII value of character
protected ord ( string $ch ) : integer | null
$ch string character
return integer | null
    protected function ord($ch)
    {
        $len = strlen($ch);
        if ($len <= 0) {
            return null;
        }
        $h = ord($ch[0]);
        if ($h <= 0x7f) {
            return $h;
        }
        if ($h < 0xc2) {
            return null;
        }
        if ($h <= 0xdf && $len > 1) {
            return ($h & 0x1f) << 6 | ord($ch[1]) & 0x3f;
        }
        if ($h <= 0xef && $len > 2) {
            return ($h & 0xf) << 12 | (ord($ch[1]) & 0x3f) << 6 | ord($ch[2]) & 0x3f;
        }
        if ($h <= 0xf4 && $len > 3) {
            return ($h & 0xf) << 18 | (ord($ch[1]) & 0x3f) << 12 | (ord($ch[2]) & 0x3f) << 6 | ord($ch[3]) & 0x3f;
        }
    }