xref: /PHP-8.0/ext/intl/tests/idn_uts46_basic.phpt (revision c5401854)
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?>
30--EXPECT--
31all ok, no details:
32string(22) "www.xn--fuball-cta.com"
33all ok, no details, transitional:
34string(16) "www.fussball.com"
35all ok, with details:
36string(22) "www.xn--fuball-cta.com"
37array(3) {
38  ["result"]=>
39  string(22) "www.xn--fuball-cta.com"
40  ["isTransitionalDifferent"]=>
41  bool(true)
42  ["errors"]=>
43  int(0)
44}
45reverse, ok, with details:
46string(16) "www.fußball.com"
47array(3) {
48  ["result"]=>
49  string(16) "www.fußball.com"
50  ["isTransitionalDifferent"]=>
51  bool(false)
52  ["errors"]=>
53  int(0)
54}
55