idn_uts46_basic.phpt 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. --TEST--
  2. IDN UTS #46 API basic tests
  3. --EXTENSIONS--
  4. intl
  5. --SKIPIF--
  6. <?php
  7. if (!defined('INTL_IDNA_VARIANT_UTS46'))
  8. die('skip no UTS #46 API');
  9. --FILE--
  10. <?php
  11. $utf8dn = "www.fußball.com";
  12. $asciiNonTrans = "www.xn--fuball-cta.com";
  13. echo "all ok, no details:", "\n";
  14. var_dump(idn_to_ascii($utf8dn,
  15. IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46));
  16. echo "all ok, no details, transitional:", "\n";
  17. var_dump(idn_to_ascii($utf8dn, 0, INTL_IDNA_VARIANT_UTS46));
  18. echo "all ok, with details:", "\n";
  19. var_dump(idn_to_ascii($utf8dn, IDNA_NONTRANSITIONAL_TO_ASCII,
  20. INTL_IDNA_VARIANT_UTS46, $info));
  21. var_dump($info);
  22. echo "reverse, ok, with details:", "\n";
  23. var_dump(idn_to_utf8($asciiNonTrans, 0, INTL_IDNA_VARIANT_UTS46, $info));
  24. var_dump($info);
  25. ?>
  26. --EXPECT--
  27. all ok, no details:
  28. string(22) "www.xn--fuball-cta.com"
  29. all ok, no details, transitional:
  30. string(16) "www.fussball.com"
  31. all ok, with details:
  32. string(22) "www.xn--fuball-cta.com"
  33. array(3) {
  34. ["result"]=>
  35. string(22) "www.xn--fuball-cta.com"
  36. ["isTransitionalDifferent"]=>
  37. bool(true)
  38. ["errors"]=>
  39. int(0)
  40. }
  41. reverse, ok, with details:
  42. string(16) "www.fußball.com"
  43. array(3) {
  44. ["result"]=>
  45. string(16) "www.fußball.com"
  46. ["isTransitionalDifferent"]=>
  47. bool(false)
  48. ["errors"]=>
  49. int(0)
  50. }