mb_substitute_character_variation2.phpt 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. --TEST--
  2. Test mb_substitute_character() function : variation unmappable out char for convert encoding
  3. --SKIPIF--
  4. <?php
  5. extension_loaded('mbstring') or die('skip');
  6. function_exists('mb_substitute_character') or die("skip mb_substitute_character() is not available in this build");
  7. ?>
  8. --FILE--
  9. <?php
  10. /* Prototype : mixed mb_substitute_character([mixed substchar])
  11. * Description: Sets the current substitute_character or returns the current substitute_character
  12. * Source code: ext/mbstring/mbstring.c
  13. * Alias to functions:
  14. */
  15. echo "*** Testing mb_substitute_character() : variation ***\n";
  16. //japenese utf-8
  17. $string_mb = base64_decode('5pel5pys6Kqe44OG44Kt44K544OI');
  18. //output the default which is ? in ISO-8859-1, x3f
  19. var_dump(bin2hex(mb_convert_encoding($string_mb, "ISO-8859-1", "UTF-8")));
  20. mb_substitute_character(66); //'B' in ISO-8859-1, x42
  21. var_dump(bin2hex(mb_convert_encoding($string_mb, "ISO-8859-1", "UTF-8")));
  22. mb_substitute_character("none"); //no substitution
  23. var_dump(bin2hex(mb_convert_encoding($string_mb, "ISO-8859-1", "UTF-8")));
  24. mb_substitute_character(280); //not valid in ISO-8859-1
  25. var_dump(bin2hex(mb_convert_encoding($string_mb, "ISO-8859-1", "UTF-8")));
  26. ?>
  27. ===DONE===
  28. --EXPECT--
  29. *** Testing mb_substitute_character() : variation ***
  30. string(14) "3f3f3f3f3f3f3f"
  31. string(14) "42424242424242"
  32. string(0) ""
  33. string(0) ""
  34. ===DONE===