uconverter_func_subst.phpt 1021 B

12345678910111213141516171819202122232425262728293031
  1. --TEST--
  2. Basic UConverter::convert() w/ Subsitution
  3. --EXTENSIONS--
  4. intl
  5. --INI--
  6. intl.use_exceptions=false
  7. --FILE--
  8. <?php
  9. foreach(array('?','','??') as $subst) {
  10. $opts = array('to_subst' => $subst);
  11. $ret = UConverter::transcode("This is an ascii string", 'ascii', 'utf-8', $opts);
  12. if ($ret === FALSE) {
  13. echo "Error: ", intl_get_error_message(), "\n";
  14. } else {
  15. var_dump($ret);
  16. }
  17. $ret = UConverter::transcode("Snowman: (\xE2\x98\x83)", 'ascii', 'utf-8', $opts);
  18. if ($ret === FALSE) {
  19. echo "Error: ", intl_get_error_message(), "\n";
  20. } else {
  21. var_dump($ret);
  22. }
  23. }
  24. ?>
  25. --EXPECT--
  26. string(23) "This is an ascii string"
  27. string(12) "Snowman: (?)"
  28. Error: transcode() returned error 1: U_ILLEGAL_ARGUMENT_ERROR: U_ILLEGAL_ARGUMENT_ERROR
  29. Error: transcode() returned error 1: U_ILLEGAL_ARGUMENT_ERROR: U_ILLEGAL_ARGUMENT_ERROR
  30. Error: transcode() returned error 1: U_ILLEGAL_ARGUMENT_ERROR: U_ILLEGAL_ARGUMENT_ERROR
  31. Error: transcode() returned error 1: U_ILLEGAL_ARGUMENT_ERROR: U_ILLEGAL_ARGUMENT_ERROR