42 #include <c-strcase.h>
44 #define DOTP(c) ((c) == 0x002E || (c) == 0x3002 || \
45 (c) == 0xFF0E || (c) == 0xFF61)
99 for (i = 0; i < inlen; i++)
104 src = malloc (
sizeof (in[0]) * (inlen + 1));
108 memcpy (src, in,
sizeof (in[0]) * inlen);
133 newp = realloc (p, len);
178 for (i = 0; src[i]; i++)
179 if (src[i] <= 0x2C || src[i] == 0x2E || src[i] == 0x2F ||
180 (src[i] >= 0x3A && src[i] <= 0x40) ||
181 (src[i] >= 0x5B && src[i] <= 0x60) ||
182 (src[i] >= 0x7B && src[i] <= 0x7F))
188 if (src[0] == 0x002D || (i > 0 && src[i - 1] == 0x002D))
205 for (i = 0; src[i]; i++)
248 for (len = 0; src[len]; len++)
274 if (strlen (out) < 1)
282 idna_to_unicode_internal (
char *utf8in,
283 uint32_t *out,
size_t *outlen,
int flags)
287 size_t utf8len = strlen (utf8in) + 1;
288 size_t addlen = 0, addinc = utf8len / 10 + 1;
302 for (i = 0; utf8in[i]; i++)
303 if (utf8in[i] & ~0x7F)
317 char *newp = realloc (utf8in, utf8len + addlen);
438 uint32_t *out,
size_t *outlen,
int flags)
441 size_t outlensave = *outlen;
448 rc = idna_to_unicode_internal (p, out, outlen, flags);
451 memcpy (out, in,
sizeof (in[0]) * (inlen < outlensave ?
452 inlen : outlensave));
479 const uint32_t *start = input;
493 *output = malloc (1);
496 strcpy (*output,
"");
500 if (
DOTP (input[0]) && input[1] == 0)
503 *output = malloc (2);
506 strcpy (*output,
".");
515 for (; *end && !
DOTP (*end); end++)
518 if (*end ==
'\0' && start == end)
535 size_t l = strlen (out) + 1 + strlen (buf) + 1;
536 char *newp = realloc (out, l);
642 const uint32_t *start = input;
646 uint32_t *out = NULL;
655 for (; *end && !
DOTP (*end); end++)
658 buflen = (size_t) (end - start);
659 buf = malloc (
sizeof (buf[0]) * (buflen + 1));
668 buf, &buflen, flags);
672 uint32_t *newp = realloc (out,
674 * (outlen + 1 + buflen + 1));
682 out[outlen++] = 0x002E;
683 memcpy (out + outlen, buf,
sizeof (buf[0]) * buflen);
int idna_to_unicode_8zlz(const char *input, char **output, int flags)
int idna_to_unicode_4z4z(const uint32_t *input, uint32_t **output, int flags)
int idna_to_ascii_8z(const char *input, char **output, int flags)
int idna_to_ascii_4z(const uint32_t *input, char **output, int flags)
int idna_to_unicode_lzlz(const char *input, char **output, int flags)
int idna_to_unicode_8z4z(const char *input, uint32_t **output, int flags)
int idna_to_unicode_44i(const uint32_t *in, size_t inlen, uint32_t *out, size_t *outlen, int flags)
int idna_to_unicode_8z8z(const char *input, char **output, int flags)
int idna_to_ascii_4i(const uint32_t *in, size_t inlen, char *out, int flags)
int idna_to_ascii_lz(const char *input, char **output, int flags)
@ IDNA_ROUNDTRIP_VERIFY_ERROR
@ IDNA_CONTAINS_ACE_PREFIX
@ IDNA_USE_STD3_ASCII_RULES
char * stringprep_ucs4_to_utf8(const uint32_t *str, ssize_t len, size_t *items_read, size_t *items_written)
uint32_t * stringprep_utf8_to_ucs4(const char *str, ssize_t len, size_t *items_written)
int punycode_decode(size_t input_length, const char input[], size_t *output_length, punycode_uint output[], unsigned char case_flags[])
int punycode_encode(size_t input_length, const punycode_uint input[], const unsigned char case_flags[], size_t *output_length, char output[])
IDNAPI char * stringprep_locale_to_utf8(const char *str)
@ STRINGPREP_TOO_SMALL_BUFFER
#define stringprep_nameprep(in, maxlen)
IDNAPI char * stringprep_utf8_to_locale(const char *str)
#define stringprep_nameprep_no_unassigned(in, maxlen)