original_string: function utf8_byte2char_pos($str, $pos) {
  		$n = 0; // number of characters
  		for ($i = $pos; $i > 0; $i--) {
  			$c = (int) ord($str{$i});
  			if (!($c & 0x80)) // single-byte (0xxxxxx)
  			{
  				$n++;
  			}
  			elseif (($c & 0xC0) == 0xC0) // multi-byte starting byte (11xxxxxx)
  			{
  				$n++;
  			}
  		}
  		if (!strlen($str{$i})) {
  			return FALSE;
  		} // offset beyond string length
  
  		return $n;
  	}
code: function utf8_byte2char_pos($str, $pos) {
  		$n = 0; // number of characters
  		for ($i = $pos; $i > 0; $i--) {
  			$c = (int) ord($str{$i});
  			if (!($c & 0x80)) // single-byte (0xxxxxx)
  			{
  				$n++;
  			}
  			elseif (($c & 0xC0) == 0xC0) // multi-byte starting byte (11xxxxxx)
  			{
  				$n++;
  			}
  		}
  		if (!strlen($str{$i})) {
  			return FALSE;
  		} // offset beyond string length
  
  		return $n;
  	}
code_tokens: function utf8_byte2char_pos ( $ str , $ pos ) { $ n = 0 ; // number of characters for ( $ i = $ pos ; $ i > 0 ; $ i -- ) { $ c = ( int ) ord ( $ str { $ i } ) ; if ( ! ( $ c & 0x80 ) ) // single-byte (0xxxxxx) { $ n ++ ; } elseif ( ( $ c & 0xC0 ) == 0xC0 ) // multi-byte starting byte (11xxxxxx) { $ n ++ ; } } if ( ! strlen ( $ str { $ i } ) ) { return FALSE ; } // offset beyond string length return $ n ; }
docstring: Translates an 'absolute' byte position into a character position.
  Unit tested by Kasper.
  
  @param	string		UTF-8 string
  @param	integer		byte position
  @return	integer		character position
  @author	Martin Kutschker <martin.t.kutschker@blackbox.net>
docstring_tokens: Translates an absolute byte position into a character position . Unit tested by Kasper .