grapheme.phpt 70 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192
  1. --TEST--
  2. grapheme()
  3. --SKIPIF--
  4. <?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
  5. --FILE--
  6. <?php
  7. /*
  8. * Test grapheme functions (procedural only)
  9. */
  10. function ut_main()
  11. {
  12. $res_str = '';
  13. $char_a_diaeresis = "\xC3\xA4"; // 'LATIN SMALL LETTER A WITH DIAERESIS' (U+00E4)
  14. $char_a_ring = "\xC3\xA5"; // 'LATIN SMALL LETTER A WITH RING ABOVE' (U+00E5)
  15. $char_o_diaeresis = "\xC3\xB6"; // 'LATIN SMALL LETTER O WITH DIAERESIS' (U+00F6)
  16. $char_O_diaeresis = "\xC3\x96"; // 'LATIN CAPITAL LETTER O WITH DIAERESIS' (U+00D6)
  17. $char_angstrom_sign = "\xE2\x84\xAB"; // 'ANGSTROM SIGN' (U+212B)
  18. $char_A_ring = "\xC3\x85"; // 'LATIN CAPITAL LETTER A WITH RING ABOVE' (U+00C5)
  19. $char_ohm_sign = "\xE2\x84\xA6"; // 'OHM SIGN' (U+2126)
  20. $char_omega = "\xCE\xA9"; // 'GREEK CAPITAL LETTER OMEGA' (U+03A9)
  21. $char_combining_ring_above = "\xCC\x8A"; // 'COMBINING RING ABOVE' (U+030A)
  22. $char_fi_ligature = "\xEF\xAC\x81"; // 'LATIN SMALL LIGATURE FI' (U+FB01)
  23. $char_long_s_dot = "\xE1\xBA\x9B"; // 'LATIN SMALL LETTER LONG S WITH DOT ABOVE' (U+1E9B)
  24. // the word 'hindi' using Devanagari characters:
  25. $hindi = "\xe0\xa4\xb9\xe0\xa4\xbf\xe0\xa4\xa8\xe0\xa5\x8d\xe0\xa4\xa6\xe0\xa5\x80";
  26. $char_a_ring_nfd = "a\xCC\x8A";
  27. $char_A_ring_nfd = "A\xCC\x8A";
  28. $char_o_diaeresis_nfd = "o\xCC\x88";
  29. $char_O_diaeresis_nfd = "O\xCC\x88";
  30. $char_diaeresis = "\xCC\x88";
  31. //=====================================================================================
  32. $res_str .= "\n" . 'function grapheme_strlen($string) {}' . "\n\n";
  33. $res_str .= "\"hindi\" in devanagari strlen " . grapheme_strlen($hindi) . "\n";
  34. $res_str .= "\"ab\" + \"hindi\" + \"cde\" strlen " . grapheme_strlen('ab' . $hindi . 'cde') . "\n";
  35. $res_str .= "\"\" strlen " . grapheme_strlen("") . "\n";
  36. $res_str .= "char_a_ring_nfd strlen " . grapheme_strlen($char_a_ring_nfd) . "\n";
  37. $res_str .= "char_a_ring_nfd + \"bc\" strlen " . grapheme_strlen($char_a_ring_nfd . 'bc') . "\n";
  38. $res_str .= "\"abc\" strlen " . grapheme_strlen('abc') . "\n";
  39. //=====================================================================================
  40. $res_str .= "\n" . 'function grapheme_strpos($haystack, $needle, $offset = 0) {}' . "\n\n";
  41. $tests = array(
  42. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", 5 ),
  43. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "o", "false" ),
  44. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, $char_o_diaeresis_nfd, 4 ),
  45. array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, 2 ),
  46. array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, 1 ),
  47. array( "abc", $char_a_ring_nfd, "false" ),
  48. array( $char_a_ring_nfd . "bc", "a", "false" ),
  49. array( "abc", "d", "false" ),
  50. array( "abc", "c", 2 ),
  51. array( "abc", "b", 1 ),
  52. array( "abc", "a", 0 ),
  53. array( "abc", "a", 0, 0 ),
  54. array( "abc", "a", 1, "false" ),
  55. array( "ababc", "a", 1, 2 ),
  56. array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", 2, 6 ),
  57. array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, 2, 3 ),
  58. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "opq", "op", 5 ),
  59. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "opq", "opq", 5 ),
  60. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "abc", "false" ),
  61. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "bc" . $char_o_diaeresis_nfd, $char_o_diaeresis_nfd . "bc" . $char_o_diaeresis_nfd, 4 ),
  62. array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd . "bc", 2 ),
  63. array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd . "bc", 1 ),
  64. array( "abc", $char_a_ring_nfd . "bc", "false" ),
  65. array( $char_a_ring_nfd . "bc", "abcdefg", "false" ),
  66. array( "abc", "defghijklmnopq", "false" ),
  67. array( "abc", "ab", 0 ),
  68. array( "abc", "bc", 1 ),
  69. array( "abc", "abc", 0 ),
  70. array( "abc", "abcd", "false" ),
  71. array( "abc", "ab", 0, 0 ),
  72. array( "abc", "abc", 0, 0 ),
  73. array( "abc", "abc", 1, "false" ),
  74. array( "ababc", "ab", 1, 2 ),
  75. array( "ababc", "abc", 1, 2 ),
  76. array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o" . $char_a_ring_nfd . "bc", "o" . $char_a_ring_nfd . "bc", 2, 6 ),
  77. array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_a_ring_nfd . "bc" . $char_a_ring_nfd . "def", $char_a_ring_nfd . "bc" . $char_a_ring_nfd, 2, 3 ),
  78. );
  79. foreach( $tests as $test ) {
  80. $arg1 = urlencode($test[1]);
  81. $arg0 = urlencode($test[0]);
  82. $res_str .= "find \"$arg1\" in \"$arg0\" - grapheme_strpos";
  83. if ( 3 == count( $test ) ) {
  84. $result = grapheme_strpos($test[0], $test[1]);
  85. }
  86. else {
  87. $res_str .= " from $test[2]";
  88. $result = grapheme_strpos($test[0], $test[1], $test[2]);
  89. }
  90. $res_str .= " = ";
  91. if ( $result === false ) {
  92. $res_str .= 'false';
  93. }
  94. else {
  95. $res_str .= $result;
  96. }
  97. $res_str .= " == " . $test[count($test)-1] . check_result($result, $test[count($test)-1]) . "\n";
  98. }
  99. //=====================================================================================
  100. $res_str .= "\n" . 'function grapheme_stripos($haystack, $needle, $offset = 0) {}' . "\n\n";
  101. $tests = array(
  102. array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", "o", 2, 6 ),
  103. array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_A_ring_nfd . "bc", $char_a_ring_nfd, 2, 3 ),
  104. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", "o", 5 ),
  105. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "O", "false" ),
  106. array( "a" . $char_a_ring_nfd . "bc" . $char_O_diaeresis_nfd, $char_o_diaeresis_nfd, 4 ),
  107. array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_A_ring_nfd, 2 ),
  108. array( "a" . $char_A_ring_nfd . "bc", $char_a_ring_nfd, 1 ),
  109. array( "Abc", $char_a_ring_nfd, "false" ),
  110. array( $char_a_ring_nfd . "bc", "A", "false" ),
  111. array( "abc", "D", "false" ),
  112. array( "abC", "c", 2 ),
  113. array( "abc", "B", 1 ),
  114. array( "Abc", "a", 0 ),
  115. array( "abc", "A", 0, 0 ),
  116. array( "Abc", "a", 1, "false" ),
  117. array( "ababc", "A", 1, 2 ),
  118. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", "oP", 5 ),
  119. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", "opQ", 5 ),
  120. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "abc", "false" ),
  121. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "bC" . $char_o_diaeresis_nfd, $char_O_diaeresis_nfd . "bc" . $char_o_diaeresis_nfd, 4 ),
  122. array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "Bc", $char_A_ring_nfd . "bc", 2 ),
  123. array( "a" . $char_a_ring_nfd . "BC", $char_a_ring_nfd . "bc", 1 ),
  124. array( "abc", $char_a_ring_nfd . "BC", "false" ),
  125. array( $char_a_ring_nfd . "BC", "aBCdefg", "false" ),
  126. array( "aBC", "Defghijklmnopq", "false" ),
  127. array( "abC", "Ab", 0 ),
  128. array( "aBC", "bc", 1 ),
  129. array( "abC", "Abc", 0 ),
  130. array( "abC", "aBcd", "false" ),
  131. array( "ABc", "ab", 0, 0 ),
  132. array( "aBc", "abC", 0, 0 ),
  133. array( "abc", "aBc", 1, "false" ),
  134. array( "ABabc", "AB", 1, 2 ),
  135. array( "abaBc", "aBc", 1, 2 ),
  136. array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o" . $char_A_ring_nfd . "bC", "O" . $char_a_ring_nfd . "bC", 2, 6 ),
  137. array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_A_ring_nfd . "bC" . $char_a_ring_nfd . "def", $char_a_ring_nfd . "Bc" . $char_a_ring_nfd, 2, 3 ),
  138. );
  139. foreach( $tests as $test ) {
  140. $arg1 = urlencode($test[1]);
  141. $arg0 = urlencode($test[0]);
  142. $res_str .= "find \"$arg1\" in \"$arg0\" - grapheme_stripos";
  143. if ( 3 == count( $test ) ) {
  144. $result = grapheme_stripos($test[0], $test[1]);
  145. }
  146. else {
  147. $res_str .= " from $test[2]";
  148. $result = grapheme_stripos($test[0], $test[1], $test[2]);
  149. }
  150. $res_str .= " = ";
  151. if ( $result === false ) {
  152. $res_str .= 'false';
  153. }
  154. else {
  155. $res_str .= $result;
  156. }
  157. $res_str .= " == " . $test[count($test)-1] . check_result($result, $test[count($test)-1]) . "\n";
  158. }
  159. //=====================================================================================
  160. $res_str .= "\n" . 'function grapheme_strrpos($haystack, $needle, $offset = 0) {}' . "\n\n";
  161. $tests = array(
  162. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", 5 ),
  163. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "o", "false" ),
  164. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, $char_o_diaeresis_nfd, 4 ),
  165. array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, 2 ),
  166. array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, 1 ),
  167. array( "abc", $char_a_ring_nfd, "false" ),
  168. array( $char_a_ring_nfd . "bc", "a", "false" ),
  169. array( "abc", "d", "false" ),
  170. array( "abc", "c", 2 ),
  171. array( "abc", "b", 1 ),
  172. array( "abc", "a", 0 ),
  173. array( "abc", "a", 0, 0 ),
  174. array( "abc", "a", 1, "false" ),
  175. array( "ababc", "a", 1, 2 ),
  176. array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", 2, 6 ),
  177. array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, 2, 3 ),
  178. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "opq", "op", 5 ),
  179. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "opq", "opq", 5 ),
  180. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "abc", "false" ),
  181. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "bc" . $char_o_diaeresis_nfd, $char_o_diaeresis_nfd . "bc" . $char_o_diaeresis_nfd, 4 ),
  182. array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd . "bc", 2 ),
  183. array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd . "bc", 1 ),
  184. array( "abc", $char_a_ring_nfd . "bc", "false" ),
  185. array( $char_a_ring_nfd . "bc", "abcdefg", "false" ),
  186. array( "abc", "defghijklmnopq", "false" ),
  187. array( "abc", "ab", 0 ),
  188. array( "abc", "bc", 1 ),
  189. array( "abc", "abc", 0 ),
  190. array( "abc", "abcd", "false" ),
  191. array( "abc", "ab", 0, 0 ),
  192. array( "abc", "abc", 0, 0 ),
  193. array( "abc", "abc", 1, "false" ),
  194. array( "ababc", "ab", 1, 2 ),
  195. array( "ababc", "abc", 1, 2 ),
  196. array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o" . $char_a_ring_nfd . "bc", "o" . $char_a_ring_nfd . "bc", 2, 6 ),
  197. array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_a_ring_nfd . "bc" . $char_a_ring_nfd . "def", $char_a_ring_nfd . "bc" . $char_a_ring_nfd, 2, 3 ),
  198. );
  199. foreach( $tests as $test ) {
  200. $arg1 = urlencode($test[1]);
  201. $arg0 = urlencode($test[0]);
  202. $res_str .= "find \"$arg1\" in \"$arg0\" - grapheme_strrpos";
  203. if ( 3 == count( $test ) ) {
  204. $result = grapheme_strrpos($test[0], $test[1]);
  205. }
  206. else {
  207. $res_str .= " from $test[2]";
  208. $result = grapheme_strrpos($test[0], $test[1], $test[2]);
  209. }
  210. $res_str .= " = ";
  211. if ( $result === false ) {
  212. $res_str .= 'false';
  213. }
  214. else {
  215. $res_str .= $result;
  216. }
  217. $res_str .= " == " . $test[count($test)-1] . check_result($result, $test[count($test)-1]) . "\n";
  218. }
  219. //=====================================================================================
  220. $res_str .= "\n" . 'function grapheme_strripos($haystack, $needle, $offset = 0) {}' . "\n\n";
  221. $tests = array(
  222. array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", "o", 2, 6 ),
  223. array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_A_ring_nfd . "bc", $char_a_ring_nfd, 2, 3 ),
  224. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", "o", 5 ),
  225. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "O", "false" ),
  226. array( "a" . $char_a_ring_nfd . "bc" . $char_O_diaeresis_nfd, $char_o_diaeresis_nfd, 4 ),
  227. array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_A_ring_nfd, 2 ),
  228. array( "a" . $char_A_ring_nfd . "bc", $char_a_ring_nfd, 1 ),
  229. array( "Abc", $char_a_ring_nfd, "false" ),
  230. array( $char_a_ring_nfd . "bc", "A", "false" ),
  231. array( "abc", "D", "false" ),
  232. array( "abC", "c", 2 ),
  233. array( "abc", "B", 1 ),
  234. array( "Abc", "a", 0 ),
  235. array( "abc", "A", 0, 0 ),
  236. array( "Abc", "a", 1, "false" ),
  237. array( "ababc", "A", 1, 2 ),
  238. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", "oP", 5 ),
  239. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", "opQ", 5 ),
  240. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "abc", "false" ),
  241. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "bC" . $char_o_diaeresis_nfd, $char_O_diaeresis_nfd . "bc" . $char_o_diaeresis_nfd, 4 ),
  242. array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "Bc", $char_A_ring_nfd . "bc", 2 ),
  243. array( "a" . $char_a_ring_nfd . "BC", $char_a_ring_nfd . "bc", 1 ),
  244. array( "abc", $char_a_ring_nfd . "BC", "false" ),
  245. array( $char_a_ring_nfd . "BC", "aBCdefg", "false" ),
  246. array( "aBC", "Defghijklmnopq", "false" ),
  247. array( "abC", "Ab", 0 ),
  248. array( "aBC", "bc", 1 ),
  249. array( "abC", "Abc", 0 ),
  250. array( "abC", "aBcd", "false" ),
  251. array( "ABc", "ab", 0, 0 ),
  252. array( "aBc", "abC", 0, 0 ),
  253. array( "abc", "aBc", 1, "false" ),
  254. array( "ABabc", "AB", 1, 2 ),
  255. array( "abaBc", "aBc", 1, 2 ),
  256. array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o" . $char_A_ring_nfd . "bC", "O" . $char_a_ring_nfd . "bC", 2, 6 ),
  257. array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_A_ring_nfd . "bC" . $char_a_ring_nfd . "def", $char_a_ring_nfd . "Bc" . $char_a_ring_nfd, 2, 3 ),
  258. );
  259. foreach( $tests as $test ) {
  260. $arg1 = urlencode($test[1]);
  261. $arg0 = urlencode($test[0]);
  262. $res_str .= "find \"$arg1\" in \"$arg0\" - grapheme_strripos";
  263. if ( 3 == count( $test ) ) {
  264. $result = grapheme_strripos($test[0], $test[1]);
  265. }
  266. else {
  267. $res_str .= " from $test[2]";
  268. $result = grapheme_strripos($test[0], $test[1], $test[2]);
  269. }
  270. $res_str .= " = ";
  271. if ( $result === false ) {
  272. $res_str .= 'false';
  273. }
  274. else {
  275. $res_str .= $result;
  276. }
  277. $res_str .= " == " . $test[count($test)-1] . check_result($result, $test[count($test)-1]) . "\n";
  278. }
  279. //=====================================================================================
  280. $res_str .= "\n" . 'function grapheme_substr($string, $start, $length = -1) {}' . "\n\n";
  281. $tests = array(
  282. array( "abc", 3, "false" ),
  283. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, 5, "false" ),
  284. array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", 2, $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O" ),
  285. array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_A_ring_nfd . "bc", 2, "a" . $char_A_ring_nfd . "bc" ),
  286. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", 5, "O" ),
  287. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, 5, "false" ),
  288. array( "a" . $char_a_ring_nfd . "bc" . $char_O_diaeresis_nfd, 4, $char_O_diaeresis_nfd ),
  289. array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", 2, $char_a_ring_nfd . "bc" ),
  290. array( "a" . $char_A_ring_nfd . "bc", 1, $char_A_ring_nfd . "bc" ),
  291. array( "Abc", -5, "false" ),
  292. array( $char_a_ring_nfd . "bc", 3, "false" ),
  293. array( "abc", 4, "false" ),
  294. array( "abC", 2, "C" ),
  295. array( "abc", 1, "bc" ),
  296. array( "Abc", 1, 1, "b" ),
  297. array( "abc", 0, 2, "ab" ),
  298. array( "Abc", -4, 1, "false" ),
  299. array( "ababc", 1, 2, "ba" ),
  300. array( "ababc", 0, 10, "ababc" ),
  301. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, 10 , "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq" ),
  302. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 5, "Opq" ),
  303. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 5, -1, "Op" ),
  304. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 5, -2, "O" ),
  305. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 5, -3, "" ),
  306. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 5, -4, "false" ),
  307. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq" ),
  308. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -1, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Op" ),
  309. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -2, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O" ),
  310. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -3, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd ),
  311. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -4, "a" . $char_a_ring_nfd . "bc" ),
  312. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -5, "a" . $char_a_ring_nfd . "b" ),
  313. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -6, "a" . $char_a_ring_nfd ),
  314. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -7, "a" ),
  315. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -8, "" ),
  316. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -9, "false" ),
  317. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq" ),
  318. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -7, $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq" ),
  319. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -6, "bc" . $char_o_diaeresis_nfd . "Opq" ),
  320. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -5, "c" . $char_o_diaeresis_nfd . "Opq" ),
  321. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -4, $char_o_diaeresis_nfd . "Opq" ),
  322. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -3, "Opq" ),
  323. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -2, "pq" ),
  324. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -1, "q" ),
  325. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -999, "false" ),
  326. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 8, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq" ),
  327. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 7, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Op" ),
  328. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 6, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O" ),
  329. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 5, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd ),
  330. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 4, "a" . $char_a_ring_nfd . "bc" ),
  331. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 3, "a" . $char_a_ring_nfd . "b" ),
  332. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 2, "a" . $char_a_ring_nfd ),
  333. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 1, "a" ),
  334. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 0, "" ),
  335. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -999, "false" ),
  336. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -1, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Op" ),
  337. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -2, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O" ),
  338. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -3, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd ),
  339. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -4, "a" . $char_a_ring_nfd . "bc" ),
  340. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -5, "a" . $char_a_ring_nfd . "b" ),
  341. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -6, "a" . $char_a_ring_nfd ),
  342. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -7, "a" ),
  343. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -8, "" ),
  344. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -9, "false" ),
  345. );
  346. foreach( $tests as $test ) {
  347. $arg0 = urlencode($test[0]);
  348. $res_str .= "substring of \"$arg0\" from \"$test[1]\" - grapheme_substr";
  349. if ( 3 == count( $test ) ) {
  350. $result = grapheme_substr($test[0], $test[1]);
  351. }
  352. else {
  353. $res_str .= " with length $test[2]";
  354. $result = grapheme_substr($test[0], $test[1], $test[2]);
  355. }
  356. $res_str .= " = ";
  357. if ( $result === false ) {
  358. $res_str .= 'false';
  359. }
  360. else {
  361. $res_str .= urlencode($result);
  362. }
  363. $res_str .= " == " . urlencode($test[count($test)-1]) . check_result($result, $test[count($test)-1]) . "\n";
  364. }
  365. //=====================================================================================
  366. $res_str .= "\n" . 'function grapheme_strstr($haystack, $needle, $before_needle = FALSE) {}' . "\n\n";
  367. $tests = array(
  368. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", "o" ),
  369. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "o", "false" ),
  370. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, $char_o_diaeresis_nfd, $char_o_diaeresis_nfd ),
  371. array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, $char_a_ring_nfd . "bc"),
  372. array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, $char_a_ring_nfd . "bc"),
  373. array( "abc", $char_a_ring_nfd, "false" ),
  374. array( $char_a_ring_nfd . "bc", "a", "false" ),
  375. array( "abc", "d", "false" ),
  376. array( "abc", "c", "c" ),
  377. array( "abc", "b", "bc" ),
  378. array( "abc", "a", "abc" ),
  379. array( "abc", "ab", "abc" ),
  380. array( "abc", "abc", "abc" ),
  381. array( "abc", "bc", "bc" ),
  382. array( "abc", "a", FALSE, "abc" ),
  383. array( "abc", "a", TRUE, "" ),
  384. array( "abc", "b", TRUE, "a" ),
  385. array( "abc", "c", TRUE, "ab" ),
  386. array( "ababc", "bab", TRUE, "a" ),
  387. array( "ababc", "abc", TRUE, "ab" ),
  388. array( "ababc", "abc", FALSE, "abc" ),
  389. array( "ab" . $char_a_ring_nfd . "c", "d", "false" ),
  390. array( "bc" . $char_a_ring_nfd . "a", "a", "a" ),
  391. array( "a" . $char_a_ring_nfd . "bc", "b", "bc" ),
  392. array( $char_a_ring_nfd . "bc", "a", "false" ),
  393. array( $char_a_ring_nfd . "abc", "ab", "abc" ),
  394. array( "abc" . $char_a_ring_nfd, "abc", "abc" . $char_a_ring_nfd),
  395. array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd . "bc", $char_a_ring_nfd . "bc" ),
  396. array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, FALSE, $char_a_ring_nfd . "bc"),
  397. array( "a" . $char_a_ring_nfd . "bc", "a", TRUE, "" ),
  398. array( $char_a_ring_nfd . "abc", "b", TRUE, $char_a_ring_nfd . "a" ),
  399. array( "ab" . $char_a_ring_nfd . "c", "c", TRUE, "ab" . $char_a_ring_nfd ),
  400. array( "aba" . $char_a_ring_nfd . "bc", "ba" . $char_a_ring_nfd . "b", TRUE, "a" ),
  401. array( "ababc" . $char_a_ring_nfd, "abc" . $char_a_ring_nfd, TRUE, "ab" ),
  402. array( "abab" . $char_a_ring_nfd . "c", "ab" . $char_a_ring_nfd . "c", FALSE, "ab" . $char_a_ring_nfd . "c" ),
  403. );
  404. foreach( $tests as $test ) {
  405. $arg1 = urlencode($test[1]);
  406. $arg0 = urlencode($test[0]);
  407. $res_str .= "find \"$arg1\" in \"$arg0\" - grapheme_strstr";
  408. if ( 3 == count( $test ) ) {
  409. $result = grapheme_strstr($test[0], $test[1]);
  410. }
  411. else {
  412. $res_str .= " before flag is " . ( $test[2] ? "TRUE" : "FALSE" );
  413. $result = grapheme_strstr($test[0], $test[1], $test[2]);
  414. }
  415. $res_str .= " = ";
  416. if ( $result === false ) {
  417. $res_str .= 'false';
  418. }
  419. else {
  420. $res_str .= urlencode($result);
  421. }
  422. $res_str .= " == " . urlencode($test[count($test)-1]) . check_result($result, $test[count($test)-1]) . "\n";
  423. }
  424. //=====================================================================================
  425. $res_str .= "\n" . 'function grapheme_stristr($haystack, $needle, $before_needle = FALSE) {}' . "\n\n";
  426. $tests = array(
  427. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, $char_O_diaeresis_nfd, $char_o_diaeresis_nfd ),
  428. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", "o", "O" ),
  429. array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "o", "false" ),
  430. array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, $char_a_ring_nfd . "bc"),
  431. array( "a" . $char_a_ring_nfd . "bc", $char_A_ring_nfd, $char_a_ring_nfd . "bc"),
  432. array( "abc", $char_a_ring_nfd, "false" ),
  433. array( $char_a_ring_nfd . "bc", "A", "false" ),
  434. array( "abc", "d", "false" ),
  435. array( "abc", "C", "c" ),
  436. array( "aBc", "b", "Bc" ),
  437. array( "abc", "A", "abc" ),
  438. array( "abC", "ab", "abC" ),
  439. array( "abc", "aBc", "abc" ),
  440. array( "abC", "bc", "bC" ),
  441. array( "abc", "A", FALSE, "abc" ),
  442. array( "abc", "a", TRUE, "" ),
  443. array( "aBc", "b", TRUE, "a" ),
  444. array( "abc", "C", TRUE, "ab" ),
  445. array( "aBabc", "bab", TRUE, "a" ),
  446. array( "ababc", "aBc", TRUE, "ab" ),
  447. array( "ababc", "abC", FALSE, "abc" ),
  448. array( "ab" . $char_a_ring_nfd . "c", "d", "false" ),
  449. array( "bc" . $char_a_ring_nfd . "A", "a", "A" ),
  450. array( "a" . $char_a_ring_nfd . "bc", "B", "bc" ),
  451. array( $char_A_ring_nfd . "bc", "a", "false" ),
  452. array( $char_a_ring_nfd . "abc", "Ab", "abc" ),
  453. array( "abc" . $char_A_ring_nfd, "abc", "abc" . $char_A_ring_nfd),
  454. array( "a" . $char_a_ring_nfd . "bc", $char_A_ring_nfd . "bc", $char_a_ring_nfd . "bc" ),
  455. array( "a" . $char_A_ring_nfd . "bc", $char_a_ring_nfd, FALSE, $char_A_ring_nfd . "bc" ),
  456. array( "a" . $char_a_ring_nfd . "bc", "A", TRUE, "" ),
  457. array( $char_a_ring_nfd . "aBc", "b", TRUE, $char_a_ring_nfd . "a" ),
  458. array( "ab" . $char_a_ring_nfd . "c", "C", TRUE, "ab" . $char_a_ring_nfd ),
  459. array( "aba" . $char_A_ring_nfd . "bc", "ba" . $char_a_ring_nfd . "b", TRUE, "a" ),
  460. array( "ababc" . $char_a_ring_nfd, "aBc" . $char_A_ring_nfd, TRUE, "ab" ),
  461. array( "abAB" . $char_A_ring_nfd . "c", "ab" . $char_a_ring_nfd . "c", FALSE, "AB" . $char_A_ring_nfd . "c" ),
  462. );
  463. foreach( $tests as $test ) {
  464. $arg1 = urlencode($test[1]);
  465. $arg0 = urlencode($test[0]);
  466. $res_str .= "find \"$arg1\" in \"$arg0\" - grapheme_stristr";
  467. if ( 3 == count( $test ) ) {
  468. $result = grapheme_stristr($test[0], $test[1]);
  469. }
  470. else {
  471. $res_str .= " before flag is " . ( $test[2] ? "TRUE" : "FALSE" );
  472. $result = grapheme_stristr($test[0], $test[1], $test[2]);
  473. }
  474. $res_str .= " = ";
  475. if ( $result === false ) {
  476. $res_str .= 'false';
  477. }
  478. else {
  479. $res_str .= urlencode($result);
  480. }
  481. $res_str .= " == " . urlencode($test[count($test)-1]) . check_result($result, $test[count($test)-1]) . "\n";
  482. }
  483. //=====================================================================================
  484. $res_str .= "\n" . 'function grapheme_extract($haystack, $size, $extract_type = GRAPHEME_EXTR_COUNT, $start = 0[, $next])' . "\n\n";
  485. $tests = array(
  486. // haystack, count, [[offset], [next]], result
  487. array( "abc", 3, "abc" ),
  488. array( "abc", 2, "ab" ),
  489. array( "abc", 1, "a" ),
  490. array( "abc", 0, "" ),
  491. array( "abc", 1, 0, "a" ),
  492. array( "abc", 1, 1, "b" ),
  493. array( "abc", 1, 2, "c" ),
  494. array( "abc", 0, 2, "" ),
  495. array( "abc", 3, 0, 3, "abc" ),
  496. array( "abc", 2, 0, 2, "ab" ),
  497. array( "abc", 1, 0, 1, "a" ),
  498. array( "abc", 0, 0, 0, "" ),
  499. array( "abc", 1, 0, 1, "a" ),
  500. array( "abc", 1, 1, 2, "b" ),
  501. array( "abc", 1, 2, 3, "c" ),
  502. array( "abc", 0, 2, 2, "" ),
  503. array( "http://news.bbc.co.uk/2/hi/middle_east/7831588.stm", 48, 48 , 50 , "tm" ),
  504. array( $char_a_ring_nfd . "bc", 3, $char_a_ring_nfd . "bc" ),
  505. array( $char_a_ring_nfd . "bc", 2, $char_a_ring_nfd . "b" ),
  506. array( $char_a_ring_nfd . "bc", 1, $char_a_ring_nfd . "" ),
  507. array( $char_a_ring_nfd . "bc", 3, 0, 5, $char_a_ring_nfd . "bc" ),
  508. array( $char_a_ring_nfd . "bc", 2, 0, 4, $char_a_ring_nfd . "b" ),
  509. array( $char_a_ring_nfd . "bc", 1, 0, 3, $char_a_ring_nfd . "" ),
  510. array( $char_a_ring_nfd . "bcde", 2, 3, 5, "bc" ),
  511. array( $char_a_ring_nfd . "bcde", 2, 4, 6, "cd" ),
  512. array( $char_a_ring_nfd . "bcde" . $char_a_ring_nfd . "f", 4, 5, 11, "de" . $char_a_ring_nfd . "f" ),
  513. array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 3, $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd ),
  514. array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, $char_a_ring_nfd . $char_o_diaeresis_nfd ),
  515. array( $char_a_ring_nfd . $char_o_diaeresis_nfd . "c", 1, $char_a_ring_nfd . "" ),
  516. array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 1, 0, $char_o_diaeresis_nfd),
  517. array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 1, 2, $char_o_diaeresis_nfd),
  518. array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 1, 3, $char_o_diaeresis_nfd),
  519. array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 1, 4, $char_diaeresis),
  520. array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 0, $char_o_diaeresis_nfd . $char_o_diaeresis_nfd),
  521. array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 2, $char_o_diaeresis_nfd . $char_o_diaeresis_nfd),
  522. array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 3, $char_o_diaeresis_nfd . $char_o_diaeresis_nfd),
  523. array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 4, $char_diaeresis . $char_o_diaeresis_nfd),
  524. array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 7, $char_diaeresis . $char_o_diaeresis_nfd),
  525. array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 8, $char_o_diaeresis_nfd),
  526. array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 10, $char_diaeresis),
  527. array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 11, "false"),
  528. );
  529. $next = -1;
  530. foreach( $tests as $test ) {
  531. $arg0 = urlencode($test[0]);
  532. $res_str .= "extract from \"$arg0\" \"$test[1]\" graphemes - grapheme_extract";
  533. if ( 3 == count( $test ) ) {
  534. $result = grapheme_extract($test[0], $test[1]);
  535. }
  536. elseif ( 4 == count ( $test ) ) {
  537. $res_str .= " starting at byte position $test[2]";
  538. $result = grapheme_extract($test[0], $test[1], GRAPHEME_EXTR_COUNT, $test[2]);
  539. }
  540. else {
  541. $res_str .= " starting at byte position $test[2] with \$next";
  542. $result = grapheme_extract($test[0], $test[1], GRAPHEME_EXTR_COUNT, $test[2], $next);
  543. }
  544. $res_str .= " = ";
  545. if ( $result === false ) {
  546. $res_str .= 'false';
  547. }
  548. else {
  549. $res_str .= urlencode($result);
  550. }
  551. $res_str .= " == " . urlencode($test[count($test)-1]) . check_result($result, $test[count($test)-1]);
  552. if ( 5 == count ( $test ) ) {
  553. $res_str .= " \$next=$next == $test[3] ";
  554. if ( $next != $test[3] ) {
  555. $res_str .= "***FAILED***";
  556. }
  557. }
  558. $res_str .= "\n";
  559. }
  560. //=====================================================================================
  561. $res_str .= "\n" . 'function grapheme_extract($haystack, $size, $extract_type = GRAPHEME_EXTR_MAXBYTES, $start = 0)' . "\n\n";
  562. $tests = array(
  563. array( "abc", 3, "abc" ),
  564. array( "abc", 2, "ab" ),
  565. array( "abc", 1, "a" ),
  566. array( "abc", 0, "" ),
  567. array( $char_a_ring_nfd . "bc", 5, $char_a_ring_nfd . "bc" ),
  568. array( $char_a_ring_nfd . "bc", 4, $char_a_ring_nfd . "b" ),
  569. array( $char_a_ring_nfd . "bc", 1, "" ),
  570. array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 9, $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd ),
  571. array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 10, $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd ),
  572. array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 11, $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd ),
  573. array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 6, $char_a_ring_nfd . $char_o_diaeresis_nfd ),
  574. array( $char_a_ring_nfd . $char_o_diaeresis_nfd . "c", 3, $char_a_ring_nfd . "" ),
  575. array( $char_a_ring_nfd . $char_o_diaeresis_nfd . "c", 4, $char_a_ring_nfd . "" ),
  576. array( $char_a_ring_nfd . $char_o_diaeresis_nfd . "c", 5, $char_a_ring_nfd . "" ),
  577. array( $char_a_ring_nfd . $char_o_diaeresis_nfd . "c", 6, $char_a_ring_nfd . $char_o_diaeresis_nfd ),
  578. array( $char_a_ring_nfd . $char_o_diaeresis_nfd . "c", 7, $char_a_ring_nfd . $char_o_diaeresis_nfd . "c" ),
  579. array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 3, 0, $char_o_diaeresis_nfd),
  580. array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 3, 2, $char_o_diaeresis_nfd),
  581. array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 3, 3, $char_o_diaeresis_nfd),
  582. array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 3, 4, $char_diaeresis),
  583. array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 6, 0, $char_o_diaeresis_nfd . $char_o_diaeresis_nfd),
  584. array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 6, 2, $char_o_diaeresis_nfd . $char_o_diaeresis_nfd),
  585. array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 6, 3, $char_o_diaeresis_nfd . $char_o_diaeresis_nfd),
  586. array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 5, 4, $char_diaeresis . $char_o_diaeresis_nfd),
  587. array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 5, 7, $char_diaeresis . $char_o_diaeresis_nfd),
  588. array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 3, 8, $char_o_diaeresis_nfd),
  589. array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 10, $char_diaeresis),
  590. array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 11, "false"),
  591. );
  592. foreach( $tests as $test ) {
  593. $arg0 = urlencode($test[0]);
  594. $res_str .= "extract from \"$arg0\" \"$test[1]\" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES";
  595. if ( 3 == count( $test ) ) {
  596. $result = grapheme_extract($test[0], $test[1], GRAPHEME_EXTR_MAXBYTES);
  597. }
  598. else {
  599. $res_str .= " starting at byte position $test[2]";
  600. $result = grapheme_extract($test[0], $test[1], GRAPHEME_EXTR_MAXBYTES, $test[2]);
  601. }
  602. $res_str .= " = ";
  603. if ( $result === false ) {
  604. $res_str .= 'false';
  605. }
  606. else {
  607. $res_str .= urlencode($result);
  608. }
  609. $res_str .= " == " . urlencode($test[count($test)-1]) . check_result($result, $test[count($test)-1]) . "\n";
  610. }
  611. //=====================================================================================
  612. $res_str .= "\n" . 'function grapheme_extract($haystack, $size, $extract_type = GRAPHEME_EXTR_MAXCHARS, $start = 0)' . "\n\n";
  613. $tests = array(
  614. array( "abc", 3, "abc" ),
  615. array( "abc", 2, "ab" ),
  616. array( "abc", 1, "a" ),
  617. array( "abc", 0, "" ),
  618. array( "abc" . $char_o_diaeresis_nfd, 0, "" ),
  619. array( "abc" . $char_o_diaeresis_nfd, 1, "a" ),
  620. array( "abc" . $char_o_diaeresis_nfd, 2, "ab" ),
  621. array( "abc" . $char_o_diaeresis_nfd, 3, "abc" ),
  622. array( "abc" . $char_o_diaeresis_nfd, 4, "abc" ),
  623. array( "abc" . $char_o_diaeresis_nfd, 5, "abc" . $char_o_diaeresis_nfd),
  624. array( "abc" . $char_o_diaeresis_nfd, 6, "abc" . $char_o_diaeresis_nfd),
  625. array( $char_o_diaeresis_nfd . "abc", 0, "" ),
  626. array( $char_o_diaeresis_nfd . "abc", 1, "" ),
  627. array( $char_o_diaeresis_nfd . "abc", 2, $char_o_diaeresis_nfd ),
  628. array( $char_o_diaeresis_nfd . "abc", 3, $char_o_diaeresis_nfd . "a" ),
  629. array( $char_o_diaeresis_nfd . "abc", 4, $char_o_diaeresis_nfd . "ab" ),
  630. array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 5, $char_o_diaeresis_nfd . "abc" ),
  631. array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 6, $char_o_diaeresis_nfd . "abc" ),
  632. array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 7, $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd ),
  633. array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "x" ),
  634. array( "abc", 3, 0, "abc" ),
  635. array( "abc", 2, 1, "bc" ),
  636. array( "abc", 1, 2, "c" ),
  637. array( "abc", 0, 3, "false" ),
  638. array( "abc", 1, 3, "false" ),
  639. array( "abc", 1, 999, "false" ),
  640. array( $char_o_diaeresis_nfd . "abc", 1, 6, "false" ),
  641. array( $char_o_diaeresis_nfd . "abc", 1, 999, "false" ),
  642. array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 0, $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "x" ),
  643. array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 1, $char_diaeresis . "abc" . $char_a_ring_nfd . "xy" ),
  644. array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 2, "abc" . $char_a_ring_nfd . "xyz" ),
  645. array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 3, "abc" . $char_a_ring_nfd . "xyz" ),
  646. array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 4, "bc" . $char_a_ring_nfd . "xyz" ),
  647. array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 5, "c" . $char_a_ring_nfd . "xyz" ),
  648. array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 6, $char_a_ring_nfd . "xyz" ),
  649. );
  650. foreach( $tests as $test ) {
  651. $arg0 = urlencode($test[0]);
  652. $res_str .= "extract from \"$arg0\" \"$test[1]\" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS";
  653. if ( 3 == count( $test ) ) {
  654. $result = grapheme_extract($test[0], $test[1], GRAPHEME_EXTR_MAXCHARS);
  655. }
  656. else {
  657. $res_str .= " starting at byte position $test[2]";
  658. $result = grapheme_extract($test[0], $test[1], GRAPHEME_EXTR_MAXCHARS, $test[2]);
  659. }
  660. $res_str .= " = ";
  661. if ( $result === false ) {
  662. $res_str .= 'false';
  663. }
  664. else {
  665. $res_str .= urlencode($result);
  666. }
  667. $res_str .= " == " . urlencode($test[count($test)-1]) . check_result($result, $test[count($test)-1]) . "\n";
  668. }
  669. //=====================================================================================
  670. return $res_str;
  671. }
  672. echo ut_main();
  673. function check_result($result, $expected) {
  674. if ( $result === false ) {
  675. $result = 'false';
  676. }
  677. if ( strcmp($result, $expected) != 0 ) {
  678. return " **FAILED** ";
  679. }
  680. return "";
  681. }
  682. ?>
  683. --EXPECT--
  684. function grapheme_strlen($string) {}
  685. "hindi" in devanagari strlen 3
  686. "ab" + "hindi" + "cde" strlen 8
  687. "" strlen 0
  688. char_a_ring_nfd strlen 1
  689. char_a_ring_nfd + "bc" strlen 3
  690. "abc" strlen 3
  691. function grapheme_strpos($haystack, $needle, $offset = 0) {}
  692. find "o" in "aa%CC%8Abco%CC%88o" - grapheme_strpos = 5 == 5
  693. find "o" in "aa%CC%8Abco%CC%88" - grapheme_strpos = false == false
  694. find "o%CC%88" in "aa%CC%8Abco%CC%88" - grapheme_strpos = 4 == 4
  695. find "a%CC%8A" in "o%CC%88aa%CC%8Abc" - grapheme_strpos = 2 == 2
  696. find "a%CC%8A" in "aa%CC%8Abc" - grapheme_strpos = 1 == 1
  697. find "a%CC%8A" in "abc" - grapheme_strpos = false == false
  698. find "a" in "a%CC%8Abc" - grapheme_strpos = false == false
  699. find "d" in "abc" - grapheme_strpos = false == false
  700. find "c" in "abc" - grapheme_strpos = 2 == 2
  701. find "b" in "abc" - grapheme_strpos = 1 == 1
  702. find "a" in "abc" - grapheme_strpos = 0 == 0
  703. find "a" in "abc" - grapheme_strpos from 0 = 0 == 0
  704. find "a" in "abc" - grapheme_strpos from 1 = false == false
  705. find "a" in "ababc" - grapheme_strpos from 1 = 2 == 2
  706. find "o" in "aoa%CC%8Abco%CC%88o" - grapheme_strpos from 2 = 6 == 6
  707. find "a%CC%8A" in "o%CC%88a%CC%8Aaa%CC%8Abc" - grapheme_strpos from 2 = 3 == 3
  708. find "op" in "aa%CC%8Abco%CC%88opq" - grapheme_strpos = 5 == 5
  709. find "opq" in "aa%CC%8Abco%CC%88opq" - grapheme_strpos = 5 == 5
  710. find "abc" in "aa%CC%8Abco%CC%88" - grapheme_strpos = false == false
  711. find "o%CC%88bco%CC%88" in "aa%CC%8Abco%CC%88bco%CC%88" - grapheme_strpos = 4 == 4
  712. find "a%CC%8Abc" in "o%CC%88aa%CC%8Abc" - grapheme_strpos = 2 == 2
  713. find "a%CC%8Abc" in "aa%CC%8Abc" - grapheme_strpos = 1 == 1
  714. find "a%CC%8Abc" in "abc" - grapheme_strpos = false == false
  715. find "abcdefg" in "a%CC%8Abc" - grapheme_strpos = false == false
  716. find "defghijklmnopq" in "abc" - grapheme_strpos = false == false
  717. find "ab" in "abc" - grapheme_strpos = 0 == 0
  718. find "bc" in "abc" - grapheme_strpos = 1 == 1
  719. find "abc" in "abc" - grapheme_strpos = 0 == 0
  720. find "abcd" in "abc" - grapheme_strpos = false == false
  721. find "ab" in "abc" - grapheme_strpos from 0 = 0 == 0
  722. find "abc" in "abc" - grapheme_strpos from 0 = 0 == 0
  723. find "abc" in "abc" - grapheme_strpos from 1 = false == false
  724. find "ab" in "ababc" - grapheme_strpos from 1 = 2 == 2
  725. find "abc" in "ababc" - grapheme_strpos from 1 = 2 == 2
  726. find "oa%CC%8Abc" in "aoa%CC%8Abco%CC%88oa%CC%8Abc" - grapheme_strpos from 2 = 6 == 6
  727. find "a%CC%8Abca%CC%8A" in "o%CC%88a%CC%8Aaa%CC%8Abca%CC%8Adef" - grapheme_strpos from 2 = 3 == 3
  728. function grapheme_stripos($haystack, $needle, $offset = 0) {}
  729. find "o" in "aoa%CC%8Abco%CC%88O" - grapheme_stripos from 2 = 6 == 6
  730. find "a%CC%8A" in "o%CC%88a%CC%8AaA%CC%8Abc" - grapheme_stripos from 2 = 3 == 3
  731. find "o" in "aa%CC%8Abco%CC%88O" - grapheme_stripos = 5 == 5
  732. find "O" in "aa%CC%8Abco%CC%88" - grapheme_stripos = false == false
  733. find "o%CC%88" in "aa%CC%8AbcO%CC%88" - grapheme_stripos = 4 == 4
  734. find "A%CC%8A" in "o%CC%88aa%CC%8Abc" - grapheme_stripos = 2 == 2
  735. find "a%CC%8A" in "aA%CC%8Abc" - grapheme_stripos = 1 == 1
  736. find "a%CC%8A" in "Abc" - grapheme_stripos = false == false
  737. find "A" in "a%CC%8Abc" - grapheme_stripos = false == false
  738. find "D" in "abc" - grapheme_stripos = false == false
  739. find "c" in "abC" - grapheme_stripos = 2 == 2
  740. find "B" in "abc" - grapheme_stripos = 1 == 1
  741. find "a" in "Abc" - grapheme_stripos = 0 == 0
  742. find "A" in "abc" - grapheme_stripos from 0 = 0 == 0
  743. find "a" in "Abc" - grapheme_stripos from 1 = false == false
  744. find "A" in "ababc" - grapheme_stripos from 1 = 2 == 2
  745. find "oP" in "aa%CC%8Abco%CC%88Opq" - grapheme_stripos = 5 == 5
  746. find "opQ" in "aa%CC%8Abco%CC%88Opq" - grapheme_stripos = 5 == 5
  747. find "abc" in "aa%CC%8Abco%CC%88" - grapheme_stripos = false == false
  748. find "O%CC%88bco%CC%88" in "aa%CC%8Abco%CC%88bCo%CC%88" - grapheme_stripos = 4 == 4
  749. find "A%CC%8Abc" in "o%CC%88aa%CC%8ABc" - grapheme_stripos = 2 == 2
  750. find "a%CC%8Abc" in "aa%CC%8ABC" - grapheme_stripos = 1 == 1
  751. find "a%CC%8ABC" in "abc" - grapheme_stripos = false == false
  752. find "aBCdefg" in "a%CC%8ABC" - grapheme_stripos = false == false
  753. find "Defghijklmnopq" in "aBC" - grapheme_stripos = false == false
  754. find "Ab" in "abC" - grapheme_stripos = 0 == 0
  755. find "bc" in "aBC" - grapheme_stripos = 1 == 1
  756. find "Abc" in "abC" - grapheme_stripos = 0 == 0
  757. find "aBcd" in "abC" - grapheme_stripos = false == false
  758. find "ab" in "ABc" - grapheme_stripos from 0 = 0 == 0
  759. find "abC" in "aBc" - grapheme_stripos from 0 = 0 == 0
  760. find "aBc" in "abc" - grapheme_stripos from 1 = false == false
  761. find "AB" in "ABabc" - grapheme_stripos from 1 = 2 == 2
  762. find "aBc" in "abaBc" - grapheme_stripos from 1 = 2 == 2
  763. find "Oa%CC%8AbC" in "aoa%CC%8Abco%CC%88oA%CC%8AbC" - grapheme_stripos from 2 = 6 == 6
  764. find "a%CC%8ABca%CC%8A" in "o%CC%88a%CC%8AaA%CC%8AbCa%CC%8Adef" - grapheme_stripos from 2 = 3 == 3
  765. function grapheme_strrpos($haystack, $needle, $offset = 0) {}
  766. find "o" in "aa%CC%8Abco%CC%88o" - grapheme_strrpos = 5 == 5
  767. find "o" in "aa%CC%8Abco%CC%88" - grapheme_strrpos = false == false
  768. find "o%CC%88" in "aa%CC%8Abco%CC%88" - grapheme_strrpos = 4 == 4
  769. find "a%CC%8A" in "o%CC%88aa%CC%8Abc" - grapheme_strrpos = 2 == 2
  770. find "a%CC%8A" in "aa%CC%8Abc" - grapheme_strrpos = 1 == 1
  771. find "a%CC%8A" in "abc" - grapheme_strrpos = false == false
  772. find "a" in "a%CC%8Abc" - grapheme_strrpos = false == false
  773. find "d" in "abc" - grapheme_strrpos = false == false
  774. find "c" in "abc" - grapheme_strrpos = 2 == 2
  775. find "b" in "abc" - grapheme_strrpos = 1 == 1
  776. find "a" in "abc" - grapheme_strrpos = 0 == 0
  777. find "a" in "abc" - grapheme_strrpos from 0 = 0 == 0
  778. find "a" in "abc" - grapheme_strrpos from 1 = false == false
  779. find "a" in "ababc" - grapheme_strrpos from 1 = 2 == 2
  780. find "o" in "aoa%CC%8Abco%CC%88o" - grapheme_strrpos from 2 = 6 == 6
  781. find "a%CC%8A" in "o%CC%88a%CC%8Aaa%CC%8Abc" - grapheme_strrpos from 2 = 3 == 3
  782. find "op" in "aa%CC%8Abco%CC%88opq" - grapheme_strrpos = 5 == 5
  783. find "opq" in "aa%CC%8Abco%CC%88opq" - grapheme_strrpos = 5 == 5
  784. find "abc" in "aa%CC%8Abco%CC%88" - grapheme_strrpos = false == false
  785. find "o%CC%88bco%CC%88" in "aa%CC%8Abco%CC%88bco%CC%88" - grapheme_strrpos = 4 == 4
  786. find "a%CC%8Abc" in "o%CC%88aa%CC%8Abc" - grapheme_strrpos = 2 == 2
  787. find "a%CC%8Abc" in "aa%CC%8Abc" - grapheme_strrpos = 1 == 1
  788. find "a%CC%8Abc" in "abc" - grapheme_strrpos = false == false
  789. find "abcdefg" in "a%CC%8Abc" - grapheme_strrpos = false == false
  790. find "defghijklmnopq" in "abc" - grapheme_strrpos = false == false
  791. find "ab" in "abc" - grapheme_strrpos = 0 == 0
  792. find "bc" in "abc" - grapheme_strrpos = 1 == 1
  793. find "abc" in "abc" - grapheme_strrpos = 0 == 0
  794. find "abcd" in "abc" - grapheme_strrpos = false == false
  795. find "ab" in "abc" - grapheme_strrpos from 0 = 0 == 0
  796. find "abc" in "abc" - grapheme_strrpos from 0 = 0 == 0
  797. find "abc" in "abc" - grapheme_strrpos from 1 = false == false
  798. find "ab" in "ababc" - grapheme_strrpos from 1 = 2 == 2
  799. find "abc" in "ababc" - grapheme_strrpos from 1 = 2 == 2
  800. find "oa%CC%8Abc" in "aoa%CC%8Abco%CC%88oa%CC%8Abc" - grapheme_strrpos from 2 = 6 == 6
  801. find "a%CC%8Abca%CC%8A" in "o%CC%88a%CC%8Aaa%CC%8Abca%CC%8Adef" - grapheme_strrpos from 2 = 3 == 3
  802. function grapheme_strripos($haystack, $needle, $offset = 0) {}
  803. find "o" in "aoa%CC%8Abco%CC%88O" - grapheme_strripos from 2 = 6 == 6
  804. find "a%CC%8A" in "o%CC%88a%CC%8AaA%CC%8Abc" - grapheme_strripos from 2 = 3 == 3
  805. find "o" in "aa%CC%8Abco%CC%88O" - grapheme_strripos = 5 == 5
  806. find "O" in "aa%CC%8Abco%CC%88" - grapheme_strripos = false == false
  807. find "o%CC%88" in "aa%CC%8AbcO%CC%88" - grapheme_strripos = 4 == 4
  808. find "A%CC%8A" in "o%CC%88aa%CC%8Abc" - grapheme_strripos = 2 == 2
  809. find "a%CC%8A" in "aA%CC%8Abc" - grapheme_strripos = 1 == 1
  810. find "a%CC%8A" in "Abc" - grapheme_strripos = false == false
  811. find "A" in "a%CC%8Abc" - grapheme_strripos = false == false
  812. find "D" in "abc" - grapheme_strripos = false == false
  813. find "c" in "abC" - grapheme_strripos = 2 == 2
  814. find "B" in "abc" - grapheme_strripos = 1 == 1
  815. find "a" in "Abc" - grapheme_strripos = 0 == 0
  816. find "A" in "abc" - grapheme_strripos from 0 = 0 == 0
  817. find "a" in "Abc" - grapheme_strripos from 1 = false == false
  818. find "A" in "ababc" - grapheme_strripos from 1 = 2 == 2
  819. find "oP" in "aa%CC%8Abco%CC%88Opq" - grapheme_strripos = 5 == 5
  820. find "opQ" in "aa%CC%8Abco%CC%88Opq" - grapheme_strripos = 5 == 5
  821. find "abc" in "aa%CC%8Abco%CC%88" - grapheme_strripos = false == false
  822. find "O%CC%88bco%CC%88" in "aa%CC%8Abco%CC%88bCo%CC%88" - grapheme_strripos = 4 == 4
  823. find "A%CC%8Abc" in "o%CC%88aa%CC%8ABc" - grapheme_strripos = 2 == 2
  824. find "a%CC%8Abc" in "aa%CC%8ABC" - grapheme_strripos = 1 == 1
  825. find "a%CC%8ABC" in "abc" - grapheme_strripos = false == false
  826. find "aBCdefg" in "a%CC%8ABC" - grapheme_strripos = false == false
  827. find "Defghijklmnopq" in "aBC" - grapheme_strripos = false == false
  828. find "Ab" in "abC" - grapheme_strripos = 0 == 0
  829. find "bc" in "aBC" - grapheme_strripos = 1 == 1
  830. find "Abc" in "abC" - grapheme_strripos = 0 == 0
  831. find "aBcd" in "abC" - grapheme_strripos = false == false
  832. find "ab" in "ABc" - grapheme_strripos from 0 = 0 == 0
  833. find "abC" in "aBc" - grapheme_strripos from 0 = 0 == 0
  834. find "aBc" in "abc" - grapheme_strripos from 1 = false == false
  835. find "AB" in "ABabc" - grapheme_strripos from 1 = 2 == 2
  836. find "aBc" in "abaBc" - grapheme_strripos from 1 = 2 == 2
  837. find "Oa%CC%8AbC" in "aoa%CC%8Abco%CC%88oA%CC%8AbC" - grapheme_strripos from 2 = 6 == 6
  838. find "a%CC%8ABca%CC%8A" in "o%CC%88a%CC%8AaA%CC%8AbCa%CC%8Adef" - grapheme_strripos from 2 = 3 == 3
  839. function grapheme_substr($string, $start, $length = -1) {}
  840. substring of "abc" from "3" - grapheme_substr = false == false
  841. substring of "aa%CC%8Abco%CC%88" from "5" - grapheme_substr = false == false
  842. substring of "aoa%CC%8Abco%CC%88O" from "2" - grapheme_substr = a%CC%8Abco%CC%88O == a%CC%8Abco%CC%88O
  843. substring of "o%CC%88a%CC%8AaA%CC%8Abc" from "2" - grapheme_substr = aA%CC%8Abc == aA%CC%8Abc
  844. substring of "aa%CC%8Abco%CC%88O" from "5" - grapheme_substr = O == O
  845. substring of "aa%CC%8Abco%CC%88" from "5" - grapheme_substr = false == false
  846. substring of "aa%CC%8AbcO%CC%88" from "4" - grapheme_substr = O%CC%88 == O%CC%88
  847. substring of "o%CC%88aa%CC%8Abc" from "2" - grapheme_substr = a%CC%8Abc == a%CC%8Abc
  848. substring of "aA%CC%8Abc" from "1" - grapheme_substr = A%CC%8Abc == A%CC%8Abc
  849. substring of "Abc" from "-5" - grapheme_substr = false == false
  850. substring of "a%CC%8Abc" from "3" - grapheme_substr = false == false
  851. substring of "abc" from "4" - grapheme_substr = false == false
  852. substring of "abC" from "2" - grapheme_substr = C == C
  853. substring of "abc" from "1" - grapheme_substr = bc == bc
  854. substring of "Abc" from "1" - grapheme_substr with length 1 = b == b
  855. substring of "abc" from "0" - grapheme_substr with length 2 = ab == ab
  856. substring of "Abc" from "-4" - grapheme_substr with length 1 = false == false
  857. substring of "ababc" from "1" - grapheme_substr with length 2 = ba == ba
  858. substring of "ababc" from "0" - grapheme_substr with length 10 = ababc == ababc
  859. substring of "aa%CC%8Abco%CC%88Opq" from "0" - grapheme_substr with length 10 = aa%CC%8Abco%CC%88Opq == aa%CC%8Abco%CC%88Opq
  860. substring of "aa%CC%8Abco%CC%88Opq" from "5" - grapheme_substr = Opq == Opq
  861. substring of "aa%CC%8Abco%CC%88Opq" from "5" - grapheme_substr with length -1 = Op == Op
  862. substring of "aa%CC%8Abco%CC%88Opq" from "5" - grapheme_substr with length -2 = O == O
  863. substring of "aa%CC%8Abco%CC%88Opq" from "5" - grapheme_substr with length -3 = ==
  864. substring of "aa%CC%8Abco%CC%88Opq" from "5" - grapheme_substr with length -4 = false == false
  865. substring of "aa%CC%8Abco%CC%88Opq" from "0" - grapheme_substr = aa%CC%8Abco%CC%88Opq == aa%CC%8Abco%CC%88Opq
  866. substring of "aa%CC%8Abco%CC%88Opq" from "0" - grapheme_substr with length -1 = aa%CC%8Abco%CC%88Op == aa%CC%8Abco%CC%88Op
  867. substring of "aa%CC%8Abco%CC%88Opq" from "0" - grapheme_substr with length -2 = aa%CC%8Abco%CC%88O == aa%CC%8Abco%CC%88O
  868. substring of "aa%CC%8Abco%CC%88Opq" from "0" - grapheme_substr with length -3 = aa%CC%8Abco%CC%88 == aa%CC%8Abco%CC%88
  869. substring of "aa%CC%8Abco%CC%88Opq" from "0" - grapheme_substr with length -4 = aa%CC%8Abc == aa%CC%8Abc
  870. substring of "aa%CC%8Abco%CC%88Opq" from "0" - grapheme_substr with length -5 = aa%CC%8Ab == aa%CC%8Ab
  871. substring of "aa%CC%8Abco%CC%88Opq" from "0" - grapheme_substr with length -6 = aa%CC%8A == aa%CC%8A
  872. substring of "aa%CC%8Abco%CC%88Opq" from "0" - grapheme_substr with length -7 = a == a
  873. substring of "aa%CC%8Abco%CC%88Opq" from "0" - grapheme_substr with length -8 = ==
  874. substring of "aa%CC%8Abco%CC%88Opq" from "0" - grapheme_substr with length -9 = false == false
  875. substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr = aa%CC%8Abco%CC%88Opq == aa%CC%8Abco%CC%88Opq
  876. substring of "aa%CC%8Abco%CC%88Opq" from "-7" - grapheme_substr = a%CC%8Abco%CC%88Opq == a%CC%8Abco%CC%88Opq
  877. substring of "aa%CC%8Abco%CC%88Opq" from "-6" - grapheme_substr = bco%CC%88Opq == bco%CC%88Opq
  878. substring of "aa%CC%8Abco%CC%88Opq" from "-5" - grapheme_substr = co%CC%88Opq == co%CC%88Opq
  879. substring of "aa%CC%8Abco%CC%88Opq" from "-4" - grapheme_substr = o%CC%88Opq == o%CC%88Opq
  880. substring of "aa%CC%8Abco%CC%88Opq" from "-3" - grapheme_substr = Opq == Opq
  881. substring of "aa%CC%8Abco%CC%88Opq" from "-2" - grapheme_substr = pq == pq
  882. substring of "aa%CC%8Abco%CC%88Opq" from "-1" - grapheme_substr = q == q
  883. substring of "aa%CC%8Abco%CC%88Opq" from "-999" - grapheme_substr = false == false
  884. substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length 8 = aa%CC%8Abco%CC%88Opq == aa%CC%8Abco%CC%88Opq
  885. substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length 7 = aa%CC%8Abco%CC%88Op == aa%CC%8Abco%CC%88Op
  886. substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length 6 = aa%CC%8Abco%CC%88O == aa%CC%8Abco%CC%88O
  887. substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length 5 = aa%CC%8Abco%CC%88 == aa%CC%8Abco%CC%88
  888. substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length 4 = aa%CC%8Abc == aa%CC%8Abc
  889. substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length 3 = aa%CC%8Ab == aa%CC%8Ab
  890. substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length 2 = aa%CC%8A == aa%CC%8A
  891. substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length 1 = a == a
  892. substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length 0 = ==
  893. substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -999 = false == false
  894. substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -1 = aa%CC%8Abco%CC%88Op == aa%CC%8Abco%CC%88Op
  895. substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -2 = aa%CC%8Abco%CC%88O == aa%CC%8Abco%CC%88O
  896. substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -3 = aa%CC%8Abco%CC%88 == aa%CC%8Abco%CC%88
  897. substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -4 = aa%CC%8Abc == aa%CC%8Abc
  898. substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -5 = aa%CC%8Ab == aa%CC%8Ab
  899. substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -6 = aa%CC%8A == aa%CC%8A
  900. substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -7 = a == a
  901. substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -8 = ==
  902. substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -9 = false == false
  903. function grapheme_strstr($haystack, $needle, $before_needle = FALSE) {}
  904. find "o" in "aa%CC%8Abco%CC%88o" - grapheme_strstr = o == o
  905. find "o" in "aa%CC%8Abco%CC%88" - grapheme_strstr = false == false
  906. find "o%CC%88" in "aa%CC%8Abco%CC%88" - grapheme_strstr = o%CC%88 == o%CC%88
  907. find "a%CC%8A" in "o%CC%88aa%CC%8Abc" - grapheme_strstr = a%CC%8Abc == a%CC%8Abc
  908. find "a%CC%8A" in "aa%CC%8Abc" - grapheme_strstr = a%CC%8Abc == a%CC%8Abc
  909. find "a%CC%8A" in "abc" - grapheme_strstr = false == false
  910. find "a" in "a%CC%8Abc" - grapheme_strstr = false == false
  911. find "d" in "abc" - grapheme_strstr = false == false
  912. find "c" in "abc" - grapheme_strstr = c == c
  913. find "b" in "abc" - grapheme_strstr = bc == bc
  914. find "a" in "abc" - grapheme_strstr = abc == abc
  915. find "ab" in "abc" - grapheme_strstr = abc == abc
  916. find "abc" in "abc" - grapheme_strstr = abc == abc
  917. find "bc" in "abc" - grapheme_strstr = bc == bc
  918. find "a" in "abc" - grapheme_strstr before flag is FALSE = abc == abc
  919. find "a" in "abc" - grapheme_strstr before flag is TRUE = ==
  920. find "b" in "abc" - grapheme_strstr before flag is TRUE = a == a
  921. find "c" in "abc" - grapheme_strstr before flag is TRUE = ab == ab
  922. find "bab" in "ababc" - grapheme_strstr before flag is TRUE = a == a
  923. find "abc" in "ababc" - grapheme_strstr before flag is TRUE = ab == ab
  924. find "abc" in "ababc" - grapheme_strstr before flag is FALSE = abc == abc
  925. find "d" in "aba%CC%8Ac" - grapheme_strstr = false == false
  926. find "a" in "bca%CC%8Aa" - grapheme_strstr = a == a
  927. find "b" in "aa%CC%8Abc" - grapheme_strstr = bc == bc
  928. find "a" in "a%CC%8Abc" - grapheme_strstr = false == false
  929. find "ab" in "a%CC%8Aabc" - grapheme_strstr = abc == abc
  930. find "abc" in "abca%CC%8A" - grapheme_strstr = abca%CC%8A == abca%CC%8A
  931. find "a%CC%8Abc" in "aa%CC%8Abc" - grapheme_strstr = a%CC%8Abc == a%CC%8Abc
  932. find "a%CC%8A" in "aa%CC%8Abc" - grapheme_strstr before flag is FALSE = a%CC%8Abc == a%CC%8Abc
  933. find "a" in "aa%CC%8Abc" - grapheme_strstr before flag is TRUE = ==
  934. find "b" in "a%CC%8Aabc" - grapheme_strstr before flag is TRUE = a%CC%8Aa == a%CC%8Aa
  935. find "c" in "aba%CC%8Ac" - grapheme_strstr before flag is TRUE = aba%CC%8A == aba%CC%8A
  936. find "baa%CC%8Ab" in "abaa%CC%8Abc" - grapheme_strstr before flag is TRUE = a == a
  937. find "abca%CC%8A" in "ababca%CC%8A" - grapheme_strstr before flag is TRUE = ab == ab
  938. find "aba%CC%8Ac" in "ababa%CC%8Ac" - grapheme_strstr before flag is FALSE = aba%CC%8Ac == aba%CC%8Ac
  939. function grapheme_stristr($haystack, $needle, $before_needle = FALSE) {}
  940. find "O%CC%88" in "aa%CC%8Abco%CC%88" - grapheme_stristr = o%CC%88 == o%CC%88
  941. find "o" in "aa%CC%8Abco%CC%88O" - grapheme_stristr = O == O
  942. find "o" in "aa%CC%8Abco%CC%88" - grapheme_stristr = false == false
  943. find "a%CC%8A" in "o%CC%88aa%CC%8Abc" - grapheme_stristr = a%CC%8Abc == a%CC%8Abc
  944. find "A%CC%8A" in "aa%CC%8Abc" - grapheme_stristr = a%CC%8Abc == a%CC%8Abc
  945. find "a%CC%8A" in "abc" - grapheme_stristr = false == false
  946. find "A" in "a%CC%8Abc" - grapheme_stristr = false == false
  947. find "d" in "abc" - grapheme_stristr = false == false
  948. find "C" in "abc" - grapheme_stristr = c == c
  949. find "b" in "aBc" - grapheme_stristr = Bc == Bc
  950. find "A" in "abc" - grapheme_stristr = abc == abc
  951. find "ab" in "abC" - grapheme_stristr = abC == abC
  952. find "aBc" in "abc" - grapheme_stristr = abc == abc
  953. find "bc" in "abC" - grapheme_stristr = bC == bC
  954. find "A" in "abc" - grapheme_stristr before flag is FALSE = abc == abc
  955. find "a" in "abc" - grapheme_stristr before flag is TRUE = ==
  956. find "b" in "aBc" - grapheme_stristr before flag is TRUE = a == a
  957. find "C" in "abc" - grapheme_stristr before flag is TRUE = ab == ab
  958. find "bab" in "aBabc" - grapheme_stristr before flag is TRUE = a == a
  959. find "aBc" in "ababc" - grapheme_stristr before flag is TRUE = ab == ab
  960. find "abC" in "ababc" - grapheme_stristr before flag is FALSE = abc == abc
  961. find "d" in "aba%CC%8Ac" - grapheme_stristr = false == false
  962. find "a" in "bca%CC%8AA" - grapheme_stristr = A == A
  963. find "B" in "aa%CC%8Abc" - grapheme_stristr = bc == bc
  964. find "a" in "A%CC%8Abc" - grapheme_stristr = false == false
  965. find "Ab" in "a%CC%8Aabc" - grapheme_stristr = abc == abc
  966. find "abc" in "abcA%CC%8A" - grapheme_stristr = abcA%CC%8A == abcA%CC%8A
  967. find "A%CC%8Abc" in "aa%CC%8Abc" - grapheme_stristr = a%CC%8Abc == a%CC%8Abc
  968. find "a%CC%8A" in "aA%CC%8Abc" - grapheme_stristr before flag is FALSE = A%CC%8Abc == A%CC%8Abc
  969. find "A" in "aa%CC%8Abc" - grapheme_stristr before flag is TRUE = ==
  970. find "b" in "a%CC%8AaBc" - grapheme_stristr before flag is TRUE = a%CC%8Aa == a%CC%8Aa
  971. find "C" in "aba%CC%8Ac" - grapheme_stristr before flag is TRUE = aba%CC%8A == aba%CC%8A
  972. find "baa%CC%8Ab" in "abaA%CC%8Abc" - grapheme_stristr before flag is TRUE = a == a
  973. find "aBcA%CC%8A" in "ababca%CC%8A" - grapheme_stristr before flag is TRUE = ab == ab
  974. find "aba%CC%8Ac" in "abABA%CC%8Ac" - grapheme_stristr before flag is FALSE = ABA%CC%8Ac == ABA%CC%8Ac
  975. function grapheme_extract($haystack, $size, $extract_type = GRAPHEME_EXTR_COUNT, $start = 0[, $next])
  976. extract from "abc" "3" graphemes - grapheme_extract = abc == abc
  977. extract from "abc" "2" graphemes - grapheme_extract = ab == ab
  978. extract from "abc" "1" graphemes - grapheme_extract = a == a
  979. extract from "abc" "0" graphemes - grapheme_extract = ==
  980. extract from "abc" "1" graphemes - grapheme_extract starting at byte position 0 = a == a
  981. extract from "abc" "1" graphemes - grapheme_extract starting at byte position 1 = b == b
  982. extract from "abc" "1" graphemes - grapheme_extract starting at byte position 2 = c == c
  983. extract from "abc" "0" graphemes - grapheme_extract starting at byte position 2 = ==
  984. extract from "abc" "3" graphemes - grapheme_extract starting at byte position 0 with $next = abc == abc $next=3 == 3
  985. extract from "abc" "2" graphemes - grapheme_extract starting at byte position 0 with $next = ab == ab $next=2 == 2
  986. extract from "abc" "1" graphemes - grapheme_extract starting at byte position 0 with $next = a == a $next=1 == 1
  987. extract from "abc" "0" graphemes - grapheme_extract starting at byte position 0 with $next = == $next=0 == 0
  988. extract from "abc" "1" graphemes - grapheme_extract starting at byte position 0 with $next = a == a $next=1 == 1
  989. extract from "abc" "1" graphemes - grapheme_extract starting at byte position 1 with $next = b == b $next=2 == 2
  990. extract from "abc" "1" graphemes - grapheme_extract starting at byte position 2 with $next = c == c $next=3 == 3
  991. extract from "abc" "0" graphemes - grapheme_extract starting at byte position 2 with $next = == $next=2 == 2
  992. extract from "http%3A%2F%2Fnews.bbc.co.uk%2F2%2Fhi%2Fmiddle_east%2F7831588.stm" "48" graphemes - grapheme_extract starting at byte position 48 with $next = tm == tm $next=50 == 50
  993. extract from "a%CC%8Abc" "3" graphemes - grapheme_extract = a%CC%8Abc == a%CC%8Abc
  994. extract from "a%CC%8Abc" "2" graphemes - grapheme_extract = a%CC%8Ab == a%CC%8Ab
  995. extract from "a%CC%8Abc" "1" graphemes - grapheme_extract = a%CC%8A == a%CC%8A
  996. extract from "a%CC%8Abc" "3" graphemes - grapheme_extract starting at byte position 0 with $next = a%CC%8Abc == a%CC%8Abc $next=5 == 5
  997. extract from "a%CC%8Abc" "2" graphemes - grapheme_extract starting at byte position 0 with $next = a%CC%8Ab == a%CC%8Ab $next=4 == 4
  998. extract from "a%CC%8Abc" "1" graphemes - grapheme_extract starting at byte position 0 with $next = a%CC%8A == a%CC%8A $next=3 == 3
  999. extract from "a%CC%8Abcde" "2" graphemes - grapheme_extract starting at byte position 3 with $next = bc == bc $next=5 == 5
  1000. extract from "a%CC%8Abcde" "2" graphemes - grapheme_extract starting at byte position 4 with $next = cd == cd $next=6 == 6
  1001. extract from "a%CC%8Abcdea%CC%8Af" "4" graphemes - grapheme_extract starting at byte position 5 with $next = dea%CC%8Af == dea%CC%8Af $next=11 == 11
  1002. extract from "a%CC%8Ao%CC%88o%CC%88" "3" graphemes - grapheme_extract = a%CC%8Ao%CC%88o%CC%88 == a%CC%8Ao%CC%88o%CC%88
  1003. extract from "a%CC%8Ao%CC%88o%CC%88" "2" graphemes - grapheme_extract = a%CC%8Ao%CC%88 == a%CC%8Ao%CC%88
  1004. extract from "a%CC%8Ao%CC%88c" "1" graphemes - grapheme_extract = a%CC%8A == a%CC%8A
  1005. extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "1" graphemes - grapheme_extract starting at byte position 0 = o%CC%88 == o%CC%88
  1006. extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "1" graphemes - grapheme_extract starting at byte position 2 = o%CC%88 == o%CC%88
  1007. extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "1" graphemes - grapheme_extract starting at byte position 3 = o%CC%88 == o%CC%88
  1008. extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "1" graphemes - grapheme_extract starting at byte position 4 = %CC%88 == %CC%88
  1009. extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "2" graphemes - grapheme_extract starting at byte position 0 = o%CC%88o%CC%88 == o%CC%88o%CC%88
  1010. extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "2" graphemes - grapheme_extract starting at byte position 2 = o%CC%88o%CC%88 == o%CC%88o%CC%88
  1011. extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "2" graphemes - grapheme_extract starting at byte position 3 = o%CC%88o%CC%88 == o%CC%88o%CC%88
  1012. extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "2" graphemes - grapheme_extract starting at byte position 4 = %CC%88o%CC%88 == %CC%88o%CC%88
  1013. extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "2" graphemes - grapheme_extract starting at byte position 7 = %CC%88o%CC%88 == %CC%88o%CC%88
  1014. extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "2" graphemes - grapheme_extract starting at byte position 8 = o%CC%88 == o%CC%88
  1015. extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "2" graphemes - grapheme_extract starting at byte position 10 = %CC%88 == %CC%88
  1016. extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "2" graphemes - grapheme_extract starting at byte position 11 = false == false
  1017. function grapheme_extract($haystack, $size, $extract_type = GRAPHEME_EXTR_MAXBYTES, $start = 0)
  1018. extract from "abc" "3" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES = abc == abc
  1019. extract from "abc" "2" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES = ab == ab
  1020. extract from "abc" "1" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES = a == a
  1021. extract from "abc" "0" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES = ==
  1022. extract from "a%CC%8Abc" "5" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES = a%CC%8Abc == a%CC%8Abc
  1023. extract from "a%CC%8Abc" "4" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES = a%CC%8Ab == a%CC%8Ab
  1024. extract from "a%CC%8Abc" "1" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES = ==
  1025. extract from "a%CC%8Ao%CC%88o%CC%88" "9" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES = a%CC%8Ao%CC%88o%CC%88 == a%CC%8Ao%CC%88o%CC%88
  1026. extract from "a%CC%8Ao%CC%88o%CC%88" "10" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES = a%CC%8Ao%CC%88o%CC%88 == a%CC%8Ao%CC%88o%CC%88
  1027. extract from "a%CC%8Ao%CC%88o%CC%88" "11" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES = a%CC%8Ao%CC%88o%CC%88 == a%CC%8Ao%CC%88o%CC%88
  1028. extract from "a%CC%8Ao%CC%88o%CC%88" "6" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES = a%CC%8Ao%CC%88 == a%CC%8Ao%CC%88
  1029. extract from "a%CC%8Ao%CC%88c" "3" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES = a%CC%8A == a%CC%8A
  1030. extract from "a%CC%8Ao%CC%88c" "4" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES = a%CC%8A == a%CC%8A
  1031. extract from "a%CC%8Ao%CC%88c" "5" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES = a%CC%8A == a%CC%8A
  1032. extract from "a%CC%8Ao%CC%88c" "6" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES = a%CC%8Ao%CC%88 == a%CC%8Ao%CC%88
  1033. extract from "a%CC%8Ao%CC%88c" "7" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES = a%CC%8Ao%CC%88c == a%CC%8Ao%CC%88c
  1034. extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "3" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES starting at byte position 0 = o%CC%88 == o%CC%88
  1035. extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "3" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES starting at byte position 2 = o%CC%88 == o%CC%88
  1036. extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "3" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES starting at byte position 3 = o%CC%88 == o%CC%88
  1037. extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "3" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES starting at byte position 4 = %CC%88 == %CC%88
  1038. extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "6" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES starting at byte position 0 = o%CC%88o%CC%88 == o%CC%88o%CC%88
  1039. extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "6" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES starting at byte position 2 = o%CC%88o%CC%88 == o%CC%88o%CC%88
  1040. extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "6" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES starting at byte position 3 = o%CC%88o%CC%88 == o%CC%88o%CC%88
  1041. extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "5" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES starting at byte position 4 = %CC%88o%CC%88 == %CC%88o%CC%88
  1042. extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "5" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES starting at byte position 7 = %CC%88o%CC%88 == %CC%88o%CC%88
  1043. extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "3" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES starting at byte position 8 = o%CC%88 == o%CC%88
  1044. extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "2" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES starting at byte position 10 = %CC%88 == %CC%88
  1045. extract from "o%CC%88o%CC%88o%CC%88o%CC%88" "2" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES starting at byte position 11 = false == false
  1046. function grapheme_extract($haystack, $size, $extract_type = GRAPHEME_EXTR_MAXCHARS, $start = 0)
  1047. extract from "abc" "3" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = abc == abc
  1048. extract from "abc" "2" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = ab == ab
  1049. extract from "abc" "1" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = a == a
  1050. extract from "abc" "0" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = ==
  1051. extract from "abco%CC%88" "0" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = ==
  1052. extract from "abco%CC%88" "1" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = a == a
  1053. extract from "abco%CC%88" "2" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = ab == ab
  1054. extract from "abco%CC%88" "3" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = abc == abc
  1055. extract from "abco%CC%88" "4" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = abc == abc
  1056. extract from "abco%CC%88" "5" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = abco%CC%88 == abco%CC%88
  1057. extract from "abco%CC%88" "6" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = abco%CC%88 == abco%CC%88
  1058. extract from "o%CC%88abc" "0" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = ==
  1059. extract from "o%CC%88abc" "1" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = ==
  1060. extract from "o%CC%88abc" "2" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = o%CC%88 == o%CC%88
  1061. extract from "o%CC%88abc" "3" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = o%CC%88a == o%CC%88a
  1062. extract from "o%CC%88abc" "4" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = o%CC%88ab == o%CC%88ab
  1063. extract from "o%CC%88abca%CC%8Axyz" "5" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = o%CC%88abc == o%CC%88abc
  1064. extract from "o%CC%88abca%CC%8Axyz" "6" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = o%CC%88abc == o%CC%88abc
  1065. extract from "o%CC%88abca%CC%8Axyz" "7" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = o%CC%88abca%CC%8A == o%CC%88abca%CC%8A
  1066. extract from "o%CC%88abca%CC%8Axyz" "8" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS = o%CC%88abca%CC%8Ax == o%CC%88abca%CC%8Ax
  1067. extract from "abc" "3" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS starting at byte position 0 = abc == abc
  1068. extract from "abc" "2" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS starting at byte position 1 = bc == bc
  1069. extract from "abc" "1" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS starting at byte position 2 = c == c
  1070. extract from "abc" "0" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS starting at byte position 3 = false == false
  1071. extract from "abc" "1" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS starting at byte position 3 = false == false
  1072. extract from "abc" "1" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS starting at byte position 999 = false == false
  1073. extract from "o%CC%88abc" "1" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS starting at byte position 6 = false == false
  1074. extract from "o%CC%88abc" "1" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS starting at byte position 999 = false == false
  1075. extract from "o%CC%88abca%CC%8Axyz" "8" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS starting at byte position 0 = o%CC%88abca%CC%8Ax == o%CC%88abca%CC%8Ax
  1076. extract from "o%CC%88abca%CC%8Axyz" "8" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS starting at byte position 1 = %CC%88abca%CC%8Axy == %CC%88abca%CC%8Axy
  1077. extract from "o%CC%88abca%CC%8Axyz" "8" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS starting at byte position 2 = abca%CC%8Axyz == abca%CC%8Axyz
  1078. extract from "o%CC%88abca%CC%8Axyz" "8" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS starting at byte position 3 = abca%CC%8Axyz == abca%CC%8Axyz
  1079. extract from "o%CC%88abca%CC%8Axyz" "8" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS starting at byte position 4 = bca%CC%8Axyz == bca%CC%8Axyz
  1080. extract from "o%CC%88abca%CC%8Axyz" "8" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS starting at byte position 5 = ca%CC%8Axyz == ca%CC%8Axyz
  1081. extract from "o%CC%88abca%CC%8Axyz" "8" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS starting at byte position 6 = a%CC%8Axyz == a%CC%8Axyz