Skip to content

Commit 13a2f2d

Browse files
committed
Move to non deprecated API on suitable ICU versions
1 parent 08178ed commit 13a2f2d

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

ext/intl/idn/idn.c

+19-1
Original file line numberDiff line numberDiff line change
@@ -218,16 +218,34 @@ static void php_intl_idn_to(INTERNAL_FUNCTION_PARAMETERS,
218218
}
219219
RETURN_FALSE;
220220
} else {
221-
UParseError parse_error;
222221
UChar converted[MAXPATHLEN];
223222
int32_t converted_ret_len;
224223

225224
status = U_ZERO_ERROR;
225+
226+
#if U_ICU_VERSION_MAJOR_NUM >= 55
227+
UIDNAInfo info = UIDNA_INFO_INITIALIZER;
228+
UIDNA *idna = uidna_openUTS46((int32_t)option, &status);
229+
230+
if (U_FAILURE(status)) {
231+
intl_error_set( NULL, status, "idn_to_ascii: failed to create an UIDNA instance", 0 );
232+
RETURN_FALSE;
233+
}
234+
235+
if (mode == INTL_IDN_TO_ASCII) {
236+
converted_ret_len = uidna_nameToASCII(idna, ustring, ustring_len, converted, MAXPATHLEN, &info, &status);
237+
} else {
238+
converted_ret_len = uidna_nameToUnicode(idna, ustring, ustring_len, converted, MAXPATHLEN, &info, &status);
239+
}
240+
uidna_close(idna);
241+
#else
242+
UParseError parse_error;
226243
if (mode == INTL_IDN_TO_ASCII) {
227244
converted_ret_len = uidna_IDNToASCII(ustring, ustring_len, converted, MAXPATHLEN, (int32_t)option, &parse_error, &status);
228245
} else {
229246
converted_ret_len = uidna_IDNToUnicode(ustring, ustring_len, converted, MAXPATHLEN, (int32_t)option, &parse_error, &status);
230247
}
248+
#endif
231249
efree(ustring);
232250

233251
if (U_FAILURE(status)) {

0 commit comments

Comments
 (0)