[Previous] [Contents] [Next]

setlocale()

Select a program's locale

Synopsis:

#include <locale.h>

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

Library:

libc

Description:

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


Note: The following built-in locales are offered:
  • C (default)
  • C-TRADITIONAL
  • POSIX

A locale affects several things:

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

Valid values for the category are:

LC_ALL
Select the entire locale environment.
LC_COLLATE
Select only the collating sequence.
LC_CTYPE
Select only the character-handling information.
LC_MESSAGES
Specify the language to be used for messages.
LC_MONETARY
Select only monetary formatting information.
LC_NUMERIC
Select only the numeric-format environment.
LC_TIME
Select only the time-related environment.

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:

A pointer to a system-generated string indicating the previous locale, or NULL if an error occurs.

Classification:

ANSI

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,


[Previous] [Contents] [Next]