USELOCALE(3)

NAME
uselocale - Sets a thread-local locale

SYNOPSIS
#include <xlocale.h>
locale_t
uselocale(locale_t locale);

DESCRIPTION
Specifies the locale for this thread to use. Specifying LC_GLOBAL_LOCALE disables the per-thread locale, while NULL returns the current locale without setting a new one.

RETURN VALUES
Returns the previous locale, or LC_GLOBAL_LOCALE if this thread has no locale associated with it.

SEE ALSO
duplocale(3), freelocale(3), localeconv(3), newlocale(3), querylocale(3), xlocale(3)

STANDARDS
USELOCALE(3)

This function conforms to p1003.1-2008

NAME
uselocale - select the locale for the current thread

SYNOPSIS
#include <locale.h>
locale_t
uselocale(locale_t newloc);

DESCRIPTION
The function uselocale() selects newloc for use by functions in the current thread that do not take a locale_t argument. Neither the global locale set by setlocale(3) nor locales used by other threads change.

The current thread uses newloc until uselocale() is called again successfully with a non-null argument in the same thread, and passing newloc to freelocale(3) or newlocale(3) before that results in undefined behaviour.

To revoke the use of newloc in the current thread without installing another thread-specific locale, instead reverting to the global locale, call uselocale() with the special argument LC_GLOBAL_LOCALE.

When called with the argument (locale_t)0, the thread-specific locale remains unchanged.

RETURN VALUES
The function uselocale() returns the thread-specific locale which is in use right before the call, or the special return value LC_GLOBAL_LOCALE if the thread used the global locale before the call.

ERRORS
The function uselocale() fails if:

[EINVAL]
    The newloc argument is neither a valid locale object nor (locale_t)0.

SEE ALSO
iswalnum(3), iswctype(3), newlocale(3), towctrans(3), towlower(3), wcscasecmp(3), wctrans(3), wctype(3)

STANDARDS
The function uselocale() conforms to p1003.1-2008.

HISTORY
The function uselocale() has been available since OpenBSD 6.2.