mb_strtoupper_basic.phpt 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. --TEST--
  2. Test mb_strtoupper() function : basic functionality
  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. * Test basic functionality of mb_strtoupper
  16. */
  17. echo "*** Testing mb_strtoupper() : basic functionality ***\n";
  18. mb_internal_encoding('utf-8');
  19. $ascii_lower = b'abcdefghijklmnopqrstuvwxyz';
  20. $ascii_upper = b'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  21. $greek_lower = base64_decode('zrHOss6zzrTOtc62zrfOuM65zrrOu868zr3Ovs6/z4DPgc+Dz4TPhc+Gz4fPiM+J');
  22. $greek_upper = base64_decode('zpHOks6TzpTOlc6WzpfOmM6ZzprOm86czp3Ons6fzqDOoc6jzqTOpc6mzqfOqM6p');
  23. echo "\n-- ASCII String --\n";
  24. $ascii = mb_strtoupper($ascii_lower);
  25. var_dump(base64_encode($ascii));
  26. if($ascii == $ascii_upper) {
  27. echo "Correctly converted\n";
  28. } else {
  29. echo "Incorrectly converted\n";
  30. }
  31. echo "\n-- Multibyte String --\n";
  32. $mb = mb_strtoupper($greek_lower, 'UTF-8');
  33. var_dump(base64_encode($mb));
  34. if ($mb == $greek_upper) {
  35. echo "Correctly converted\n";
  36. } else {
  37. echo "Incorreclty converted\n";
  38. }
  39. echo "Done";
  40. ?>
  41. --EXPECT--
  42. *** Testing mb_strtoupper() : basic functionality ***
  43. -- ASCII String --
  44. string(36) "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVo="
  45. Correctly converted
  46. -- Multibyte String --
  47. string(64) "zpHOks6TzpTOlc6WzpfOmM6ZzprOm86czp3Ons6fzqDOoc6jzqTOpc6mzqfOqM6p"
  48. Correctly converted
  49. Done