src/Debug/Utf8.php
public static function ordUtf8($str, &$offset = 0, &$char = null)
    {
        $code = \ord($str[$offset]);
        $numBytes = 1;
        if ($code >= 0x80) {            // otherwise 0xxxxxxx
            if ($code < 0xe0) {         // 110xxxxx
                $numBytes = 2;
                $code -= 0xC0;
            } elseif ($code < 0xf0) {   // 1110xxxx
                $numBytes = 3;
                $code -= 0xE0;
            } elseif ($code < 0xf8) {
                $numBytes = 4;          // 11110xxx
                $code -= 0xF0;
            }
            for ($i = 1; $i < $numBytes; $i++) {
                $code2 = \ord($str[$offset + $i]) - 0x80;        // 10xxxxxx
                $code = $code * 64 + $code2;
            }
        }
        $char = \substr($str, $offset, $numBytes);
        $offset = $offset + $numBytes;
        return $code;
    }
public static function ordUtf8($str, &$offset = 0, &$char = null)
    {
        $code = \ord($str[$offset]);
        $numBytes = 1;
        if ($code >= 0x80) {            // otherwise 0xxxxxxx
            if ($code < 0xe0) {         // 110xxxxx
                $numBytes = 2;
                $code -= 0xC0;
            } elseif ($code < 0xf0) {   // 1110xxxx
                $numBytes = 3;
                $code -= 0xE0;
            } elseif ($code < 0xf8) {
                $numBytes = 4;          // 11110xxx
                $code -= 0xF0;
            }
            for ($i = 1; $i < $numBytes; $i++) {
                $code2 = \ord($str[$offset + $i]) - 0x80;        // 10xxxxxx
                $code = $code * 64 + $code2;
            }
        }
        $char = \substr($str, $offset, $numBytes);
        $offset = $offset + $numBytes;
        return $code;
    }
public static function ordUtf8 ( $ str , & $ offset = 0 , & $ char = null ) { $ code = \ ord ( $ str [ $ offset ] ) ; $ numBytes = 1 ; if ( $ code >= 0x80 ) { // otherwise 0xxxxxxx if ( $ code < 0xe0 ) { // 110xxxxx $ numBytes = 2 ; $ code -= 0xC0 ; } elseif ( $ code < 0xf0 ) { // 1110xxxx $ numBytes = 3 ; $ code -= 0xE0 ; } elseif ( $ code < 0xf8 ) { $ numBytes = 4 ; // 11110xxx $ code -= 0xF0 ; } for ( $ i = 1 ; $ i < $ numBytes ; $ i ++ ) { $ code2 = \ ord ( $ str [ $ offset + $ i ] ) - 0x80 ; // 10xxxxxx $ code = $ code * 64 + $ code2 ; } } $ char = \ substr ( $ str , $ offset , $ numBytes ) ; $ offset = $ offset + $ numBytes ; return $ code ; }
Returns decimal code-point for multi-byte character

Use dechex to convert to hex (ie \uxxxx)

@param string  $str    A string or single character
@param integer $offset (0) Zero-based offset will be updated for offset of next char
@param string  $char   will be populated with the character found at offset

@return integer
Returns decimal code - point for multi - byte character