public static function ord(string $char): int
    {
        $h = \ord($char[0]);
        
        if ($h <= 0x7F) {
            return $h;
        }
        
        if ($h < 0xC2) {
            throw new \InvalidArgumentException('Could not get unicode codepoint for character: "' . $char . '"');
        }
        
        if ($h <= 0xDF) {
            return ($h & 0x1F) << 6 | (\ord($char[1]) & 0x3F);
        }
        
        if ($h <= 0xEF) {
            return (($h & 0x0F) << 12 | (\ord($char[1]) & 0x3F) << 6 | (\ord($char[2]) & 0x3F));
        }
        
        if ($h <= 0xF4) {
            return (($h & 0x0F) << 18 | (\ord($char[1]) & 0x3F) << 12 | (\ord($char[2]) & 0x3F) << 6 | (\ord($char[3]) & 0x3F));
        }
        
        throw new \InvalidArgumentException('Could not get unicode codepoint for character: "' . $char . '"');
    }
public static function ord(string $char): int
    {
        $h = \ord($char[0]);
        
        if ($h <= 0x7F) {
            return $h;
        }
        
        if ($h < 0xC2) {
            throw new \InvalidArgumentException('Could not get unicode codepoint for character: "' . $char . '"');
        }
        
        if ($h <= 0xDF) {
            return ($h & 0x1F) << 6 | (\ord($char[1]) & 0x3F);
        }
        
        if ($h <= 0xEF) {
            return (($h & 0x0F) << 12 | (\ord($char[1]) & 0x3F) << 6 | (\ord($char[2]) & 0x3F));
        }
        
        if ($h <= 0xF4) {
            return (($h & 0x0F) << 18 | (\ord($char[1]) & 0x3F) << 12 | (\ord($char[2]) & 0x3F) << 6 | (\ord($char[3]) & 0x3F));
        }
        
        throw new \InvalidArgumentException('Could not get unicode codepoint for character: "' . $char . '"');
    }
public static function ord ( string $ char ) : int { $ h = \ ord ( $ char [ 0 ] ) ; if ( $ h <= 0x7F ) { return $ h ; } if ( $ h < 0xC2 ) { throw new \ InvalidArgumentException ( 'Could not get unicode codepoint for character: "' . $ char . '"' ) ; } if ( $ h <= 0xDF ) { return ( $ h & 0x1F ) << 6 | ( \ ord ( $ char [ 1 ] ) & 0x3F ) ; } if ( $ h <= 0xEF ) { return ( ( $ h & 0x0F ) << 12 | ( \ ord ( $ char [ 1 ] ) & 0x3F ) << 6 | ( \ ord ( $ char [ 2 ] ) & 0x3F ) ) ; } if ( $ h <= 0xF4 ) { return ( ( $ h & 0x0F ) << 18 | ( \ ord ( $ char [ 1 ] ) & 0x3F ) << 12 | ( \ ord ( $ char [ 2 ] ) & 0x3F ) << 6 | ( \ ord ( $ char [ 3 ] ) & 0x3F ) ) ; } throw new \ InvalidArgumentException ( 'Could not get unicode codepoint for character: "' . $ char . '"' ) ; }
Get codepoint of the first UTF-8 character in the given string.

@throws \InvalidArgumentException When the input string does not start with a valid UTF-8 character.
Get codepoint of the first UTF - 8 character in the given string .