1<?php 2 3/* 4 * This file is part of the Symfony package. 5 * 6 * (c) Fabien Potencier <fabien@symfony.com> 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12use Symfony\Polyfill\Intl\Idn as p; 13 14if (extension_loaded('intl')) { 15 return; 16} 17 18if (\PHP_VERSION_ID >= 80000) { 19 return require __DIR__.'/bootstrap80.php'; 20} 21 22if (!defined('U_IDNA_PROHIBITED_ERROR')) { 23 define('U_IDNA_PROHIBITED_ERROR', 66560); 24} 25if (!defined('U_IDNA_ERROR_START')) { 26 define('U_IDNA_ERROR_START', 66560); 27} 28if (!defined('U_IDNA_UNASSIGNED_ERROR')) { 29 define('U_IDNA_UNASSIGNED_ERROR', 66561); 30} 31if (!defined('U_IDNA_CHECK_BIDI_ERROR')) { 32 define('U_IDNA_CHECK_BIDI_ERROR', 66562); 33} 34if (!defined('U_IDNA_STD3_ASCII_RULES_ERROR')) { 35 define('U_IDNA_STD3_ASCII_RULES_ERROR', 66563); 36} 37if (!defined('U_IDNA_ACE_PREFIX_ERROR')) { 38 define('U_IDNA_ACE_PREFIX_ERROR', 66564); 39} 40if (!defined('U_IDNA_VERIFICATION_ERROR')) { 41 define('U_IDNA_VERIFICATION_ERROR', 66565); 42} 43if (!defined('U_IDNA_LABEL_TOO_LONG_ERROR')) { 44 define('U_IDNA_LABEL_TOO_LONG_ERROR', 66566); 45} 46if (!defined('U_IDNA_ZERO_LENGTH_LABEL_ERROR')) { 47 define('U_IDNA_ZERO_LENGTH_LABEL_ERROR', 66567); 48} 49if (!defined('U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR')) { 50 define('U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR', 66568); 51} 52if (!defined('U_IDNA_ERROR_LIMIT')) { 53 define('U_IDNA_ERROR_LIMIT', 66569); 54} 55if (!defined('U_STRINGPREP_PROHIBITED_ERROR')) { 56 define('U_STRINGPREP_PROHIBITED_ERROR', 66560); 57} 58if (!defined('U_STRINGPREP_UNASSIGNED_ERROR')) { 59 define('U_STRINGPREP_UNASSIGNED_ERROR', 66561); 60} 61if (!defined('U_STRINGPREP_CHECK_BIDI_ERROR')) { 62 define('U_STRINGPREP_CHECK_BIDI_ERROR', 66562); 63} 64if (!defined('IDNA_DEFAULT')) { 65 define('IDNA_DEFAULT', 0); 66} 67if (!defined('IDNA_ALLOW_UNASSIGNED')) { 68 define('IDNA_ALLOW_UNASSIGNED', 1); 69} 70if (!defined('IDNA_USE_STD3_RULES')) { 71 define('IDNA_USE_STD3_RULES', 2); 72} 73if (!defined('IDNA_CHECK_BIDI')) { 74 define('IDNA_CHECK_BIDI', 4); 75} 76if (!defined('IDNA_CHECK_CONTEXTJ')) { 77 define('IDNA_CHECK_CONTEXTJ', 8); 78} 79if (!defined('IDNA_NONTRANSITIONAL_TO_ASCII')) { 80 define('IDNA_NONTRANSITIONAL_TO_ASCII', 16); 81} 82if (!defined('IDNA_NONTRANSITIONAL_TO_UNICODE')) { 83 define('IDNA_NONTRANSITIONAL_TO_UNICODE', 32); 84} 85if (!defined('INTL_IDNA_VARIANT_2003')) { 86 define('INTL_IDNA_VARIANT_2003', 0); 87} 88if (!defined('INTL_IDNA_VARIANT_UTS46')) { 89 define('INTL_IDNA_VARIANT_UTS46', 1); 90} 91if (!defined('IDNA_ERROR_EMPTY_LABEL')) { 92 define('IDNA_ERROR_EMPTY_LABEL', 1); 93} 94if (!defined('IDNA_ERROR_LABEL_TOO_LONG')) { 95 define('IDNA_ERROR_LABEL_TOO_LONG', 2); 96} 97if (!defined('IDNA_ERROR_DOMAIN_NAME_TOO_LONG')) { 98 define('IDNA_ERROR_DOMAIN_NAME_TOO_LONG', 4); 99} 100if (!defined('IDNA_ERROR_LEADING_HYPHEN')) { 101 define('IDNA_ERROR_LEADING_HYPHEN', 8); 102} 103if (!defined('IDNA_ERROR_TRAILING_HYPHEN')) { 104 define('IDNA_ERROR_TRAILING_HYPHEN', 16); 105} 106if (!defined('IDNA_ERROR_HYPHEN_3_4')) { 107 define('IDNA_ERROR_HYPHEN_3_4', 32); 108} 109if (!defined('IDNA_ERROR_LEADING_COMBINING_MARK')) { 110 define('IDNA_ERROR_LEADING_COMBINING_MARK', 64); 111} 112if (!defined('IDNA_ERROR_DISALLOWED')) { 113 define('IDNA_ERROR_DISALLOWED', 128); 114} 115if (!defined('IDNA_ERROR_PUNYCODE')) { 116 define('IDNA_ERROR_PUNYCODE', 256); 117} 118if (!defined('IDNA_ERROR_LABEL_HAS_DOT')) { 119 define('IDNA_ERROR_LABEL_HAS_DOT', 512); 120} 121if (!defined('IDNA_ERROR_INVALID_ACE_LABEL')) { 122 define('IDNA_ERROR_INVALID_ACE_LABEL', 1024); 123} 124if (!defined('IDNA_ERROR_BIDI')) { 125 define('IDNA_ERROR_BIDI', 2048); 126} 127if (!defined('IDNA_ERROR_CONTEXTJ')) { 128 define('IDNA_ERROR_CONTEXTJ', 4096); 129} 130 131if (\PHP_VERSION_ID < 70400) { 132 if (!function_exists('idn_to_ascii')) { 133 function idn_to_ascii($domain, $flags = 0, $variant = \INTL_IDNA_VARIANT_2003, &$idna_info = null) { return p\Idn::idn_to_ascii($domain, $flags, $variant, $idna_info); } 134 } 135 if (!function_exists('idn_to_utf8')) { 136 function idn_to_utf8($domain, $flags = 0, $variant = \INTL_IDNA_VARIANT_2003, &$idna_info = null) { return p\Idn::idn_to_utf8($domain, $flags, $variant, $idna_info); } 137 } 138} else { 139 if (!function_exists('idn_to_ascii')) { 140 function idn_to_ascii($domain, $flags = 0, $variant = \INTL_IDNA_VARIANT_UTS46, &$idna_info = null) { return p\Idn::idn_to_ascii($domain, $flags, $variant, $idna_info); } 141 } 142 if (!function_exists('idn_to_utf8')) { 143 function idn_to_utf8($domain, $flags = 0, $variant = \INTL_IDNA_VARIANT_UTS46, &$idna_info = null) { return p\Idn::idn_to_utf8($domain, $flags, $variant, $idna_info); } 144 } 145} 146