libidn  1.28
Macros | Enumerations | Functions
idna.h File Reference
#include <stddef.h>
#include <idn-int.h>

Go to the source code of this file.

Macros

#define IDNAPI
#define IDNA_ACE_PREFIX   "xn--"

Enumerations

enum  Idna_rc {
  IDNA_SUCCESS = 0, IDNA_STRINGPREP_ERROR = 1, IDNA_PUNYCODE_ERROR = 2, IDNA_CONTAINS_NON_LDH = 3,
  IDNA_CONTAINS_LDH = IDNA_CONTAINS_NON_LDH, IDNA_CONTAINS_MINUS = 4, IDNA_INVALID_LENGTH = 5, IDNA_NO_ACE_PREFIX = 6,
  IDNA_ROUNDTRIP_VERIFY_ERROR = 7, IDNA_CONTAINS_ACE_PREFIX = 8, IDNA_ICONV_ERROR = 9, IDNA_MALLOC_ERROR = 201,
  IDNA_DLOPEN_ERROR = 202
}
enum  Idna_flags { IDNA_ALLOW_UNASSIGNED = 0x0001, IDNA_USE_STD3_ASCII_RULES = 0x0002 }

Functions

IDNAPI const char * idna_strerror (Idna_rc rc)
IDNAPI int idna_to_ascii_4i (const uint32_t *in, size_t inlen, char *out, int flags)
IDNAPI int idna_to_unicode_44i (const uint32_t *in, size_t inlen, uint32_t *out, size_t *outlen, int flags)
IDNAPI int idna_to_ascii_4z (const uint32_t *input, char **output, int flags)
IDNAPI int idna_to_ascii_8z (const char *input, char **output, int flags)
IDNAPI int idna_to_ascii_lz (const char *input, char **output, int flags)
IDNAPI int idna_to_unicode_4z4z (const uint32_t *input, uint32_t **output, int flags)
IDNAPI int idna_to_unicode_8z4z (const char *input, uint32_t **output, int flags)
IDNAPI int idna_to_unicode_8z8z (const char *input, char **output, int flags)
IDNAPI int idna_to_unicode_8zlz (const char *input, char **output, int flags)
IDNAPI int idna_to_unicode_lzlz (const char *input, char **output, int flags)

Macro Definition Documentation

#define IDNA_ACE_PREFIX   "xn--"

Definition at line 81 of file idna.h.

#define IDNAPI

Definition at line 41 of file idna.h.

Enumeration Type Documentation

enum Idna_flags
Enumerator:
IDNA_ALLOW_UNASSIGNED 
IDNA_USE_STD3_ASCII_RULES 

Definition at line 74 of file idna.h.

enum Idna_rc
Enumerator:
IDNA_SUCCESS 
IDNA_STRINGPREP_ERROR 
IDNA_PUNYCODE_ERROR 
IDNA_CONTAINS_NON_LDH 
IDNA_CONTAINS_LDH 
IDNA_CONTAINS_MINUS 
IDNA_INVALID_LENGTH 
IDNA_NO_ACE_PREFIX 
IDNA_ROUNDTRIP_VERIFY_ERROR 
IDNA_CONTAINS_ACE_PREFIX 
IDNA_ICONV_ERROR 
IDNA_MALLOC_ERROR 
IDNA_DLOPEN_ERROR 

Definition at line 54 of file idna.h.

Function Documentation

IDNAPI const char* idna_strerror ( Idna_rc  rc)

idna_strerror:

Parameters
rcan Idna_rc return code.

Convert a return code integer to a text string. This string can be used to output a diagnostic message to the user.

IDNA_SUCCESS: Successful operation. This value is guaranteed to always be zero, the remaining ones are only guaranteed to hold non-zero values, for logical comparison purposes. IDNA_STRINGPREP_ERROR: Error during string preparation. IDNA_PUNYCODE_ERROR: Error during punycode operation. IDNA_CONTAINS_NON_LDH: For IDNA_USE_STD3_ASCII_RULES, indicate that the string contains non-LDH ASCII characters. IDNA_CONTAINS_MINUS: For IDNA_USE_STD3_ASCII_RULES, indicate that the string contains a leading or trailing hyphen-minus (U+002D). IDNA_INVALID_LENGTH: The final output string is not within the (inclusive) range 1 to 63 characters. IDNA_NO_ACE_PREFIX: The string does not contain the ACE prefix (for ToUnicode). IDNA_ROUNDTRIP_VERIFY_ERROR: The ToASCII operation on output string does not equal the input. IDNA_CONTAINS_ACE_PREFIX: The input contains the ACE prefix (for ToASCII). IDNA_ICONV_ERROR: Could not convert string in locale encoding. IDNA_MALLOC_ERROR: Could not allocate buffer (this is typically a fatal error). IDNA_DLOPEN_ERROR: Could not dlopen the libcidn DSO (only used internally in libc).

Return value: Returns a pointer to a statically allocated string containing a description of the error with the return code .

Definition at line 73 of file strerror-idna.c.

IDNAPI int idna_to_ascii_4i ( const uint32_t *  in,
size_t  inlen,
char *  out,
int  flags 
)

idna_to_ascii_4i:

Parameters
ininput array with unicode code points.
inlenlength of input array with unicode code points.
outoutput zero terminated string that must have room for at least 63 characters plus the terminating zero.
flagsan Idna_flags value, e.g., IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES.

The ToASCII operation takes a sequence of Unicode code points that make up one domain label and transforms it into a sequence of code points in the ASCII range (0..7F). If ToASCII succeeds, the original sequence and the resulting sequence are equivalent labels.

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 81 of file idna.c.

IDNAPI int idna_to_ascii_4z ( const uint32_t *  input,
char **  output,
int  flags 
)

idna_to_ascii_4z:

Parameters
inputzero terminated input Unicode string.
outputpointer to newly allocated output string.
flagsan Idna_flags value, e.g., IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES.

Convert UCS-4 domain name to ASCII string. The domain name may contain several labels, separated by dots. The output buffer must be deallocated by the caller.

Return value: Returns IDNA_SUCCESS on success, or error code.

Definition at line 471 of file idna.c.

IDNAPI int idna_to_ascii_8z ( const char *  input,
char **  output,
int  flags 
)

idna_to_ascii_8z:

Parameters
inputzero terminated input UTF-8 string.
outputpointer to newly allocated output string.
flagsan Idna_flags value, e.g., IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES.

Convert UTF-8 domain name to ASCII string. The domain name may contain several labels, separated by dots. The output buffer must be deallocated by the caller.

Return value: Returns IDNA_SUCCESS on success, or error code.

Definition at line 572 of file idna.c.

IDNAPI int idna_to_ascii_lz ( const char *  input,
char **  output,
int  flags 
)

idna_to_ascii_lz:

Parameters
inputzero terminated input string encoded in the current locale's character set.
outputpointer to newly allocated output string.
flagsan Idna_flags value, e.g., IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES.

Convert domain name in the locale's encoding to ASCII string. The domain name may contain several labels, separated by dots. The output buffer must be deallocated by the caller.

Return value: Returns IDNA_SUCCESS on success, or error code.

Definition at line 605 of file idna.c.

IDNAPI int idna_to_unicode_44i ( const uint32_t *  in,
size_t  inlen,
uint32_t *  out,
size_t *  outlen,
int  flags 
)

idna_to_unicode_44i:

Parameters
ininput array with unicode code points.
inlenlength of input array with unicode code points.
outoutput array with unicode code points.
outlenon input, maximum size of output array with unicode code points, on exit, actual size of output array with unicode code points.
flagsan Idna_flags value, e.g., IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES.

The ToUnicode operation takes a sequence of Unicode code points that make up one domain label and returns a sequence of Unicode code points. If the input sequence is a label in ACE form, then the result is an equivalent internationalized label that is not in ACE form, otherwise the original sequence is returned unaltered.

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 431 of file idna.c.

IDNAPI int idna_to_unicode_4z4z ( const uint32_t *  input,
uint32_t **  output,
int  flags 
)

idna_to_unicode_4z4z:

Parameters
inputzero-terminated Unicode string.
outputpointer to newly allocated output Unicode string.
flagsan Idna_flags value, e.g., IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES.

Convert possibly ACE encoded domain name in UCS-4 format into a UCS-4 string. The domain name may contain several labels, separated by dots. The output buffer must be deallocated by the caller.

Return value: Returns IDNA_SUCCESS on success, or error code.

Definition at line 636 of file idna.c.

IDNAPI int idna_to_unicode_8z4z ( const char *  input,
uint32_t **  output,
int  flags 
)

idna_to_unicode_8z4z:

Parameters
inputzero-terminated UTF-8 string.
outputpointer to newly allocated output Unicode string.
flagsan Idna_flags value, e.g., IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES.

Convert possibly ACE encoded domain name in UTF-8 format into a UCS-4 string. The domain name may contain several labels, separated by dots. The output buffer must be deallocated by the caller.

Return value: Returns IDNA_SUCCESS on success, or error code.

Definition at line 712 of file idna.c.

IDNAPI int idna_to_unicode_8z8z ( const char *  input,
char **  output,
int  flags 
)

idna_to_unicode_8z8z:

Parameters
inputzero-terminated UTF-8 string.
outputpointer to newly allocated output UTF-8 string.
flagsan Idna_flags value, e.g., IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES.

Convert possibly ACE encoded domain name in UTF-8 format into a UTF-8 string. The domain name may contain several labels, separated by dots. The output buffer must be deallocated by the caller.

Return value: Returns IDNA_SUCCESS on success, or error code.

Definition at line 743 of file idna.c.

IDNAPI int idna_to_unicode_8zlz ( const char *  input,
char **  output,
int  flags 
)

idna_to_unicode_8zlz:

Parameters
inputzero-terminated UTF-8 string.
outputpointer to newly allocated output string encoded in the current locale's character set.
flagsan Idna_flags value, e.g., IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES.

Convert possibly ACE encoded domain name in UTF-8 format into a string encoded in the current locale's character set. The domain name may contain several labels, separated by dots. The output buffer must be deallocated by the caller.

Return value: Returns IDNA_SUCCESS on success, or error code.

Definition at line 774 of file idna.c.

IDNAPI int idna_to_unicode_lzlz ( const char *  input,
char **  output,
int  flags 
)

idna_to_unicode_lzlz:

Parameters
inputzero-terminated string encoded in the current locale's character set.
outputpointer to newly allocated output string encoded in the current locale's character set.
flagsan Idna_flags value, e.g., IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES.

Convert possibly ACE encoded domain name in the locale's character set into a string encoded in the current locale's character set. The domain name may contain several labels, separated by dots. The output buffer must be deallocated by the caller.

Return value: Returns IDNA_SUCCESS on success, or error code.

Definition at line 806 of file idna.c.