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 & 0x0F) << 12 | (ord($c[$index + 1]) & 0x3F) << 6 | (ord($c[$index + 2]) & 0x3F);
			
		// four-byte
		} elseif ($o <= 0xF4 && $index < $l - 3) {
			$i += 3;
			return ($o & 0x0F) << 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;
		}
	}
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 & 0x0F) << 12 | (ord($c[$index + 1]) & 0x3F) << 6 | (ord($c[$index + 2]) & 0x3F);
			
		// four-byte
		} elseif ($o <= 0xF4 && $index < $l - 3) {
			$i += 3;
			return ($o & 0x0F) << 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;
		}
	}
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 & 0x0F ) << 12 | ( ord ( $ c [ $ index + 1 ] ) & 0x3F ) << 6 | ( ord ( $ c [ $ index + 2 ] ) & 0x3F ) ; // four-byte } elseif ( $ o <= 0xF4 && $ index < $ l - 3 ) { $ i += 3 ; return ( $ o & 0x0F ) << 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 ; } }
Returns the unicode value of the string

@param string $c The source string
@param integer $i The index to get the char from (passed by reference for use in a loop)
@return integer The value of the char at $c[$i]
@author kerry at shetline dot com
@author Dom Hastings - modified to suit my needs
@see http://www.php.net/manual/en/function.ord.php#78032
Returns the unicode value of the string