You can use environment variables to specify the names of locale categories. However you must call the setlocale function, regardless the current environment variable settings.
Here is a C program that uses the _putenv function to set the category LC_ALL for a locale called TEXAN before calling setlocale. This program runs as described if you first create the TEXAN locale following the example for the steps to customize a locale.
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
int main(void){
printf("Default locale = \"%s\"\n", setlocale(LC_ALL, ""));
_putenv("LC_ALL=TEXAN");
setlocale(LC_ALL,"");
printf("Default locale = \"%s\"\n", setlocale(LC_ALL,NULL));
return(0);
}
When you build and run this program, you should see output similar to:
Default locale = "C" Default locale = "TEXAN"
Example: Customize an Existing Locale
![]()
Internationalization
Localization
and Locales
![]()
Make Your
Program International
Select a
Locale
Customize
a Locale
