|
NAMEidn_decodename, idn_decodename2 - decode an internationalized domain nameSYNOPSIS#include <idn/api.h> idn_result_t idn_decodename(idn_action_t actions, const char *from, char *to, size_t tolen); idn_result_t idn_decodename2(idn_action_t actions, const char *from, char *to, size_t tolen, const char *auxencoding); DESCRIPTIONThe function idn_decodename() decodes a domain name from and writes the result on to, at most tolen bytes. Note that from must be terminated by NUL, and tolen includes room for a NUL character.The argument actions specifies which steps in the entire decoding process should be performed. The following list shows action names corresponding with steps of the decoding process. The function performs the steps in that order.
Between the step 2 and 3, the domain name is split into labels. The step 3 through 15 are applied to each label. After the step 15, labels are joined with a separator ``.''. A value of bitwise-OR of some actions can be specified, like:
r = idn_decodename(IDN_IDNCONV | IDN_LOCALCONV, from, to, tolen);
The function idn_decodename2() works same as idn_decodename(), but an encoding conversion from auxencoding to UTF-8 is performed prior to the actual decoding process. Instead, idn_decodename2() ignores IDN_UNICODECONV action. If auxencoding is NULL, from is treated as UTF-8. Also the following actions are provided for convenience:
Upon success, the functions returns idn_success. Otherwise, it returns an error code. See idn_result_tostring(3) for the complete list of error codes. EXAMPLETo decode an internationalized domain name returned from a resolver function, use idn_decodename().idn_result_t r; char ace_name[256]; struct hostent *hp; ... hp = gethostbyname(name); r = idn_decodename(IDN_DECODE_LOOKUP, hp->h_name, local_name, sizeof(local_name)); if (r != idn_success) { fprintf(stderr, "idn_decodename failed: %s\n", idn_result_tostring(r)); exit(1); } printf("name: %s\n", local_name); ... SEE ALSOidnconv(1), libidnkit(3), idn_nameinit(3), idn_result_tostring(3), idn2.conf(5)
Visit the GSP FreeBSD Man Page Interface. |