strtoupper1.phpt 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. --TEST--
  2. Test strtoupper() function
  3. --SKIPIF--
  4. <?php
  5. if( substr(PHP_OS, 0, 3) == 'WIN') {
  6. if (!setlocale(LC_ALL, 'C')) {
  7. die('skip need "C" locale (this windows is broken)');
  8. }
  9. } else {
  10. if (!setlocale(LC_ALL, 'en_US.UTF-8', 'en')) {
  11. die('skip need "en_US.UTF-8" locale');
  12. }
  13. }
  14. ?>
  15. --FILE--
  16. <?php
  17. if( substr(PHP_OS, 0, 3) == 'WIN') {
  18. setlocale(LC_ALL, 'C');
  19. } else {
  20. setlocale(LC_ALL, 'en_US.UTF-8');
  21. }
  22. echo "*** Testing strtoupper() with 128 chars ***\n";
  23. for ($i=0; $i<=127; $i++){
  24. $char = chr($i);
  25. print(bin2hex($char))." => ".(bin2hex(strtoupper("$char")))."\n";
  26. }
  27. echo "\n*** Testing strtoupper() with basic strings ***\n";
  28. $str = "Mary Had A liTTle LAmb and ShE loveD IT So\n";
  29. var_dump(strtoupper($str));
  30. echo "\n*** Testing strtoupper() with various strings ***";
  31. /* strings to pass strtoupper() */
  32. $strings = array (
  33. "",
  34. "string",
  35. "stRINg0234",
  36. "1.233.344StrinG12333",
  37. "$$$$$$!!!!@@@@@@@ ABCDEF !!!***",
  38. "ABCD\0abcdABCD",
  39. TRUE,
  40. FALSE,
  41. );
  42. $count = 0;
  43. /* loop through to check possible variations */
  44. foreach ($strings as $string) {
  45. echo "\n-- Iteration $count --\n";
  46. var_dump( strtoupper($string) );
  47. $count++;
  48. }
  49. echo "\n*** Testing strtoupper() with two different case strings ***\n";
  50. if (strtoupper("HeLLo woRLd") === strtoupper("hEllo WORLD"))
  51. echo "strings are same, with Case Insensitive\n";
  52. else
  53. echo "strings are not same\n";
  54. echo "*** Done ***";
  55. ?>
  56. --EXPECTF--
  57. *** Testing strtoupper() with 128 chars ***
  58. 00 => 00
  59. 01 => 01
  60. 02 => 02
  61. 03 => 03
  62. 04 => 04
  63. 05 => 05
  64. 06 => 06
  65. 07 => 07
  66. 08 => 08
  67. 09 => 09
  68. 0a => 0a
  69. 0b => 0b
  70. 0c => 0c
  71. 0d => 0d
  72. 0e => 0e
  73. 0f => 0f
  74. 10 => 10
  75. 11 => 11
  76. 12 => 12
  77. 13 => 13
  78. 14 => 14
  79. 15 => 15
  80. 16 => 16
  81. 17 => 17
  82. 18 => 18
  83. 19 => 19
  84. 1a => 1a
  85. 1b => 1b
  86. 1c => 1c
  87. 1d => 1d
  88. 1e => 1e
  89. 1f => 1f
  90. 20 => 20
  91. 21 => 21
  92. 22 => 22
  93. 23 => 23
  94. 24 => 24
  95. 25 => 25
  96. 26 => 26
  97. 27 => 27
  98. 28 => 28
  99. 29 => 29
  100. 2a => 2a
  101. 2b => 2b
  102. 2c => 2c
  103. 2d => 2d
  104. 2e => 2e
  105. 2f => 2f
  106. 30 => 30
  107. 31 => 31
  108. 32 => 32
  109. 33 => 33
  110. 34 => 34
  111. 35 => 35
  112. 36 => 36
  113. 37 => 37
  114. 38 => 38
  115. 39 => 39
  116. 3a => 3a
  117. 3b => 3b
  118. 3c => 3c
  119. 3d => 3d
  120. 3e => 3e
  121. 3f => 3f
  122. 40 => 40
  123. 41 => 41
  124. 42 => 42
  125. 43 => 43
  126. 44 => 44
  127. 45 => 45
  128. 46 => 46
  129. 47 => 47
  130. 48 => 48
  131. 49 => 49
  132. 4a => 4a
  133. 4b => 4b
  134. 4c => 4c
  135. 4d => 4d
  136. 4e => 4e
  137. 4f => 4f
  138. 50 => 50
  139. 51 => 51
  140. 52 => 52
  141. 53 => 53
  142. 54 => 54
  143. 55 => 55
  144. 56 => 56
  145. 57 => 57
  146. 58 => 58
  147. 59 => 59
  148. 5a => 5a
  149. 5b => 5b
  150. 5c => 5c
  151. 5d => 5d
  152. 5e => 5e
  153. 5f => 5f
  154. 60 => 60
  155. 61 => 41
  156. 62 => 42
  157. 63 => 43
  158. 64 => 44
  159. 65 => 45
  160. 66 => 46
  161. 67 => 47
  162. 68 => 48
  163. 69 => 49
  164. 6a => 4a
  165. 6b => 4b
  166. 6c => 4c
  167. 6d => 4d
  168. 6e => 4e
  169. 6f => 4f
  170. 70 => 50
  171. 71 => 51
  172. 72 => 52
  173. 73 => 53
  174. 74 => 54
  175. 75 => 55
  176. 76 => 56
  177. 77 => 57
  178. 78 => 58
  179. 79 => 59
  180. 7a => 5a
  181. 7b => 7b
  182. 7c => 7c
  183. 7d => 7d
  184. 7e => 7e
  185. 7f => 7f
  186. *** Testing strtoupper() with basic strings ***
  187. string(43) "MARY HAD A LITTLE LAMB AND SHE LOVED IT SO
  188. "
  189. *** Testing strtoupper() with various strings ***
  190. -- Iteration 0 --
  191. string(0) ""
  192. -- Iteration 1 --
  193. string(6) "STRING"
  194. -- Iteration 2 --
  195. string(10) "STRING0234"
  196. -- Iteration 3 --
  197. string(20) "1.233.344STRING12333"
  198. -- Iteration 4 --
  199. string(31) "$$$$$$!!!!@@@@@@@ ABCDEF !!!***"
  200. -- Iteration 5 --
  201. string(13) "ABCD%0ABCDABCD"
  202. -- Iteration 6 --
  203. string(1) "1"
  204. -- Iteration 7 --
  205. string(0) ""
  206. *** Testing strtoupper() with two different case strings ***
  207. strings are same, with Case Insensitive
  208. *** Done ***