file s_truncf.S was initially added on branch fedora-branch.
[glibc/history.git] / libidn / idna.c
blobcf95291596978bdf73496667ff4ac5c527de1e57
1 /* idna.c Convert to or from IDN strings.
2 * Copyright (C) 2002, 2003, 2004 Simon Josefsson
4 * This file is part of GNU Libidn.
6 * GNU Libidn is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * GNU Libidn is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with GNU Libidn; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #if HAVE_CONFIG_H
23 # include "config.h"
24 #endif
26 #include <stdlib.h>
27 #include <string.h>
28 #include <stringprep.h>
29 #include <punycode.h>
31 #include "idna.h"
33 #define DOTP(c) ((c) == 0x002E || (c) == 0x3002 || \
34 (c) == 0xFF0E || (c) == 0xFF61)
36 /* Core functions */
38 /**
39 * idna_to_ascii_4i
40 * @in: input array with unicode code points.
41 * @inlen: length of input array with unicode code points.
42 * @out: output zero terminated string that must have room for at
43 * least 63 characters plus the terminating zero.
44 * @flags: IDNA flags, e.g. IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES.
46 * The ToASCII operation takes a sequence of Unicode code points that make
47 * up one label and transforms it into a sequence of code points in the
48 * ASCII range (0..7F). If ToASCII succeeds, the original sequence and the
49 * resulting sequence are equivalent labels.
51 * It is important to note that the ToASCII operation can fail. ToASCII
52 * fails if any step of it fails. If any step of the ToASCII operation
53 * fails on any label in a domain name, that domain name MUST NOT be used
54 * as an internationalized domain name. The method for deadling with this
55 * failure is application-specific.
57 * The inputs to ToASCII are a sequence of code points, the AllowUnassigned
58 * flag, and the UseSTD3ASCIIRules flag. The output of ToASCII is either a
59 * sequence of ASCII code points or a failure condition.
61 * ToASCII never alters a sequence of code points that are all in the ASCII
62 * range to begin with (although it could fail). Applying the ToASCII
63 * operation multiple times has exactly the same effect as applying it just
64 * once.
66 * Return value: Returns 0 on success, or an error code.
68 int
69 idna_to_ascii_4i (const uint32_t * in, size_t inlen, char *out, int flags)
71 size_t len, outlen;
72 uint32_t *src; /* XXX don't need to copy data? */
73 int rc;
76 * ToASCII consists of the following steps:
78 * 1. If all code points in the sequence are in the ASCII range (0..7F)
79 * then skip to step 3.
83 size_t i;
84 int inasciirange;
86 inasciirange = 1;
87 for (i = 0; i < inlen; i++)
88 if (in[i] > 0x7F)
89 inasciirange = 0;
90 if (inasciirange)
92 src = malloc (sizeof (in[0]) * (inlen + 1));
93 if (src == NULL)
94 return IDNA_MALLOC_ERROR;
96 memcpy (src, in, sizeof (in[0]) * inlen);
97 src[inlen] = 0;
99 goto step3;
104 * 2. Perform the steps specified in [NAMEPREP] and fail if there is
105 * an error. The AllowUnassigned flag is used in [NAMEPREP].
109 char *p;
111 p = stringprep_ucs4_to_utf8 (in, inlen, NULL, NULL);
112 if (p == NULL)
113 return IDNA_MALLOC_ERROR;
115 len = strlen (p);
118 char *newp;
120 len = 2 * len + 10; /* XXX better guess? */
121 newp = realloc (p, len);
122 if (newp == NULL)
124 free (p);
125 return IDNA_MALLOC_ERROR;
127 p = newp;
129 if (flags & IDNA_ALLOW_UNASSIGNED)
130 rc = stringprep_nameprep (p, len);
131 else
132 rc = stringprep_nameprep_no_unassigned (p, len);
134 while (rc == STRINGPREP_TOO_SMALL_BUFFER);
136 if (rc != STRINGPREP_OK)
138 free (p);
139 return IDNA_STRINGPREP_ERROR;
142 src = stringprep_utf8_to_ucs4 (p, -1, NULL);
144 free (p);
147 step3:
149 * 3. If the UseSTD3ASCIIRules flag is set, then perform these checks:
151 * (a) Verify the absence of non-LDH ASCII code points; that is,
152 * the absence of 0..2C, 2E..2F, 3A..40, 5B..60, and 7B..7F.
154 * (b) Verify the absence of leading and trailing hyphen-minus;
155 * that is, the absence of U+002D at the beginning and end of
156 * the sequence.
159 if (flags & IDNA_USE_STD3_ASCII_RULES)
161 size_t i;
163 for (i = 0; src[i]; i++)
164 if (src[i] <= 0x2C || src[i] == 0x2E || src[i] == 0x2F ||
165 (src[i] >= 0x3A && src[i] <= 0x40) ||
166 (src[i] >= 0x5B && src[i] <= 0x60) ||
167 (src[i] >= 0x7B && src[i] <= 0x7F))
169 free (src);
170 return IDNA_CONTAINS_NON_LDH;
173 if (src[0] == 0x002D || (i > 0 && src[i - 1] == 0x002D))
175 free (src);
176 return IDNA_CONTAINS_MINUS;
181 * 4. If all code points in the sequence are in the ASCII range
182 * (0..7F), then skip to step 8.
186 size_t i;
187 int inasciirange;
189 inasciirange = 1;
190 for (i = 0; src[i]; i++)
192 if (src[i] > 0x7F)
193 inasciirange = 0;
194 /* copy string to output buffer if we are about to skip to step8 */
195 if (i < 64)
196 out[i] = src[i];
198 if (i < 64)
199 out[i] = '\0';
200 if (inasciirange)
201 goto step8;
205 * 5. Verify that the sequence does NOT begin with the ACE prefix.
210 size_t i;
211 int match;
213 match = 1;
214 for (i = 0; match && i < strlen (IDNA_ACE_PREFIX); i++)
215 if (((uint32_t) IDNA_ACE_PREFIX[i] & 0xFF) != src[i])
216 match = 0;
217 if (match)
219 free (src);
220 return IDNA_CONTAINS_ACE_PREFIX;
225 * 6. Encode the sequence using the encoding algorithm in [PUNYCODE]
226 * and fail if there is an error.
228 for (len = 0; src[len]; len++)
230 src[len] = '\0';
231 outlen = 63 - strlen (IDNA_ACE_PREFIX);
232 rc = punycode_encode (len, src, NULL,
233 &outlen, &out[strlen (IDNA_ACE_PREFIX)]);
234 if (rc != PUNYCODE_SUCCESS)
236 free (src);
237 return IDNA_PUNYCODE_ERROR;
239 out[strlen (IDNA_ACE_PREFIX) + outlen] = '\0';
242 * 7. Prepend the ACE prefix.
245 memcpy (out, IDNA_ACE_PREFIX, strlen (IDNA_ACE_PREFIX));
248 * 8. Verify that the number of code points is in the range 1 to 63
249 * inclusive (0 is excluded).
252 step8:
253 free (src);
254 if (strlen (out) < 1 || strlen (out) > 63)
255 return IDNA_INVALID_LENGTH;
257 return IDNA_SUCCESS;
260 /* ToUnicode(). May realloc() utf8in. */
261 static int
262 idna_to_unicode_internal (char *utf8in,
263 uint32_t * out, size_t * outlen, int flags)
265 int rc;
266 char tmpout[64];
267 size_t utf8len = strlen (utf8in) + 1;
268 size_t addlen = 0;
271 * ToUnicode consists of the following steps:
273 * 1. If the sequence contains any code points outside the ASCII range
274 * (0..7F) then proceed to step 2, otherwise skip to step 3.
278 size_t i;
279 int inasciirange;
281 inasciirange = 1;
282 for (i = 0; utf8in[i]; i++)
283 if (utf8in[i] & ~0x7F)
284 inasciirange = 0;
285 if (inasciirange)
286 goto step3;
290 * 2. Perform the steps specified in [NAMEPREP] and fail if there is an
291 * error. (If step 3 of ToASCII is also performed here, it will not
292 * affect the overall behavior of ToUnicode, but it is not
293 * necessary.) The AllowUnassigned flag is used in [NAMEPREP].
297 char *newp = realloc (utf8in, utf8len + addlen);
298 if (newp == NULL)
300 free (utf8in);
301 return IDNA_MALLOC_ERROR;
303 utf8in = newp;
304 if (flags & IDNA_ALLOW_UNASSIGNED)
305 rc = stringprep_nameprep (utf8in, utf8len + addlen);
306 else
307 rc = stringprep_nameprep_no_unassigned (utf8in, utf8len + addlen);
308 addlen += 1;
310 while (rc == STRINGPREP_TOO_SMALL_BUFFER);
312 if (rc != STRINGPREP_OK)
314 free (utf8in);
315 return IDNA_STRINGPREP_ERROR;
318 /* 3. Verify that the sequence begins with the ACE prefix, and save a
319 * copy of the sequence.
322 step3:
323 if (memcmp (IDNA_ACE_PREFIX, utf8in, strlen (IDNA_ACE_PREFIX)) != 0)
325 free (utf8in);
326 return IDNA_NO_ACE_PREFIX;
329 /* 4. Remove the ACE prefix.
332 memmove (utf8in, &utf8in[strlen (IDNA_ACE_PREFIX)],
333 strlen (utf8in) - strlen (IDNA_ACE_PREFIX) + 1);
335 /* 5. Decode the sequence using the decoding algorithm in [PUNYCODE]
336 * and fail if there is an error. Save a copy of the result of
337 * this step.
340 (*outlen)--; /* reserve one for the zero */
342 rc = punycode_decode (strlen (utf8in), utf8in, outlen, out, NULL);
343 if (rc != PUNYCODE_SUCCESS)
345 free (utf8in);
346 return IDNA_PUNYCODE_ERROR;
349 out[*outlen] = 0; /* add zero */
351 /* 6. Apply ToASCII.
354 rc = idna_to_ascii_4i (out, *outlen, tmpout, flags);
355 if (rc != IDNA_SUCCESS)
357 free (utf8in);
358 return rc;
361 /* 7. Verify that the result of step 6 matches the saved copy from
362 * step 3, using a case-insensitive ASCII comparison.
365 if (strcasecmp (utf8in, tmpout + strlen (IDNA_ACE_PREFIX)) != 0)
367 free (utf8in);
368 return IDNA_ROUNDTRIP_VERIFY_ERROR;
371 /* 8. Return the saved copy from step 5.
374 free (utf8in);
375 return IDNA_SUCCESS;
379 * idna_to_unicode_44i
380 * @in: input array with unicode code points.
381 * @inlen: length of input array with unicode code points.
382 * @out: output array with unicode code points.
383 * @outlen: on input, maximum size of output array with unicode code points,
384 * on exit, actual size of output array with unicode code points.
385 * @flags: IDNA flags, e.g. IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES.
387 * The ToUnicode operation takes a sequence of Unicode code points
388 * that make up one label and returns a sequence of Unicode code
389 * points. If the input sequence is a label in ACE form, then the
390 * result is an equivalent internationalized label that is not in ACE
391 * form, otherwise the original sequence is returned unaltered.
393 * ToUnicode never fails. If any step fails, then the original input
394 * sequence is returned immediately in that step.
396 * The Punycode decoder can never output more code points than it
397 * inputs, but Nameprep can, and therefore ToUnicode can. Note that
398 * the number of octets needed to represent a sequence of code points
399 * depends on the particular character encoding used.
401 * The inputs to ToUnicode are a sequence of code points, the
402 * AllowUnassigned flag, and the UseSTD3ASCIIRules flag. The output of
403 * ToUnicode is always a sequence of Unicode code points.
405 * Return value: Returns error condition, but it must only be used for
406 * debugging purposes. The output buffer is always
407 * guaranteed to contain the correct data according to
408 * the specification (sans malloc induced errors). NB!
409 * This means that you normally ignore the return code
410 * from this function, as checking it means breaking the
411 * standard.
414 idna_to_unicode_44i (const uint32_t * in, size_t inlen,
415 uint32_t * out, size_t * outlen, int flags)
417 int rc;
418 size_t outlensave = *outlen;
419 char *p;
421 p = stringprep_ucs4_to_utf8 (in, inlen, NULL, NULL);
422 if (p == NULL)
423 return IDNA_MALLOC_ERROR;
425 rc = idna_to_unicode_internal (p, out, outlen, flags);
426 if (rc != IDNA_SUCCESS)
428 memcpy (out, in, sizeof (in[0]) * (inlen < outlensave ?
429 inlen : outlensave));
430 *outlen = inlen;
433 /* p is freed in idna_to_unicode_internal. */
435 return rc;
438 /* Wrappers that handle several labels */
441 * idna_to_ascii_4z:
442 * @input: zero terminated input Unicode string.
443 * @output: pointer to newly allocated output string.
444 * @flags: IDNA flags, e.g. IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES.
446 * Convert UCS-4 domain name to ASCII string. The domain name may
447 * contain several labels, separated by dots. The output buffer must
448 * be deallocated by the caller.
450 * Return value: Returns IDNA_SUCCESS on success, or error code.
453 idna_to_ascii_4z (const uint32_t * input, char **output, int flags)
455 const uint32_t *start = input;
456 const uint32_t *end = input;
457 char buf[64];
458 char *out = NULL;
459 int rc;
461 /* 1) Whenever dots are used as label separators, the following
462 characters MUST be recognized as dots: U+002E (full stop),
463 U+3002 (ideographic full stop), U+FF0E (fullwidth full stop),
464 U+FF61 (halfwidth ideographic full stop). */
466 if (input[0] == 0)
468 /* Handle implicit zero-length root label. */
469 *output = malloc (1);
470 if (!*output)
471 return IDNA_MALLOC_ERROR;
472 strcpy (*output, "");
473 return IDNA_SUCCESS;
476 if (DOTP (input[0]) && input[1] == 0)
478 /* Handle explicit zero-length root label. */
479 *output = malloc (2);
480 if (!*output)
481 return IDNA_MALLOC_ERROR;
482 strcpy (*output, ".");
483 return IDNA_SUCCESS;
486 *output = NULL;
489 end = start;
491 for (; *end && !DOTP (*end); end++)
494 if (*end == '\0' && start == end)
496 /* Handle explicit zero-length root label. */
497 buf[0] = '\0';
499 else
501 rc = idna_to_ascii_4i (start, end - start, buf, flags);
502 if (rc != IDNA_SUCCESS)
503 return rc;
506 if (out)
508 char *newp = realloc (out, strlen (out) + 1 + strlen (buf) + 1);
509 if (!newp)
511 free (out);
512 return IDNA_MALLOC_ERROR;
514 out = newp;
515 strcat (out, ".");
516 strcat (out, buf);
518 else
520 out = (char *) malloc (strlen (buf) + 1);
521 if (!out)
522 return IDNA_MALLOC_ERROR;
523 strcpy (out, buf);
526 start = end + 1;
528 while (*end);
530 *output = out;
532 return IDNA_SUCCESS;
536 * idna_to_ascii_8z:
537 * @input: zero terminated input UTF-8 string.
538 * @output: pointer to newly allocated output string.
539 * @flags: IDNA flags, e.g. IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES.
541 * Convert UTF-8 domain name to ASCII string. The domain name may
542 * contain several labels, separated by dots. The output buffer must
543 * be deallocated by the caller.
545 * Return value: Returns IDNA_SUCCESS on success, or error code.
548 idna_to_ascii_8z (const char *input, char **output, int flags)
550 uint32_t *ucs4;
551 size_t ucs4len;
552 int rc;
554 ucs4 = stringprep_utf8_to_ucs4 (input, -1, &ucs4len);
555 if (!ucs4)
556 return IDNA_ICONV_ERROR;
558 rc = idna_to_ascii_4z (ucs4, output, flags);
560 free (ucs4);
562 return rc;
567 * idna_to_ascii_lz:
568 * @input: zero terminated input UTF-8 string.
569 * @output: pointer to newly allocated output string.
570 * @flags: IDNA flags, e.g. IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES.
572 * Convert domain name in the locale's encoding to ASCII string. The
573 * domain name may contain several labels, separated by dots. The
574 * output buffer must be deallocated by the caller.
576 * Return value: Returns IDNA_SUCCESS on success, or error code.
579 idna_to_ascii_lz (const char *input, char **output, int flags)
581 char *utf8;
582 int rc;
584 utf8 = stringprep_locale_to_utf8 (input);
585 if (!utf8)
586 return IDNA_ICONV_ERROR;
588 rc = idna_to_ascii_8z (utf8, output, flags);
590 free (utf8);
592 return rc;
596 * idna_to_unicode_4z4z:
597 * @input: zero-terminated Unicode string.
598 * @output: pointer to newly allocated output Unicode string.
599 * @flags: IDNA flags, e.g. IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES.
601 * Convert possibly ACE encoded domain name in UCS-4 format into a
602 * UCS-4 string. The domain name may contain several labels,
603 * separated by dots. The output buffer must be deallocated by the
604 * caller.
606 * Return value: Returns IDNA_SUCCESS on success, or error code.
609 idna_to_unicode_4z4z (const uint32_t * input, uint32_t ** output, int flags)
611 const uint32_t *start = input;
612 const uint32_t *end = input;
613 uint32_t *buf;
614 size_t buflen;
615 uint32_t *out = NULL;
616 size_t outlen = 0;
617 int rc;
619 *output = NULL;
623 end = start;
625 for (; *end && !DOTP (*end); end++)
628 buflen = end - start;
629 buf = malloc (sizeof (buf[0]) * (buflen + 1));
630 if (!buf)
631 return IDNA_MALLOC_ERROR;
633 rc = idna_to_unicode_44i (start, end - start, buf, &buflen, flags);
634 /* don't check rc as per specification! */
636 if (out)
638 uint32_t *newp = realloc (out,
639 sizeof (out[0])
640 * (outlen + 1 + buflen + 1));
641 if (!newp)
643 free (buf);
644 free (out);
645 return IDNA_MALLOC_ERROR;
647 out = newp;
648 out[outlen++] = 0x002E; /* '.' (full stop) */
649 memcpy (out + outlen, buf, sizeof (buf[0]) * buflen);
650 outlen += buflen;
651 out[outlen] = 0x0;
652 free (buf);
654 else
656 out = buf;
657 outlen = buflen;
658 out[outlen] = 0x0;
661 start = end + 1;
663 while (*end);
665 *output = out;
667 return IDNA_SUCCESS;
671 * idna_to_unicode_8z4z:
672 * @input: zero-terminated UTF-8 string.
673 * @output: pointer to newly allocated output Unicode string.
674 * @flags: IDNA flags, e.g. IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES.
676 * Convert possibly ACE encoded domain name in UTF-8 format into a
677 * UCS-4 string. The domain name may contain several labels,
678 * separated by dots. The output buffer must be deallocated by the
679 * caller.
681 * Return value: Returns IDNA_SUCCESS on success, or error code.
684 idna_to_unicode_8z4z (const char *input, uint32_t ** output, int flags)
686 uint32_t *ucs4;
687 size_t ucs4len;
688 int rc;
690 ucs4 = stringprep_utf8_to_ucs4 (input, -1, &ucs4len);
691 if (!ucs4)
692 return IDNA_ICONV_ERROR;
694 rc = idna_to_unicode_4z4z (ucs4, output, flags);
695 free (ucs4);
697 return rc;
701 * idna_to_unicode_8z8z:
702 * @input: zero-terminated UTF-8 string.
703 * @output: pointer to newly allocated output UTF-8 string.
704 * @flags: IDNA flags, e.g. IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES.
706 * Convert possibly ACE encoded domain name in UTF-8 format into a
707 * UTF-8 string. The domain name may contain several labels,
708 * separated by dots. The output buffer must be deallocated by the
709 * caller.
711 * Return value: Returns IDNA_SUCCESS on success, or error code.
714 idna_to_unicode_8z8z (const char *input, char **output, int flags)
716 uint32_t *ucs4;
717 int rc;
719 rc = idna_to_unicode_8z4z (input, &ucs4, flags);
720 *output = stringprep_ucs4_to_utf8 (ucs4, -1, NULL, NULL);
721 free (ucs4);
723 if (!*output)
724 return IDNA_ICONV_ERROR;
726 return rc;
730 * idna_to_unicode_8zlz:
731 * @input: zero-terminated UTF-8 string.
732 * @output: pointer to newly allocated output string encoded in the
733 * current locale's character set.
734 * @flags: IDNA flags, e.g. IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES.
736 * Convert possibly ACE encoded domain name in UTF-8 format into a
737 * string encoded in the current locale's character set. The domain
738 * name may contain several labels, separated by dots. The output
739 * buffer must be deallocated by the caller.
741 * Return value: Returns IDNA_SUCCESS on success, or error code.
744 idna_to_unicode_8zlz (const char *input, char **output, int flags)
746 char *utf8;
747 int rc;
749 rc = idna_to_unicode_8z8z (input, &utf8, flags);
750 *output = stringprep_utf8_to_locale (utf8);
751 free (utf8);
753 if (!*output)
754 return IDNA_ICONV_ERROR;
756 return rc;
760 * idna_to_unicode_lzlz:
761 * @input: zero-terminated string encoded in the current locale's
762 * character set.
763 * @output: pointer to newly allocated output string encoded in the
764 * current locale's character set.
765 * @flags: IDNA flags, e.g. IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES.
767 * Convert possibly ACE encoded domain name in the locale's character
768 * set into a string encoded in the current locale's character set.
769 * The domain name may contain several labels, separated by dots. The
770 * output buffer must be deallocated by the caller.
772 * Return value: Returns IDNA_SUCCESS on success, or error code.
775 idna_to_unicode_lzlz (const char *input, char **output, int flags)
777 char *utf8;
778 int rc;
780 utf8 = stringprep_locale_to_utf8 (input);
781 if (!utf8)
782 return IDNA_ICONV_ERROR;
784 rc = idna_to_unicode_8zlz (utf8, output, flags);
785 free (utf8);
787 return rc;
791 * IDNA_ACE_PREFIX
793 * The IANA allocated prefix to use for IDNA. "xn--"
797 * Idna_rc:
798 * @IDNA_SUCCESS: Successful operation. This value is guaranteed to
799 * always be zero, the remaining ones are only guaranteed to hold
800 * non-zero values, for logical comparison purposes.
801 * @IDNA_STRINGPREP_ERROR: Error during string preparation.
802 * @IDNA_PUNYCODE_ERROR: Error during punycode operation.
803 * @IDNA_CONTAINS_NON_LDH: For IDNA_USE_STD3_ASCII_RULES, indicate that
804 * the string contains non-LDH ASCII characters.
805 * @IDNA_CONTAINS_MINUS: For IDNA_USE_STD3_ASCII_RULES, indicate that
806 * the string contains a leading or trailing hyphen-minus (U+002D).
807 * @IDNA_INVALID_LENGTH: The final output string is not within the
808 * (inclusive) range 1 to 63 characters.
809 * @IDNA_NO_ACE_PREFIX: The string does not contain the ACE prefix
810 * (for ToUnicode).
811 * @IDNA_ROUNDTRIP_VERIFY_ERROR: The ToASCII operation on output
812 * string does not equal the input.
813 * @IDNA_CONTAINS_ACE_PREFIX: The input contains the ACE prefix (for
814 * ToASCII).
815 * @IDNA_ICONV_ERROR: Could not convert string in locale encoding.
816 * @IDNA_MALLOC_ERROR: Could not allocate buffer (this is typically a
817 * fatal error).
818 * @IDNA_DLOPEN_ERROR: Could not dlopen the libcidn DSO (only used
819 * internally in libc).
821 * Enumerated return codes of idna_to_ascii_4i(),
822 * idna_to_unicode_44i() functions (and functions derived from those
823 * functions). The value 0 is guaranteed to always correspond to
824 * success.
829 * Idna_flags:
830 * @IDNA_ALLOW_UNASSIGNED: Don't reject strings containing unassigned
831 * Unicode code points.
832 * @IDNA_USE_STD3_ASCII_RULES: Validate strings according to STD3
833 * rules (i.e., normal host name rules).
835 * Flags to pass to idna_to_ascii_4i(), idna_to_unicode_44i() etc.