2.6.2 setlocale


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

Sets or reads location dependent information.

category can be one of the following:

LC_ALLSet everything.
LC_COLLATEAffects strcoll and strxfrm functions.
LC_CTYPEAffects all character functions.
LC_MONETARYAffects the monetary information provided by localeconv function.
LC_NUMERICAffects decimal-point formatting and the information provided by localeconv function.
LC_TIMEAffects the strftime function.

A value of “C” for locale sets the locale to the normal C translation environment settings (default). A null value (“”) sets the native environment settings. A null pointer (NULL) causes setlocale to return a pointer to the string associated with this category for the current settings (no changes occur). All other values are implementation-specific.

After a successful set, setlocale returns a pointer to a string which represents the previous location setting. On failure it returns NULL.



int main(void)
  char *old_locale;

  printf("The preivous setting was %s.\n",old_locale);
  return 0;