USELOCALE(3POSIX)
π USELOCALE(3POSIX) β the POSIX Programmer's Manual one
okay bestie, quick vibe check before we start: this is uselocale(3POSIX) from the POSIX Programmer's Manual. Say it with me. π
β¨ PROLOG β¨
so like, this manual page is part of the POSIX Programmer's Manual. that's the whole tea. but heads up, fr fr: the Linux implementation of this interface may differ β so go consult the corresponding Linux manual page for the deets on Linux behavior β or honestly the interface might not even be implemented on Linux at all. π tragic but true.
πΈ NAME πΈ
uselocale β use locale in current thread π§΅β¨
π¦ SYNOPSIS π¦
#include <locale.h>
locale_t uselocale(locale_t newloc);
π DESCRIPTION π
so the uselocale() function shall set or query the current locale for the calling thread. that's the whole job. main character energy honestly. π
the value for the newloc argument shall be one of the following:
- A value returned by the
newlocale()orduplocale()functions - The special locale object descriptor
LC_GLOBAL_LOCALE (locale_t)0
now let's break down what each one actually does, because this is the part that matters:
- If the
newlocargument is(locale_t)0, the current locale shall not be changed. this value can be used to query the current locale setting. it's giving "just looking, not touching" π - If the
newlocargument isLC_GLOBAL_LOCALE, any thread-local locale for the calling thread shall be uninstalled. the thread shall again use the global locale as the current locale, and changes to the global locale shall affect the thread. back to the group chat, babes. - Otherwise, the locale represented by
newlocshall be installed as a thread-local locale, to be used as the current locale for the calling thread. β¨
and here's the iconic part: once the uselocale() function has been called to install a thread-local locale, the behavior of every interface using data from the current locale shall be affected for the calling thread. every single one. no cap. but the current locale for other threads shall remain unchanged β your thread's business is your thread's business, periodt. π«Ά
π RETURN VALUE π
upon successful completion, the uselocale() function shall return a handle for the thread-local locale that was in use as the current locale for the calling thread on entry to the function, or LC_GLOBAL_LOCALE if no thread-local locale was in use. like, it tells you what you were on, not what you are on now. very "here's a photo of you before the glow-up" πΈ
otherwise, uselocale() shall return (locale_t)0 and set errno to indicate the error. π
π₯ ERRORS π₯
the uselocale() function may fail if:
EINVALβnewlocis not a valid locale object and is not(locale_t)0.
bestie. read that again. if it's not a real locale object AND it's not(locale_t)0, that's anEINVALand you did that. π
the following sections are informative.
π EXAMPLES π
None. (yes, actually none. the void. the emptiness. iconic of them honestly. π³οΈ)
π APPLICATION USAGE π
unlike the setlocale() function, the uselocale() function does not allow replacing some locale categories only. so if your app needs to install a locale which differs only in a few categories, you must use newlocale() to change a locale object equivalent to the currently used locale and then install it. it's giving "you can't just swap one category, you gotta build the whole fit" π
π§ RATIONALE π§
None. (again. nothing. we respect the silence. β¨)
β FUTURE DIRECTIONS β
None.
π SEE ALSO π
duplocale()freelocale()newlocale()setlocale()
and from the Base Definitions volume of POSIX.1β2017: <locale.h> π«Ά
πΈ COPYRIGHT πΈ
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
and that's the whole page bestie!! brought to you by IEEE/The Open Group, 2017 β yeah, 2017, they were doing thread-local locales before it was cool. mwah. π β¨
π¦ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 Β· Other
- debian trixie: manpages-posix-dev 2017a-2 Β· Other
- ubuntu jammy: manpages-posix-dev 2017a-2 Β· Other
- ubuntu noble: manpages-posix-dev 2017a-2 Β· Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 Β· Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 Β· Other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms