1<?php 2############################################################################# 3# Grapheme constants. 4############################################################################# 5 6 /** 7 * grapheme_extract extract_type 8 * 9 */ 10 /** Extract the given number of whole grapheme clusters from the string: */ 11 define('GRAPHEME_EXTR_COUNT', 0); 12 /** Extract as many whole grapheme clusters as will fit into the given number of bytes: */ 13 define('GRAPHEME_EXTR_MAXBYTES', 1); 14 /** Extract whole grapheme clusters up to a maximum number of UTF-8 characters: */ 15 define('GRAPHEME_EXTR_MAXCHARS', 2); 16 17 18############################################################################# 19# Grapheme API 20############################################################################# 21 22 /** 23 * Get string length in grapheme units 24 * @param string $input The string being measured for length. 25 * @return int The length of the string on success, and 0 if the string is empty. 26 */ 27 function grapheme_strlen($input) {} 28 29 /** 30 * Find position (in grapheme units) of first occurrence of a string 31 * @param string $haystack The string to look in 32 * @param string $needle The string to look for 33 * @param [int] $offset The optional offset parameter allows you to specify 34 which character in haystack to start searching. The position 35 returned is still relative to the beginning of haystack. 36 * @return int Returns the position as an integer. If needle is not found, strpos() will return boolean FALSE. 37 */ 38 function grapheme_strpos($haystack, $needle, $offset = 0) {} 39 40 41 /** 42 * Find position (in grapheme units) of first occurrence of a case-insensitive string 43 * @param string $haystack The string to look in 44 * @param string $needle The string to look for 45 * @param [int] $offset The optional offset parameter allows you to specify 46 which character in haystack to start searching. The position 47 returned is still relative to the beginning of haystack. 48 * @return int Returns the position as an integer. If needle is not found, grapheme_stripos() will return boolean FALSE. 49 */ 50 function grapheme_stripos($haystack, $needle, $offset = 0) {} 51 52 53 /** 54 * Find position (in grapheme units) of last occurrence of a string 55 * @param string $haystack The string to look in 56 * @param string $needle The string to look for 57 * @param [int] $offset The optional offset parameter allows you to specify 58 which character in haystack to start searching. The position 59 returned is still relative to the beginning of haystack. 60 * @return int Returns the position as an integer. If needle is not found, grapheme_strrpos() will return boolean FALSE. 61 */ 62 function grapheme_strrpos($haystack, $needle, $offset = 0) {} 63 64 65 /** 66 * Find position (in grapheme units) of last occurrence of a case-insensitive string 67 * @param string $haystack The string to look in 68 * @param string $needle The string to look for 69 * @param [int] $offset The optional offset parameter allows you to specify 70 which character in haystack to start searching. The position 71 returned is still relative to the beginning of haystack. 72 * @return int Returns the position as an integer. If needle is not found, grapheme_strripos() will return boolean FALSE. 73 */ 74 function grapheme_strripos($haystack, $needle, $offset = 0) {} 75 76 77 /** 78 * Return part of a string 79 * @param string $string The input string. 80 * @param int $start If start is non-negative, the returned string will start at the 81 start'th position in string, counting from zero. If start is negative, 82 the returned string will start at the start'th character from the 83 end of string. 84 * @param [int] $length If length is given and is positive, the string returned will contain 85 at most length characters beginning from start (depending on the 86 length of string). If string is less than or equal to start characters 87 long, FALSE will be returned. If length is given and is negative, then 88 that many characters will be omitted from the end of string (after the 89 start position has been calculated when a start is negative). If start 90 denotes a position beyond this truncation, an empty string will be returned. 91 * @return int Returns the extracted part of string. 92 */ 93 function grapheme_substr($string, $start, $length = -1) {} 94 95 96 /** 97 * Returns part of haystack string from the first occurrence of needle to the end of haystack. 98 * @param string $haystack The input string. 99 * @param string $needle The string to look for. 100 * @param [boolean] $before_needle If TRUE (the default is FALSE), grapheme_strstr() returns the part of the 101 haystack before the first occurrence of the needle. 102 * @return string Returns the portion of string, or FALSE if needle is not found. 103 */ 104 function grapheme_strstr($haystack, $needle, $before_needle = FALSE) {} 105 106 107 /** 108 * Returns part of haystack string from the first occurrence of case-insensitive needle to the end of haystack. 109 * @param string $haystack The input string. 110 * @param string $needle The string to look for. 111 * @param [boolean] $before_needle If TRUE (the default is FALSE), grapheme_strstr() returns the part of the 112 haystack before the first occurrence of the needle. 113 * @return string Returns the portion of string, or FALSE if needle is not found. 114 */ 115 function grapheme_stristr($haystack, $needle, $before_needle = FALSE) {} 116 117 118 /** 119 * Function to extract a sequence of default grapheme clusters from a text buffer, which must be encoded in UTF-8. 120 * @param string $haystack string to search 121 * @param int $size maximum number of units - based on the $extract_type - to return 122 * @param [int] $extract_type one of GRAPHEME_EXTR_COUNT (default), GRAPHEME_EXTR_MAXBYTES, or GRAPHEME_EXTR_MAXCHARS 123 * @param [int] $start starting position in $haystack in bytes 124 * @param [&int] $next set to next starting position in bytes 125 * @return string A string starting at offset $start containing no more than $size grapheme clusters 126 and ending on a default grapheme cluster boundary. 127 */ 128 function grapheme_extract($haystack, $size, $extract_type = GRAPHEME_EXTR_COUNT, $start = 0, &$next) {} 129 130?> 131