Use TR46 transitional with libidn2 >= 0.14

This commit is contained in:
Tim Rühsen 2017-01-03 12:30:43 +01:00
parent 7d5f3a67af
commit 2c17d56234
1 changed files with 12 additions and 0 deletions

View File

@ -701,6 +701,17 @@ static int _psl_idna_toASCII(_psl_idna_t *idna _UNUSED, const char *utf8, char *
fprintf(stderr, "Failed to convert UTF-8 to UTF-16 (status %d)\n", status); */
}
#elif defined(WITH_LIBIDN2)
#if IDN2_VERSION_NUMBER >= 0x00140000
int rc;
/* IDN2_TRANSITIONAL automatically converts to lowercase */
/* IDN2_NFC_INPUT converts to NFC before toASCII conversion */
if ((rc = idn2_lookup_u8((uint8_t *)utf8, (uint8_t **)ascii, IDN2_NFC_INPUT | IDN2_TRANSITIONAL)) == IDN2_OK)
ret = 0;
/* else
fprintf(stderr, "toASCII(%s) failed (%d): %s\n", lower, rc, idn2_strerror(rc)); */
#else
int rc;
uint8_t *lower;
size_t len = u8_strlen((uint8_t *)utf8) + 1;
@ -717,6 +728,7 @@ static int _psl_idna_toASCII(_psl_idna_t *idna _UNUSED, const char *utf8, char *
fprintf(stderr, "toASCII(%s) failed (%d): %s\n", lower, rc, idn2_strerror(rc)); */
free(lower);
#endif
#elif defined(WITH_LIBIDN)
int rc;