💾 Archived View for rawtext.club › ~sloum › geminilist › 006146.gmi captured on 2023-11-04 at 13:30:00. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2021-11-30)
-=-=-=-=-=-=-
Sean Conner sean at conman.org
Thu Mar 18 02:13:18 GMT 2021
- - - - - - - - - - - - - - - - - - -
It was thus said that the Great Scot once stated:
Hi Sean,
Hi Scot!
I think you were wondering whether it's possible to resolve UTF-8
IDNs with a C or Lua program. This Linux C program [7] will do so
via glibc's getaddrinfo(). For platforms without glibc such as the
BSDs, ports of the libidn library [1] are available.
Microsoft provides IdnToAscii() [2] for use with Windows 7 and it
looks as if they support automatic conversion to punycode [3]
in their implemenation of getaddrinfo() as of Windows 8.
Slides 30 through 48 of this presentation [4] describe how Apple
approaches network name internationalization. iOS 10 and
macOS Sierra will try to query a given UTF-8 name via DNS. If
the server doesn't have an entry for the UTF-8 name, it
converts to punycode and tries again.
Android 2.3 has the java.net.IDN package [5] for converting
IDNs and Android 7.0 has android.icu.text.IDNA [6].
Thoughts?
Thank you *so* much for the sample code, and providing much neededbackground information about this. This will make the final decision on IRIsupport a bit easier to make. I was not aware of the GNU-specific AI_IDNflag to getaddrinfo() (and I wish it was standard actually), and yes, itdoes work on systems that have it (Linux).
Just one thing though---you might want to be careful when pasting codeinto email---the code below contained non-breaking spaces that my C compiler(gcc) did not like. It's an easy fix, so this is mostly an FYI gettingweird errors when compiling the code below.
Again, thank you for your message.
-spc
[1] https://www.gnu.org/software/libidn/
[2] https://docs.microsoft.com/en-us/windows/win32/api/winnls/nf-winnls-idntoascii
[3] https://docs.microsoft.com/en-us/windows/win32/api/ws2tcpip/nf-ws2tcpip-getaddrinfo
[4] https://devstreaming-cdn.apple.com/videos/wwdc/2016/714urluxe140lardrb7/714/714_networking_for_the_modern_internet.pdf?dl=1
[5] https://developer.android.com/reference/kotlin/java/net/IDN
[6] https://developer.android.com/reference/android/icu/text/IDNA
[7] Public domain example C program to resolve UTF-8 IDNs
P.S. Here's the code with the non-breaking spaces removed.
void show_ip(char *name) { struct addrinfo filter, *info; char address[ADDR_LEN]; void *addr; memset (&filter, 0, sizeof(filter)); filter.ai_family = PF_UNSPEC; filter.ai_socktype = SOCK_STREAM; filter.ai_flags = AI_IDN; if (getaddrinfo (name, NULL, &filter, &info) == 0) { printf ("\nHost: %s\n", name); while (info) { if (info-
ai_family == AF_INET) { addr = &((struct sockaddr_in *) info-
ai_addr)-
sin_addr; inet_ntop (AF_INET, addr, address, ADDR_LEN); printf ("Â IPv4 address: %s\n", address); } else if (info-
ai_family == AF_INET6) { addr = &((struct sockaddr_in6 *) info-
ai_addr)-
sin6_addr; inet_ntop (AF_INET6, addr, address, ADDR_LEN); printf ("Â IPv6 address: %s\n", address); } info = info-
ai_next; } } else perror ("getaddrinfo"); freeaddrinfo(info);}
int main() { setlocale(LC_ALL, ""); show_ip("蛸.jp"); show_ip("xn--td2a.jp"); show_ip("gémeaux.bortzmeyer.org"); show_ip("xn--gmeaux-bva.bortzmeyer.org"); show_ip("café.mozz.us"); show_ip("xn--caf-dma.mozz.us");}