Create separat convertDomainToIDNA function in func.php

Signed-off-by: Christian König <ckoenig@posteo.de>
This commit is contained in:
Christian König
2022-07-13 19:42:18 +02:00
parent 6656865e5b
commit 678b4c96b6
3 changed files with 19 additions and 25 deletions

View File

@@ -554,4 +554,18 @@ function getGateway() {
}
return $ret;
}
//Convert a given (unicode) domain to IDNA ASCII
function convertDomainToIDNA($IDNA) {
if (extension_loaded("intl")) {
// Be prepared that this may fail and see our comments about "idn_to_utf8
if (defined("INTL_IDNA_VARIANT_UTS46")) {
$IDNA = idn_to_ascii($IDNA, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46);
} elseif (defined("INTL_IDNA_VARIANT_2003")) {
$IDNA = idn_to_ascii($IDNA, IDNA_DEFAULT, INTL_IDNA_VARIANT_2003);
}
}
return $IDNA;
}
?>