#include <stdlib.h>
#include <string.h>
#include <stringprep.h>
#include <punycode.h>
#include "idna.h"
Go to the source code of this file.
Defines | |
#define | DOTP(c) |
Functions | |
int | idna_to_ascii_4i (const uint32_t *in, size_t inlen, char *out, 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_ascii_4z (const uint32_t *input, char **output, int flags) |
int | idna_to_ascii_8z (const char *input, char **output, int flags) |
int | idna_to_ascii_lz (const char *input, char **output, int flags) |
int | idna_to_unicode_4z4z (const uint32_t *input, uint32_t **output, int flags) |
int | idna_to_unicode_8z4z (const char *input, uint32_t **output, int flags) |
int | idna_to_unicode_8z8z (const char *input, char **output, int flags) |
int | idna_to_unicode_8zlz (const char *input, char **output, int flags) |
int | idna_to_unicode_lzlz (const char *input, char **output, int flags) |
#define DOTP | ( | c | ) |
Value:
((c) == 0x002E || (c) == 0x3002 || \ (c) == 0xFF0E || (c) == 0xFF61)
Definition at line 33 of file idna.c.
Referenced by idna_to_ascii_4z(), idna_to_unicode_4z4z(), and tld_get_4().
int idna_to_ascii_4i | ( | const uint32_t * | in, | |
size_t | inlen, | |||
char * | out, | |||
int | flags | |||
) |
idna_to_ascii_4i - convert Unicode domain name label to text
in | input array with unicode code points. | |
inlen | length of input array with unicode code points. | |
out | output zero terminated string that must have room for at least 63 characters plus the terminating zero. | |
flags | an Idna_flags value, e.g., IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES. |
It is important to note that the ToASCII operation can fail. ToASCII fails if any step of it fails. If any step of the ToASCII operation fails on any label in a domain name, that domain name MUST NOT be used as an internationalized domain name. The method for deadling with this failure is application-specific.
The inputs to ToASCII are a sequence of code points, the AllowUnassigned flag, and the UseSTD3ASCIIRules flag. The output of ToASCII is either a sequence of ASCII code points or a failure condition.
ToASCII never alters a sequence of code points that are all in the ASCII range to begin with (although it could fail). Applying the ToASCII operation multiple times has exactly the same effect as applying it just once.
Return value: Returns 0 on success, or an Idna_rc error code.
Definition at line 70 of file idna.c.
References IDNA_ACE_PREFIX, IDNA_ALLOW_UNASSIGNED, IDNA_CONTAINS_ACE_PREFIX, IDNA_CONTAINS_MINUS, IDNA_CONTAINS_NON_LDH, IDNA_INVALID_LENGTH, IDNA_MALLOC_ERROR, IDNA_PUNYCODE_ERROR, IDNA_STRINGPREP_ERROR, IDNA_SUCCESS, IDNA_USE_STD3_ASCII_RULES, punycode_encode(), PUNYCODE_SUCCESS, stringprep_nameprep, stringprep_nameprep_no_unassigned, STRINGPREP_OK, STRINGPREP_TOO_SMALL_BUFFER, stringprep_ucs4_to_utf8(), stringprep_utf8_to_ucs4(), and uint32_t.
Referenced by idna_to_ascii_4z().
int idna_to_ascii_4z | ( | const uint32_t * | input, | |
char ** | output, | |||
int | flags | |||
) |
idna_to_ascii_4z - convert Unicode domain name label to text
input | zero terminated input Unicode string. | |
output | pointer to newly allocated output string. | |
flags | an Idna_flags value, e.g., IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES. |
Return value: Returns IDNA_SUCCESS on success, or error code.
Definition at line 455 of file idna.c.
References DOTP, IDNA_MALLOC_ERROR, IDNA_SUCCESS, idna_to_ascii_4i(), and uint32_t.
Referenced by idna_to_ascii_8z().
int idna_to_ascii_8z | ( | const char * | input, | |
char ** | output, | |||
int | flags | |||
) |
idna_to_ascii_8z - convert Unicode domain name label to text
input | zero terminated input UTF-8 string. | |
output | pointer to newly allocated output string. | |
flags | an Idna_flags value, e.g., IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES. |
Return value: Returns IDNA_SUCCESS on success, or error code.
Definition at line 551 of file idna.c.
References IDNA_ICONV_ERROR, idna_to_ascii_4z(), stringprep_utf8_to_ucs4(), and uint32_t.
Referenced by idna_to_ascii_lz().
int idna_to_ascii_lz | ( | const char * | input, | |
char ** | output, | |||
int | flags | |||
) |
idna_to_ascii_lz - convert Unicode domain name label to text
input | zero terminated input string encoded in the current locale's character set. | |
output | pointer to newly allocated output string. | |
flags | an Idna_flags value, e.g., IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES. |
Return value: Returns IDNA_SUCCESS on success, or error code.
Definition at line 584 of file idna.c.
References IDNA_ICONV_ERROR, idna_to_ascii_8z(), and stringprep_locale_to_utf8().
int idna_to_unicode_44i | ( | const uint32_t * | in, | |
size_t | inlen, | |||
uint32_t * | out, | |||
size_t * | outlen, | |||
int | flags | |||
) |
idna_to_unicode_44i - convert domain name label to Unicode
in | input array with unicode code points. | |
inlen | length of input array with unicode code points. | |
out | output array with unicode code points. | |
outlen | on input, maximum size of output array with unicode code points, on exit, actual size of output array with unicode code points. | |
flags | an Idna_flags value, e.g., IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES. |
ToUnicode never fails. If any step fails, then the original input sequence is returned immediately in that step.
The Punycode decoder can never output more code points than it inputs, but Nameprep can, and therefore ToUnicode can. Note that the number of octets needed to represent a sequence of code points depends on the particular character encoding used.
The inputs to ToUnicode are a sequence of code points, the AllowUnassigned flag, and the UseSTD3ASCIIRules flag. The output of ToUnicode is always a sequence of Unicode code points.
Return value: Returns Idna_rc error condition, but it must only be used for debugging purposes. The output buffer is always guaranteed to contain the correct data according to the specification (sans malloc induced errors). NB! This means that you normally ignore the return code from this function, as checking it means breaking the standard.
Definition at line 415 of file idna.c.
References IDNA_MALLOC_ERROR, IDNA_SUCCESS, and stringprep_ucs4_to_utf8().
Referenced by idna_to_unicode_4z4z().
int idna_to_unicode_4z4z | ( | const uint32_t * | input, | |
uint32_t ** | output, | |||
int | flags | |||
) |
idna_to_unicode_4z4z - convert domain name label to Unicode
input | zero-terminated Unicode string. | |
output | pointer to newly allocated output Unicode string. | |
flags | an Idna_flags value, e.g., IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES. |
Return value: Returns IDNA_SUCCESS on success, or error code.
Definition at line 615 of file idna.c.
References DOTP, IDNA_MALLOC_ERROR, IDNA_SUCCESS, idna_to_unicode_44i(), and uint32_t.
Referenced by idna_to_unicode_8z4z().
int idna_to_unicode_8z4z | ( | const char * | input, | |
uint32_t ** | output, | |||
int | flags | |||
) |
idna_to_unicode_8z4z - convert domain name label to Unicode
input | zero-terminated UTF-8 string. | |
output | pointer to newly allocated output Unicode string. | |
flags | an Idna_flags value, e.g., IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES. |
Return value: Returns IDNA_SUCCESS on success, or error code.
Definition at line 691 of file idna.c.
References IDNA_ICONV_ERROR, idna_to_unicode_4z4z(), stringprep_utf8_to_ucs4(), and uint32_t.
Referenced by idna_to_unicode_8z8z().
int idna_to_unicode_8z8z | ( | const char * | input, | |
char ** | output, | |||
int | flags | |||
) |
idna_to_unicode_8z8z - convert domain name label to Unicode
input | zero-terminated UTF-8 string. | |
output | pointer to newly allocated output UTF-8 string. | |
flags | an Idna_flags value, e.g., IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES. |
Return value: Returns IDNA_SUCCESS on success, or error code.
Definition at line 722 of file idna.c.
References IDNA_ICONV_ERROR, idna_to_unicode_8z4z(), stringprep_ucs4_to_utf8(), and uint32_t.
Referenced by idna_to_unicode_8zlz().
int idna_to_unicode_8zlz | ( | const char * | input, | |
char ** | output, | |||
int | flags | |||
) |
idna_to_unicode_8zlz - convert domain name label to Unicode
input | zero-terminated UTF-8 string. | |
output | pointer to newly allocated output string encoded in the current locale's character set. | |
flags | an Idna_flags value, e.g., IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES. |
Return value: Returns IDNA_SUCCESS on success, or error code.
Definition at line 753 of file idna.c.
References IDNA_ICONV_ERROR, idna_to_unicode_8z8z(), and stringprep_utf8_to_locale().
Referenced by idna_to_unicode_lzlz().
int idna_to_unicode_lzlz | ( | const char * | input, | |
char ** | output, | |||
int | flags | |||
) |
idna_to_unicode_lzlz - convert domain name label to Unicode
input | zero-terminated string encoded in the current locale's character set. | |
output | pointer to newly allocated output string encoded in the current locale's character set. | |
flags | an Idna_flags value, e.g., IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES. |
Return value: Returns IDNA_SUCCESS on success, or error code.
Definition at line 785 of file idna.c.
References IDNA_ICONV_ERROR, idna_to_unicode_8zlz(), and stringprep_locale_to_utf8().