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