public static function utf8ToCodepoint( $char ) {
		# Find the length
		$z = ord( $char[0] );
		if ( $z & 0x80 ) {
			$length = 0;
			while ( $z & 0x80 ) {
				$length++;
				$z <<= 1;
			}
		} else {
			$length = 1;
		}

		if ( $length != strlen( $char ) ) {
			return false;
		}

		if ( $length == 1 ) {
			return ord( $char );
		}

		# Mask off the length-determining bits and shift back to the original location
		$z &= 0xff;
		$z >>= $length;

		# Add in the free bits from subsequent bytes
		for ( $i = 1; $i < $length; $i++ ) {
			$z <<= 6;
			$z |= ord( $char[$i] ) & 0x3f;
		}

		return $z;
	}
public static function utf8ToCodepoint( $char ) {
		# Find the length
		$z = ord( $char[0] );
		if ( $z & 0x80 ) {
			$length = 0;
			while ( $z & 0x80 ) {
				$length++;
				$z <<= 1;
			}
		} else {
			$length = 1;
		}

		if ( $length != strlen( $char ) ) {
			return false;
		}

		if ( $length == 1 ) {
			return ord( $char );
		}

		# Mask off the length-determining bits and shift back to the original location
		$z &= 0xff;
		$z >>= $length;

		# Add in the free bits from subsequent bytes
		for ( $i = 1; $i < $length; $i++ ) {
			$z <<= 6;
			$z |= ord( $char[$i] ) & 0x3f;
		}

		return $z;
	}
public static function utf8ToCodepoint ( $ char ) { # Find the length $ z = ord ( $ char [ 0 ] ) ; if ( $ z & 0x80 ) { $ length = 0 ; while ( $ z & 0x80 ) { $ length ++ ; $ z <<= 1 ; } } else { $ length = 1 ; } if ( $ length != strlen ( $ char ) ) { return false ; } if ( $ length == 1 ) { return ord ( $ char ) ; } # Mask off the length-determining bits and shift back to the original location $ z &= 0xff ; $ z >>= $ length ; # Add in the free bits from subsequent bytes for ( $ i = 1 ; $ i < $ length ; $ i ++ ) { $ z <<= 6 ; $ z |= ord ( $ char [ $ i ] ) & 0x3f ; } return $ z ; }
Determine the Unicode codepoint of a single-character UTF-8 sequence.
Does not check for invalid input data.

@param string $char
@return int
Determine the Unicode codepoint of a single - character UTF - 8 sequence . Does not check for invalid input data .