tld_check_lz(3)

πŸ’– tld_check_lz β€” the libidn manual, but make it make sense πŸ’–

okay bestie, so this is tld_check_lz(3) from libidn, and before u ask: yes it's a C function, no it's not scary, and yes i'm gonna hold ur hand through it. it's giving "vibe check but for domain name characters" fr fr πŸ¦‹


✨ NAME ✨

tld_check_lz β€” an API function. that's it, that's the name. she's short, she's sweet, she checks ur characters against TLD rules. periodt πŸ’…


✨ SYNOPSIS ✨

#include <tld.h>

int tld_check_lz(const char * in, size_t * errpos, const Tld_table **
overrides);

like yes the signature wraps weirdly, that's just how the manpage do. copy it exactly, don't get creative 😭


✨ ARGUMENTS ✨

  • const char * in β€” a zero-terminated string in the encoding of ur current locale, aka the thing u want processed. she's the main character of this whole operation πŸ‘‘
  • size_t * errpos β€” this is where the position of the offending character gets dropped off for u. like a lil gift basket but it's just "here's where it went wrong" πŸ’€
  • const Tld_table ** overrides β€” a Tld_table array of extra domain restriction structs that complement and supersede the built-in info. so like, built-in is the base fit and overrides is the accessories that can straight up replace it πŸŽ€

✨ DESCRIPTION ✨

so what does she actually DO. she tests every single character in in and asks: are u allowed by the info in overrides, or by the built-in TLD restriction data? 🌈

the rules of engagement, no cap:

  • when data for the same TLD exists both internally and in overrides, the info in overrides takes precedence. built-in stays in its lane 🫢
  • if several entries for a specific TLD show up, the first one is used. first come first served, no drama ✨
  • if overrides is NULL, then it's just the built-in information, nothing else. simple life πŸ’œ
  • the position of the first offending character gets returned in errpos.
⚠️ lowkey important: the error position refers to the decoded character offset, NOT the byte position in the string. so don't go counting bytes, bestie, u will be humbled 😭

Return value: returns the Tld_rc value TLD_SUCCESS if all characters are valid, or when tld is null. returns TLD_INVALID if a character is not allowed. and if things go generally wrong? additional error codes, as a treat πŸ’…


✨ REPORTING BUGS ✨

found a bug? not me manifesting that but ok, tell the devs:

they're nice, they'll help, go forth πŸ¦‹


Copyright Β© 2002-2026 Simon Josefsson. πŸŽ€

Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved.

(translation: take it, share it, remix it, just keep the receipts bestie 🫢)


✨ SEE ALSO ✨

the full documentation for libidn lives in a Texinfo manual. if the info and libidn programs are properly installed at ur site, this command:

info libidn

should give u access to the complete manual. obsessed. πŸ“–

as an alternative u may obtain the manual from:

https://www.gnu.org/software/libidn/manual/

okay that's the whole thing, u ate this, i'm so proud 🌸 and if u ever need the receipts: this is libidn version 1.44, page tld_check_lz(3). go slay ur character validation, mwah πŸ’–βœ¨πŸ‘‘

πŸ“¦ where this page comes from