mb_strtoupper_variation3.phpt 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. --TEST--
  2. Test mb_strtoupper() function : usage varitations - pass mixed ASCII and non-ASCII strings
  3. --SKIPIF--
  4. <?php
  5. extension_loaded('mbstring') or die('skip');
  6. function_exists('mb_strtoupper') or die("skip mb_strtoupper() is not available in this build");
  7. ?>
  8. --FILE--
  9. <?php
  10. /* Prototype : string mb_strtoupper(string $sourcestring [, string $encoding]
  11. * Description: Returns a uppercased version of $sourcestring
  12. * Source code: ext/mbstring/mbstring.c
  13. */
  14. /*
  15. * Pass a Japanese string and a mixed Japanese and ASCII string to mb_strtolower
  16. * to check correct conversion is occurring (Japanese characters should not be converted).
  17. */
  18. echo "*** Testing mb_strtoupper() : usage variations ***\n";
  19. $string_mixed_upper = base64_decode('5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCUEhQLiAwMTIzNO+8le+8lu+8l++8mO+8meOAgg==');
  20. $string_mixed_lower = base64_decode('5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCcGhwLiAwMTIzNO+8le+8lu+8l++8mO+8meOAgg==');
  21. $string_all_mb = base64_decode('5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CC');
  22. echo "\n-- Mixed string (mulitbyte and ASCII characters) --\n";
  23. $a = mb_strtoupper($string_mixed_lower, 'UTF-8');
  24. var_dump(base64_encode($a));
  25. if ($a == $string_mixed_upper) {
  26. echo "Correctly Converted\n";
  27. } else {
  28. echo "Incorrectly Converted\n";
  29. }
  30. echo "\n-- Multibyte Only String--\n";
  31. $b = mb_strtoupper($string_all_mb, 'UTF-8');
  32. var_dump(base64_encode($b));
  33. if ($b == $string_all_mb) { // Japanese characters only - should not be any conversion
  34. echo "Correctly Converted\n";
  35. } else {
  36. echo "Incorrectly Converted\n";
  37. }
  38. echo "Done";
  39. ?>
  40. --EXPECTF--
  41. *** Testing mb_strtoupper() : usage variations ***
  42. -- Mixed string (mulitbyte and ASCII characters) --
  43. string(80) "5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCUEhQLiAwMTIzNO+8le+8lu+8l++8mO+8meOAgg=="
  44. Correctly Converted
  45. -- Multibyte Only String--
  46. string(40) "5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CC"
  47. Correctly Converted
  48. Done