monotone

monotone Mtn Source Tree

Root/idna/idna.c

1/* idna.cConvert to or from IDN strings.
2 * Copyright (C) 2002, 2003 Simon Josefsson
3 *
4 * This file is part of GNU Libidn.
5 *
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.
10 *
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.
15 *
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
19 *
20 */
21
22#if HAVE_CONFIG_H
23# include "config.h"
24#endif
25
26#include <stdlib.h>
27#include <string.h>
28#include "idna/stringprep.h"
29#include "idna/punycode.h"
30
31#include "idna/idna.h"
32
33#ifdef _MSC_VER
34#define strcasecmp(a,b) _stricmp(a,b)
35#endif
36
37#define DOTP(c) ((c) == 0x002E || (c) == 0x3002 ||\
38 (c) == 0xFF0E || (c) == 0xFF61)
39
40/* Core functions */
41
42/**
43 * idna_to_ascii_4i
44 * @in: input array with unicode code points.
45 * @inlen: length of input array with unicode code points.
46 * @out: output zero terminated string that must have room for at
47 * least 63 characters plus the terminating zero.
48 * @flags: IDNA flags, e.g. IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES.
49 *
50 * The ToASCII operation takes a sequence of Unicode code points that make
51 * up one label and transforms it into a sequence of code points in the
52 * ASCII range (0..7F). If ToASCII succeeds, the original sequence and the
53 * resulting sequence are equivalent labels.
54 *
55 * It is important to note that the ToASCII operation can fail. ToASCII
56 * fails if any step of it fails. If any step of the ToASCII operation
57 * fails on any label in a domain name, that domain name MUST NOT be used
58 * as an internationalized domain name. The method for deadling with this
59 * failure is application-specific.
60 *
61 * The inputs to ToASCII are a sequence of code points, the AllowUnassigned
62 * flag, and the UseSTD3ASCIIRules flag. The output of ToASCII is either a
63 * sequence of ASCII code points or a failure condition.
64 *
65 * ToASCII never alters a sequence of code points that are all in the ASCII
66 * range to begin with (although it could fail). Applying the ToASCII
67 * operation multiple times has exactly the same effect as applying it just
68 * once.
69 *
70 * Return value: Returns 0 on success, or an error code.
71 */
72int
73idna_to_ascii_4i (const uint32_t * in, size_t inlen, char *out, int flags)
74{
75 size_t len, outlen;
76 uint32_t *src;/* XXX don't need to copy data? */
77 int rc;
78
79 /*
80 * ToASCII consists of the following steps:
81 *
82 * 1. If all code points in the sequence are in the ASCII range (0..7F)
83 * then skip to step 3.
84 */
85
86 {
87 size_t i;
88 int inasciirange;
89
90 inasciirange = 1;
91 for (i = 0; i < inlen; i++)
92 if (in[i] > 0x7F)
93inasciirange = 0;
94 if (inasciirange)
95 {
96src = malloc (sizeof (in[0]) * (inlen + 1));
97if (src == NULL)
98 return IDNA_MALLOC_ERROR;
99
100memcpy (src, in, sizeof (in[0]) * inlen);
101src[inlen] = 0;
102
103goto step3;
104 }
105 }
106
107 /*
108 * 2. Perform the steps specified in [NAMEPREP] and fail if there is
109 * an error. The AllowUnassigned flag is used in [NAMEPREP].
110 */
111
112 {
113 char *p;
114
115 p = stringprep_ucs4_to_utf8 (in, inlen, NULL, NULL);
116 if (p == NULL)
117 return IDNA_MALLOC_ERROR;
118
119 len = strlen (p);
120 do
121 {
122len = 2 * len + 10;/* XXX better guess? */
123p = realloc (p, len);
124if (p == NULL)
125 return IDNA_MALLOC_ERROR;
126
127if (flags & IDNA_ALLOW_UNASSIGNED)
128 rc = stringprep_nameprep (p, len);
129else
130 rc = stringprep_nameprep_no_unassigned (p, len);
131 }
132 while (rc == STRINGPREP_TOO_SMALL_BUFFER);
133
134 if (rc != STRINGPREP_OK)
135 {
136free (p);
137return IDNA_STRINGPREP_ERROR;
138 }
139
140 src = stringprep_utf8_to_ucs4 (p, -1, NULL);
141
142 free (p);
143 }
144
145step3:
146 /*
147 * 3. If the UseSTD3ASCIIRules flag is set, then perform these checks:
148 *
149 * (a) Verify the absence of non-LDH ASCII code points; that is,
150 * the absence of 0..2C, 2E..2F, 3A..40, 5B..60, and 7B..7F.
151 *
152 * (b) Verify the absence of leading and trailing hyphen-minus;
153 * that is, the absence of U+002D at the beginning and end of
154 * the sequence.
155 */
156
157 if (flags & IDNA_USE_STD3_ASCII_RULES)
158 {
159 size_t i;
160
161 for (i = 0; src[i]; i++)
162if (src[i] <= 0x2C || src[i] == 0x2E || src[i] == 0x2F ||
163 (src[i] >= 0x3A && src[i] <= 0x40) ||
164 (src[i] >= 0x5B && src[i] <= 0x60) ||
165 (src[i] >= 0x7B && src[i] <= 0x7F))
166 {
167 free (src);
168 return IDNA_CONTAINS_NON_LDH;
169 }
170
171 if (src[0] == 0x002D || (i > 0 && src[i - 1] == 0x002D))
172{
173 free (src);
174 return IDNA_CONTAINS_MINUS;
175}
176 }
177
178 /*
179 * 4. If all code points in the sequence are in the ASCII range
180 * (0..7F), then skip to step 8.
181 */
182
183 {
184 size_t i;
185 int inasciirange;
186
187 inasciirange = 1;
188 for (i = 0; src[i]; i++)
189 {
190if (src[i] > 0x7F)
191 inasciirange = 0;
192/* copy string to output buffer if we are about to skip to step8 */
193if (i < 64)
194 out[i] = src[i];
195 }
196 if (i < 64)
197 out[i] = '\0';
198 if (inasciirange)
199 goto step8;
200 }
201
202 /*
203 * 5. Verify that the sequence does NOT begin with the ACE prefix.
204 *
205 */
206
207 {
208 size_t i;
209 int match;
210
211 match = 1;
212 for (i = 0; match && i < strlen (IDNA_ACE_PREFIX); i++)
213 if (((uint32_t) IDNA_ACE_PREFIX[i] & 0xFF) != src[i])
214match = 0;
215 if (match)
216 {
217free (src);
218return IDNA_CONTAINS_ACE_PREFIX;
219 }
220 }
221
222 /*
223 * 6. Encode the sequence using the encoding algorithm in [PUNYCODE]
224 * and fail if there is an error.
225 */
226 for (len = 0; src[len]; len++)
227 ;
228 src[len] = '\0';
229 outlen = 63 - strlen (IDNA_ACE_PREFIX);
230 rc = punycode_encode (len, src, NULL,
231&outlen, &out[strlen (IDNA_ACE_PREFIX)]);
232 if (rc != PUNYCODE_SUCCESS)
233 {
234 free (src);
235 return IDNA_PUNYCODE_ERROR;
236 }
237 out[strlen (IDNA_ACE_PREFIX) + outlen] = '\0';
238
239 /*
240 * 7. Prepend the ACE prefix.
241 */
242
243 memcpy (out, IDNA_ACE_PREFIX, strlen (IDNA_ACE_PREFIX));
244
245 /*
246 * 8. Verify that the number of code points is in the range 1 to 63
247 * inclusive.
248 */
249
250step8:
251 free (src);
252 if (strlen (out) < 1 || strlen (out) > 63)
253 return IDNA_INVALID_LENGTH;
254
255 return IDNA_SUCCESS;
256}
257
258/* ToUnicode(). May realloc() utf8in. */
259static int
260idna_to_unicode_internal (char *utf8in,
261 uint32_t * out, size_t * outlen, int flags)
262{
263 int rc;
264 char tmpout[64];
265 size_t utf8len = strlen (utf8in) + 1;
266 size_t addlen = 0;
267
268 /*
269 * 1. If all code points in the sequence are in the ASCII range (0..7F)
270 * then skip to step 3.
271 */
272
273 {
274 size_t i;
275 int inasciirange;
276
277 inasciirange = 1;
278 for (i = 0; utf8in[i]; i++)
279 if (utf8in[i] & ~0x7F)
280inasciirange = 0;
281 if (inasciirange)
282 goto step3;
283 }
284
285 /*
286 * 2. Perform the steps specified in [NAMEPREP] and fail if there is an
287 * error. (If step 3 of ToASCII is also performed here, it will not
288 * affect the overall behavior of ToUnicode, but it is not
289 * necessary.) The AllowUnassigned flag is used in [NAMEPREP].
290 */
291 do
292 {
293 utf8in = realloc (utf8in, utf8len + addlen);
294 if (!utf8in)
295return IDNA_MALLOC_ERROR;
296 if (flags & IDNA_ALLOW_UNASSIGNED)
297rc = stringprep_nameprep (utf8in, utf8len + addlen);
298 else
299rc = stringprep_nameprep_no_unassigned (utf8in, utf8len + addlen);
300 addlen += 1;
301 }
302 while (rc == STRINGPREP_TOO_SMALL_BUFFER);
303
304 if (rc != STRINGPREP_OK)
305 return IDNA_STRINGPREP_ERROR;
306
307 /* 3. Verify that the sequence begins with the ACE prefix, and save a
308 * copy of the sequence.
309 */
310
311step3:
312 if (memcmp (IDNA_ACE_PREFIX, utf8in, strlen (IDNA_ACE_PREFIX)) != 0)
313 return IDNA_NO_ACE_PREFIX;
314
315 /* 4. Remove the ACE prefix.
316 */
317
318 memmove (utf8in, &utf8in[strlen (IDNA_ACE_PREFIX)],
319 strlen (utf8in) - strlen (IDNA_ACE_PREFIX) + 1);
320
321 /* 5. Decode the sequence using the decoding algorithm in [PUNYCODE]
322 * and fail if there is an error. Save a copy of the result of
323 * this step.
324 */
325
326 (*outlen)--;/* reserve one for the zero */
327
328 rc = punycode_decode (strlen (utf8in), utf8in, outlen, out, NULL);
329 if (rc != PUNYCODE_SUCCESS)
330 return IDNA_PUNYCODE_ERROR;
331
332 out[*outlen] = 0;/* add zero */
333
334 /* 6. Apply ToASCII.
335 */
336
337 rc = idna_to_ascii_4i (out, *outlen, tmpout, flags);
338 if (rc != IDNA_SUCCESS)
339 return rc;
340
341 /* 7. Verify that the result of step 6 matches the saved copy from
342 * step 3, using a case-insensitive ASCII comparison.
343 */
344
345 if (strcasecmp (utf8in, tmpout + strlen (IDNA_ACE_PREFIX)) != 0)
346 return IDNA_ROUNDTRIP_VERIFY_ERROR;
347
348 /* 8. Return the saved copy from step 5.
349 */
350
351 return IDNA_SUCCESS;
352}
353
354/**
355 * idna_to_unicode_44i
356 * @in: input array with unicode code points.
357 * @inlen: length of input array with unicode code points.
358 * @out: output array with unicode code points.
359 * @outlen: on input, maximum size of output array with unicode code points,
360 * on exit, actual size of output array with unicode code points.
361 * @flags: IDNA flags, e.g. IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES.
362 *
363 * The ToUnicode operation takes a sequence of Unicode code points
364 * that make up one label and returns a sequence of Unicode code
365 * points. If the input sequence is a label in ACE form, then the
366 * result is an equivalent internationalized label that is not in ACE
367 * form, otherwise the original sequence is returned unaltered.
368 *
369 * ToUnicode never fails. If any step fails, then the original input
370 * sequence is returned immediately in that step.
371 *
372 * The ToUnicode output never contains more code points than its
373 * input. Note that the number of octets needed to represent a
374 * sequence of code points depends on the particular character
375 * encoding used.
376 *
377 * The inputs to ToUnicode are a sequence of code points, the
378 * AllowUnassigned flag, and the UseSTD3ASCIIRules flag. The output of
379 * ToUnicode is always a sequence of Unicode code points.
380 *
381 * Return value: Returns error condition, but it must only be used for
382 * debugging purposes. The output buffer is always
383 * guaranteed to contain the correct data according to
384 * the specification (sans malloc induced errors). NB!
385 * This means that you normally ignore the return code
386 * from this function, as checking it means breaking the
387 * standard.
388 */
389int
390idna_to_unicode_44i (const uint32_t * in, size_t inlen,
391 uint32_t * out, size_t * outlen, int flags)
392{
393 int rc;
394 size_t outlensave = *outlen;
395 char *p;
396
397 p = stringprep_ucs4_to_utf8 (in, inlen, NULL, NULL);
398 if (p == NULL)
399 return IDNA_MALLOC_ERROR;
400
401 rc = idna_to_unicode_internal (p, out, outlen, flags);
402 if (rc != IDNA_SUCCESS)
403 {
404 memcpy (out, in, sizeof (in[0]) * (inlen < outlensave ?
405 inlen : outlensave));
406 *outlen = inlen;
407 }
408
409 free (p);
410
411 return rc;
412}
413
414/* Wrappers that handle several labels */
415
416/**
417 * idna_to_ascii_4z:
418 * @input: zero terminated input Unicode string.
419 * @output: pointer to newly allocated output string.
420 * @flags: IDNA flags, e.g. IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES.
421 *
422 * Convert UCS-4 domain name to ASCII string. The domain name may
423 * contain several labels, separated by dots. The output buffer must
424 * be deallocated by the caller.
425 *
426 * Return value: Returns IDNA_SUCCESS on success, or error code.
427 **/
428int
429idna_to_ascii_4z (const uint32_t * input, char **output, int flags)
430{
431 const uint32_t *start = input;
432 const uint32_t *end = input;
433 char buf[64];
434 char *out = NULL;
435 int rc;
436
437 /* 1) Whenever dots are used as label separators, the following
438 characters MUST be recognized as dots: U+002E (full stop),
439 U+3002 (ideographic full stop), U+FF0E (fullwidth full stop),
440 U+FF61 (halfwidth ideographic full stop). */
441
442 if (input[0] == 0)
443 {
444 /* Handle implicit zero-length root label. */
445 *output = malloc (1);
446 if (!*output)
447return IDNA_MALLOC_ERROR;
448 strcpy (*output, "");
449 return IDNA_SUCCESS;
450 }
451
452 if (DOTP (input[0]) && input[1] == 0)
453 {
454 /* Handle explicit zero-length root label. */
455 *output = malloc (2);
456 if (!*output)
457return IDNA_MALLOC_ERROR;
458 strcpy (*output, ".");
459 return IDNA_SUCCESS;
460 }
461
462 *output = NULL;
463 do
464 {
465 end = start;
466
467 for (; *end && !DOTP (*end); end++)
468;
469
470 if (*end == '\0' && start == end)
471{
472 /* Handle explicit zero-length root label. */
473 buf[0] = '\0';
474}
475 else
476{
477 rc = idna_to_ascii_4i (start, end - start, buf, flags);
478 if (rc != IDNA_SUCCESS)
479 return rc;
480}
481
482 if (out)
483{
484 out = realloc (out, strlen (out) + 1 + strlen (buf) + 1);
485 if (!out)
486 return IDNA_MALLOC_ERROR;
487 strcat (out, ".");
488 strcat (out, buf);
489}
490 else
491{
492 out = (char *) malloc (strlen (buf) + 1);
493 if (!out)
494 return IDNA_MALLOC_ERROR;
495 strcpy (out, buf);
496}
497
498 start = end + 1;
499 }
500 while (*end);
501
502 *output = out;
503
504 return IDNA_SUCCESS;
505}
506
507/**
508 * idna_to_ascii_8z:
509 * @input: zero terminated input UTF-8 string.
510 * @output: pointer to newly allocated output string.
511 * @flags: IDNA flags, e.g. IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES.
512 *
513 * Convert UTF-8 domain name to ASCII string. The domain name may
514 * contain several labels, separated by dots. The output buffer must
515 * be deallocated by the caller.
516 *
517 * Return value: Returns IDNA_SUCCESS on success, or error code.
518 **/
519int
520idna_to_ascii_8z (const char *input, char **output, int flags)
521{
522 uint32_t *ucs4;
523 size_t ucs4len;
524 int rc;
525
526 ucs4 = stringprep_utf8_to_ucs4 (input, -1, &ucs4len);
527 if (!ucs4)
528 return IDNA_ICONV_ERROR;
529
530 rc = idna_to_ascii_4z (ucs4, output, flags);
531
532 free (ucs4);
533
534 return rc;
535
536}
537
538/**
539 * idna_to_ascii_lz:
540 * @input: zero terminated input UTF-8 string.
541 * @output: pointer to newly allocated output string.
542 * @flags: IDNA flags, e.g. IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES.
543 *
544 * Convert domain name in the locale's encoding to ASCII string. The
545 * domain name may contain several labels, separated by dots. The
546 * output buffer must be deallocated by the caller.
547 *
548 * Return value: Returns IDNA_SUCCESS on success, or error code.
549 **/
550int
551idna_to_ascii_lz (const char *input, char **output, int flags)
552{
553 char *utf8;
554 int rc;
555
556 utf8 = stringprep_locale_to_utf8 (input);
557 if (!utf8)
558 return IDNA_ICONV_ERROR;
559
560 rc = idna_to_ascii_8z (utf8, output, flags);
561
562 free (utf8);
563
564 return rc;
565}
566
567/**
568 * idna_to_unicode_4z4z:
569 * @input: zero-terminated Unicode string.
570 * @output: pointer to newly allocated output Unicode string.
571 * @flags: IDNA flags, e.g. IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES.
572 *
573 * Convert possibly ACE encoded domain name in UCS-4 format into a
574 * UCS-4 string. The domain name may contain several labels,
575 * separated by dots. The output buffer must be deallocated by the
576 * caller.
577 *
578 * Return value: Returns IDNA_SUCCESS on success, or error code.
579 **/
580int
581idna_to_unicode_4z4z (const uint32_t * input, uint32_t ** output, int flags)
582{
583 const uint32_t *start = input;
584 const uint32_t *end = input;
585 uint32_t *buf;
586 size_t buflen;
587 uint32_t *out = NULL;
588 size_t outlen = 0;
589 int rc;
590
591 *output = NULL;
592
593 do
594 {
595 end = start;
596
597 for (; *end && !DOTP (*end); end++)
598;
599
600 buflen = end - start;
601 buf = malloc (sizeof (buf[0]) * (buflen + 1));
602 if (!buf)
603return IDNA_MALLOC_ERROR;
604
605 rc = idna_to_unicode_44i (start, end - start, buf, &buflen, flags);
606 /* don't check rc as per specification! */
607
608 if (out)
609{
610 out = realloc (out, sizeof (out[0]) * (outlen + 1 + buflen + 1));
611 if (!out)
612 return IDNA_MALLOC_ERROR;
613 out[outlen++] = 0x002E;/* '.' (full stop) */
614 memcpy (out + outlen, buf, sizeof (buf[0]) * buflen);
615 outlen += buflen;
616 out[outlen] = 0x0;
617 free (buf);
618}
619 else
620{
621 out = buf;
622 outlen = buflen;
623 out[outlen] = 0x0;
624}
625
626 start = end + 1;
627 }
628 while (*end);
629
630 *output = out;
631
632 return IDNA_SUCCESS;
633}
634
635/**
636 * idna_to_unicode_8z4z:
637 * @input: zero-terminated UTF-8 string.
638 * @output: pointer to newly allocated output Unicode string.
639 * @flags: IDNA flags, e.g. IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES.
640 *
641 * Convert possibly ACE encoded domain name in UTF-8 format into a
642 * UCS-4 string. The domain name may contain several labels,
643 * separated by dots. The output buffer must be deallocated by the
644 * caller.
645 *
646 * Return value: Returns IDNA_SUCCESS on success, or error code.
647 **/
648int
649idna_to_unicode_8z4z (const char *input, uint32_t ** output, int flags)
650{
651 uint32_t *ucs4;
652 size_t ucs4len;
653 int rc;
654
655 ucs4 = stringprep_utf8_to_ucs4 (input, -1, &ucs4len);
656 if (!ucs4)
657 return IDNA_ICONV_ERROR;
658
659 rc = idna_to_unicode_4z4z (ucs4, output, flags);
660 free (ucs4);
661
662 return rc;
663}
664
665/**
666 * idna_to_unicode_8z8z:
667 * @input: zero-terminated UTF-8 string.
668 * @output: pointer to newly allocated output UTF-8 string.
669 * @flags: IDNA flags, e.g. IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES.
670 *
671 * Convert possibly ACE encoded domain name in UTF-8 format into a
672 * UTF-8 string. The domain name may contain several labels,
673 * separated by dots. The output buffer must be deallocated by the
674 * caller.
675 *
676 * Return value: Returns IDNA_SUCCESS on success, or error code.
677 **/
678int
679idna_to_unicode_8z8z (const char *input, char **output, int flags)
680{
681 uint32_t *ucs4;
682 int rc;
683
684 rc = idna_to_unicode_8z4z (input, &ucs4, flags);
685 *output = stringprep_ucs4_to_utf8 (ucs4, -1, NULL, NULL);
686 free (ucs4);
687
688 if (!*output)
689 return IDNA_ICONV_ERROR;
690
691 return rc;
692}
693
694/**
695 * idna_to_unicode_8zlz:
696 * @input: zero-terminated UTF-8 string.
697 * @output: pointer to newly allocated output string encoded in the
698 * current locale's character set.
699 * @flags: IDNA flags, e.g. IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES.
700 *
701 * Convert possibly ACE encoded domain name in UTF-8 format into a
702 * string encoded in the current locale's character set. The domain
703 * name may contain several labels, separated by dots. The output
704 * buffer must be deallocated by the caller.
705 *
706 * Return value: Returns IDNA_SUCCESS on success, or error code.
707 **/
708int
709idna_to_unicode_8zlz (const char *input, char **output, int flags)
710{
711 char *utf8;
712 int rc;
713
714 rc = idna_to_unicode_8z8z (input, &utf8, flags);
715 *output = stringprep_utf8_to_locale (utf8);
716 free (utf8);
717
718 if (!*output)
719 return IDNA_ICONV_ERROR;
720
721 return rc;
722}
723
724/**
725 * idna_to_unicode_lzlz:
726 * @input: zero-terminated string encoded in the current locale's
727 * character set.
728 * @output: pointer to newly allocated output string encoded in the
729 * current locale's character set.
730 * @flags: IDNA flags, e.g. IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES.
731 *
732 * Convert possibly ACE encoded domain name in the locale's character
733 * set into a string encoded in the current locale's character set.
734 * The domain name may contain several labels, separated by dots. The
735 * output buffer must be deallocated by the caller.
736 *
737 * Return value: Returns IDNA_SUCCESS on success, or error code.
738 **/
739int
740idna_to_unicode_lzlz (const char *input, char **output, int flags)
741{
742 char *utf8;
743 int rc;
744
745 utf8 = stringprep_locale_to_utf8 (input);
746 if (!utf8)
747 return IDNA_ICONV_ERROR;
748
749 rc = idna_to_unicode_8zlz (utf8, output, flags);
750 free (utf8);
751
752 return rc;
753}
754
755/**
756 * IDNA_ACE_PREFIX
757 *
758 * The IANA allocated prefix to use for IDNA. "xn--"
759 */
760
761/**
762 * Idna_rc:
763 * @IDNA_SUCCESS: Successful operation. This value is guaranteed to
764 * always be zero, the remaining ones are only guaranteed to hold
765 * non-zero values, for logical comparison purposes.
766 * @IDNA_STRINGPREP_ERROR: Error during string preparation.
767 * @IDNA_PUNYCODE_ERROR: Error during punycode operation.
768 * @IDNA_CONTAINS_NON_LDH: For IDNA_USE_STD3_ASCII_RULES, indicate that
769 * the string contains non-LDH ASCII characters.
770 * @IDNA_CONTAINS_MINUS: For IDNA_USE_STD3_ASCII_RULES, indicate that
771 * the string contains a leading or trailing hyphen-minus (U+002D).
772 * @IDNA_INVALID_LENGTH: The final output string is not within the
773 * (inclusive) range 1 to 63 characters.
774 * @IDNA_NO_ACE_PREFIX: The string does not contain the ACE prefix
775 * (for ToUnicode).
776 * @IDNA_ROUNDTRIP_VERIFY_ERROR: The ToASCII operation on output
777 * string does not equal the input.
778 * @IDNA_CONTAINS_ACE_PREFIX: The input contains the ACE prefix (for
779 * ToASCII).
780 * @IDNA_ICONV_ERROR: Could not convert string in locale encoding.
781 * @IDNA_MALLOC_ERROR: Could not allocate buffer (this is typically a
782 * fatal error).
783 *
784 * Enumerated return codes of idna_to_ascii_4i(),
785 * idna_to_unicode_44i() functions (and functions derived from those
786 * functions). The value 0 is guaranteed to always correspond to
787 * success.
788 */
789
790
791/**
792 * Idna_flags:
793 * @IDNA_ALLOW_UNASSIGNED: Don't reject strings containing unassigned
794 * Unicode code points.
795 * @IDNA_USE_STD3_ASCII_RULES: Validate strings according to STD3
796 * rules (i.e., normal host name rules).
797 *
798 * Flags to pass to idna_to_ascii_4i(), idna_to_unicode_44i() etc.
799 */

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status