xref: /PHP-5.4/ext/intl/tests/idn_uts46_basic.phpt (revision 5fa1cfbb)
1--TEST--
2IDN 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
14echo "all ok, no details:", "\n";
15var_dump(idn_to_ascii($utf8dn,
16	IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46));
17
18echo "all ok, no details, transitional:", "\n";
19var_dump(idn_to_ascii($utf8dn, 0, INTL_IDNA_VARIANT_UTS46));
20
21echo "all ok, with details:", "\n";
22var_dump(idn_to_ascii($utf8dn, IDNA_NONTRANSITIONAL_TO_ASCII,
23	INTL_IDNA_VARIANT_UTS46, $info));
24var_dump($info);
25
26echo "reverse, ok, with details:", "\n";
27var_dump(idn_to_utf8($asciiNonTrans, 0, INTL_IDNA_VARIANT_UTS46, $info));
28var_dump($info);
29--EXPECT--
30all ok, no details:
31string(22) "www.xn--fuball-cta.com"
32all ok, no details, transitional:
33string(16) "www.fussball.com"
34all ok, with details:
35string(22) "www.xn--fuball-cta.com"
36array(3) {
37  ["result"]=>
38  string(22) "www.xn--fuball-cta.com"
39  ["isTransitionalDifferent"]=>
40  bool(true)
41  ["errors"]=>
42  int(0)
43}
44reverse, ok, with details:
45string(16) "www.fußball.com"
46array(3) {
47  ["result"]=>
48  string(16) "www.fußball.com"
49  ["isTransitionalDifferent"]=>
50  bool(false)
51  ["errors"]=>
52  int(0)
53}
54