|
NAMEidn_encodename - encode an internationalized domain nameSYNOPSIS#include <idn/api.h> idn_result_t idn_encodename(idn_action_t actions, const char *from, char *to, size_t tolen); DESCRIPTIONThe function idn_encodename() converts 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 encoding process should be performed. The following list shows action names corresponding with steps of the encoding 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 17 are applied to each label. After the step 17, labels are joined with a separator ``.''. A value of bitwise-OR of some actions can be specified, like:
r = idn_encodename(IDN_UNICODECONV | IDN_MAP, from, to, tolen);
Also the following actions are provided for convenience:
Upon success, idn_encodename() returns idn_success. Otherwise, it returns an error code. See idn_result_tostring(3) for the complete list of error codes. EXAMPLETo get an address of an internationalized domain name written in the application's local encoding, use idn_encodename() to convert the name to the format suitable for passing to resolver functions.idn_result_t r; char ace_name[256]; struct hostent *hp; ... r = idn_encodename(IDN_ENCODE_LOOKUP, name, ace_name, sizeof(ace_name)); if (r != idn_success) { fprintf(stderr, "idn_encodename failed: %s\n", idn_result_tostring(r)); exit(1); } hp = gethostbyname(ace_name); ... SEE ALSOidnconv(1), libidnkit(3), idn_nameinit(3), idn_result_tostring(3), idn2.conf(5)
Visit the GSP FreeBSD Man Page Interface. |