idn_encodename(3)
π NAME π
okay so bestie, meet idn_encodename(3) from the Library Functions Manual β she encodes an internationalized domain name, no cap. π
idn_encodename β encode an internationalized domain name. β¨
β¨ SYNOPSIS β¨
#include <idn/api.h>
idn_result_t
idn_encodename(idn_action_t actions, const char *from, char *to,
size_t tolen);
π¦ DESCRIPTION π¦
The function idn_encodename() takes a domain name from from and writes the result into to, using at most tolen bytes. Lowkey important: from must be terminated by NUL, and tolen includes room for a NUL character. π«Ά
The actions argument says which steps of the whole encoding process should be performed. Hereβs the action-name-to-step lineup, and yes, she performs these steps in exactly this order, periodt:
- Step 1:
IDN_UNICODECONVβ Convert a domain name from local encoding (e.g.ISO-8859-1) toUTF-8. - Step 2:
IDN_MAPβ Perform mappings (NFC, Lowercase conversion, etc.). - Step 3:
IDN_ASCLOWERβ Convert ASCII uppercase letters (A..Z) to lowercase (a..z). - Step 4:
IDN_RTCONVβ Convert A-labels to U-labels. - Step 5:
IDN_PROHCHECKβ Check prohibited code points. - Step 6:
IDN_UNASCHECKβ Check unassigned code points. - Step 7:
IDN_NFCCHECKβ Check labels are inNFC. - Step 8:
IDN_PREFCHECKβ Check labels containing--in the 3rd and 4th characters. - Step 9:
IDN_HYPHCHECKβ Check labels beginning/ending with-. - Step 10:
IDN_COMBCHECKβ Check labels beginning with a combining mark. - Step 11:
IDN_CTXJCHECKβ Check CONTEXTJ code points. - Step 12a:
IDN_CTXOCHECKβ Check CONTEXTO code points for the registration protocol. - Step 12b:
IDN_CTXOLITECHECKβ Check CONTEXTO code points for the lookup protocol. - Step 13:
IDN_BIDICHECKβ Check requirements specified in[IDNA2008-BIDI]. - Step 14:
IDN_LOCALCHECKβ Perform local check (optional). - Step 15:
IDN_IDNCONVβ Convert labels inUTF-8to Punycode. - Step 16:
IDN_LENCHECKβ Check length of each label. - Step 17:
IDN_RTCHECKβ Perform round trip check for each label.
Between step 2 and step 3, the domain name is split into labels. Steps 3 through 17 are applied to each label. After step 17, labels are joined with a separator "." β yes, a literal dot, slay. π
A value of bitwise-OR of some actions can be specified, like:
r = idn_encodename(IDN_UNICODECONV | IDN_MAP, from, to, tolen);
Also, these convenience actions are provided:
IDN_ENCODE_REGISTβ Encode a domain name with IDNA2008 registration protocol.libidnkitperforms the step 1..11, 12a, 13 and 15..17.libidnkitliteperforms the step 2..11, 12a, 13 and 15..17.IDN_ENCODE_LOOKUPβ Encode a domain name with IDNA2008 lookup protocol.libidnkitperforms the step 1..8, 10, 11, 12b, 13 and 15..17.libidnkitliteperforms the step 2..8, 10, 11, 12b, 13 and 15..17.
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. π
πΈ EXAMPLE πΈ
To 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. Like, literally:
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 ALSO π
xoxo from idn_encodename(3), source Library Functions Manual, dated Sep 21, 2012 β mwah ππ
π¦ where this page comes from
- nixos 26.05: idnkit 2.3
- nixpkgs unstable: idnkit 2.3
- Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved
- Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
- Copyright (c) 2010-2012 Japan Registry Services Co., Ltd. All rights reserved."
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms