xref: /illumos-gate/usr/src/man/man3c/uselocale.3c (revision ddb365bfc9e868ad24ccdcb0dc91af18b10df082)
te

This file and its contents are supplied under the terms of the
Common Development and Distribution License ("CDDL"), version 1.0.
You may only use this file in accordance with the terms of version
1.0 of the CDDL.

A full copy of the text of the CDDL should have accompanied this
source. A copy of the CDDL is also available via the Internet at
http://www.illumos.org/license/CDDL.


Copyright (c) 2014 Joyent, Inc. All rights reserved.
Copyright 2014 Garrett D'Amore <garrett@damore.org>

USELOCALE 3C "Jun 24, 2014"
NAME
uselocale - get and set the locale for an individual thread
SYNOPSIS

#include <locale.h>

locale_t uselocale(locale_t loc);
DESCRIPTION

The uselocale() function is used to obtain and set the current locale for a thread. When a thread is created, it uses the global locale as specified by calls to setlocale() .

If (locale_t) 0 is supplied for loc , then no change is made to the thread's locale setting. This can be used to query the thread's locale without making any change.

If LC_GLOBAL_LOCALE is supplied for loc , then the thread will use the global locale, undoing the effect of any prior call to establish a thread-specific locale.

Otherwise the thread will use the supplied loc locale object as a thread-specific locale. Changes to the global locale, or to the locale of any other thread, will not affect this thread.

Locale objects for use with uselocale() can be created with the functions duplocale (3C) and newlocale (3C).

RETURN VALUES
Upon successful completion, the uselocale() function always returns the previous locale that was set. If no locale was previously set, the global locale, LC_GLOBAL_LOCALE , is returned. On failure, the uselocale() function returns (locale_t) 0, and sets errno to indicate the error.
ERRORS

EINVAL An invalid locale was encountered or an internal error occurred that caused the system to be unable to update the locale.

ATTRIBUTES
ATTRIBUTE TYPE ATTRIBUTE VALUE
Interface Stability Standard
MT-Level MT-Safe
SEE ALSO
locale (1), duplocale (3C), newlocale (3C), setlocale (3C), locale (7)