diff options
author | Anatol Belski <ab@php.net> | 2018-04-05 13:58:03 +0200 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2018-04-05 13:58:03 +0200 |
commit | 13a2f2d041999dca0066542f2a552798fab9a13d (patch) | |
tree | 6fe03f23d97cd98996ccb9d14a02a954fa51ded9 | |
parent | 08178ed2315790a73f1b6353ae4b0ad94fe7b532 (diff) | |
download | php-git-13a2f2d041999dca0066542f2a552798fab9a13d.tar.gz |
Move to non deprecated API on suitable ICU versions
-rw-r--r-- | ext/intl/idn/idn.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/ext/intl/idn/idn.c b/ext/intl/idn/idn.c index d2148cf58c..a7f40ba66e 100644 --- a/ext/intl/idn/idn.c +++ b/ext/intl/idn/idn.c @@ -218,16 +218,34 @@ static void php_intl_idn_to(INTERNAL_FUNCTION_PARAMETERS, } RETURN_FALSE; } else { - UParseError parse_error; UChar converted[MAXPATHLEN]; int32_t converted_ret_len; status = U_ZERO_ERROR; + +#if U_ICU_VERSION_MAJOR_NUM >= 55 + UIDNAInfo info = UIDNA_INFO_INITIALIZER; + UIDNA *idna = uidna_openUTS46((int32_t)option, &status); + + if (U_FAILURE(status)) { + intl_error_set( NULL, status, "idn_to_ascii: failed to create an UIDNA instance", 0 ); + RETURN_FALSE; + } + + if (mode == INTL_IDN_TO_ASCII) { + converted_ret_len = uidna_nameToASCII(idna, ustring, ustring_len, converted, MAXPATHLEN, &info, &status); + } else { + converted_ret_len = uidna_nameToUnicode(idna, ustring, ustring_len, converted, MAXPATHLEN, &info, &status); + } + uidna_close(idna); +#else + UParseError parse_error; if (mode == INTL_IDN_TO_ASCII) { converted_ret_len = uidna_IDNToASCII(ustring, ustring_len, converted, MAXPATHLEN, (int32_t)option, &parse_error, &status); } else { converted_ret_len = uidna_IDNToUnicode(ustring, ustring_len, converted, MAXPATHLEN, (int32_t)option, &parse_error, &status); } +#endif efree(ustring); if (U_FAILURE(status)) { |