QUERYLOCALE(3)
π 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
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 2011 The FreeBSD Foundation
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms