Caution: This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs.

setlocale()

Select a program's locale

Synopsis:

#include <locale.h>

char * setlocale( int category, 
                  const char * locale );

Arguments:

category
The part of the environment that you want to set; one of:
locale
The locale that you want to use. The following built-in locales are offered:

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The setlocale() function selects a program's locale, according to the specified category and the specified locale.

A locale affects several things:

See the localeconv() function for more information about the locale.

At the start of a program, the default C locale is initialized as if the following call to setlocale() appeared at the start of main():

(void)setlocale( LC_ALL, "C" );

Returns:

The string associated with the specified category for the new locale, or NULL if an error occurs. This function doesn't change the program's locale when error occurs.


Note: For a NULL pointer of locale, this function returns a pointer to the string associated with the category for the program's current locale. This function doesn't change the program's locale.

Classification:

ANSI, POSIX 1003.1

Safety:
Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes

See also:

isalpha(), isascii(), localeconv(), printf(), scanf(), strcat(), strchr(), strcmp(), strcoll(), strcpy(), strftime(), strlen(), strpbrk(), strspn(), strtod(), strtok(), strxfrm(), tm