idn_uts46_basic.phpt 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. --TEST--
  2. IDN UTS #46 API basic tests
  3. --SKIPIF--
  4. <?php
  5. if (!extension_loaded('intl'))
  6. die('skip');
  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. --EXPECT--
  26. all ok, no details:
  27. string(22) "www.xn--fuball-cta.com"
  28. all ok, no details, transitional:
  29. string(16) "www.fussball.com"
  30. all ok, with details:
  31. string(22) "www.xn--fuball-cta.com"
  32. array(3) {
  33. ["result"]=>
  34. string(22) "www.xn--fuball-cta.com"
  35. ["isTransitionalDifferent"]=>
  36. bool(true)
  37. ["errors"]=>
  38. int(0)
  39. }
  40. reverse, ok, with details:
  41. string(16) "www.fußball.com"
  42. array(3) {
  43. ["result"]=>
  44. string(16) "www.fußball.com"
  45. ["isTransitionalDifferent"]=>
  46. bool(false)
  47. ["errors"]=>
  48. int(0)
  49. }