QUERYLOCALE(3)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1

πŸ’… QUERYLOCALE(3) β€” bestie's guide to looking up locale names and versions ✨

okay so real talk, this page lives in the Library Functions Manual, and it's part of the Standard C Library β€” that's libc, link it with -lc, mwah πŸŽ€


🌸 NAME 🌸

querylocale β€” the little function that looks up the locale name or the version for a category you pick πŸ‘‘

πŸ¦‹ SYNOPSIS πŸ¦‹

#include <locale.h>

const char *
querylocale(int mask, locale_t locale);

πŸ’– DESCRIPTION πŸ’–

So here's the vibe: it returns the name or the version of the locale, for whichever category your mask says. 🫢

The possible values for the mask are literally the same ones as in newlocale(3) β€” but like, when you're requesting the locale name, yk? Same energy. πŸ’«

Now for the spicy part: if you want a version string, you OR together LC_VERSION_MASK and another mask value. Bitwise OR, bestie, not vibes. πŸ”₯

What's a version string even for? Comparing them, periodt β€” you compare version strings to detect changes to the locale's definition. πŸ‘€ The structure of the version string is unspecified though, so don't get attached to any particular format, ngl.

And rn? Version info is only available for LC_COLLATE_MASK πŸ“ β€” for every other category you just get an empty string back. That's it, that's the whole story. 😭

⚠️ Heads up: if more than one bit in the mask is set (not counting LC_VERSION_MASK, okay?), the returned value is undefined. Like, undefined undefined. So don't do that. πŸ’€

⭐ SEE ALSO ⭐

duplocale(3), freelocale(3), localeconv(3), newlocale(3), uselocale(3), xlocale(3) β€” go read the whole friend group, iykyk πŸ’œ

🧚 HISTORY 🧚

querylocale() first appeared in FreeBSD 9.1, and it's based on the function of the same name in Darwin. Iconic lineage honestly. Then LC_VERSION_MASK first appeared in FreeBSD 13.0 β€” glow-up era ✨


Debian Β· November 8, 2020 Β· that's the source/version and date, bestie, signed, sealed, slayed πŸ’…πŸŽ€

πŸ“¦ where this page comes from