Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

atof(3C)

catopen(3C)

conv(3C)

ctype(3C)

gcvt(3C)

getdate(3C)

localeconv(3C)

nl_langinfo(3C)

strcoll(3C)

strftime(3C)

strtod(3C)

strxfrm(3C)

lconv(4)

strftime(4)

environ(5)

langinfo(5)

chrtbl(1M)

colltbl(1M)

gencat(1M)

montbl(1M)

setlocale(3C)

NAME

setlocale − locale control

SYNOPSIS

#include <locale.h>

char ∗setlocale (category, locale)
int category;
char ∗locale;

DESCRIPTION

The setlocale function selects the appropriate portion of the program’s locale as specified by the category and locale arguments.  The setlocale function may be used to change or query the program’s entire current locale or portions thereof. 

Category is a name defined in <locale.h> which expands to an integer value and determines which functions are to be affected by the specified locale. Category may have any of the following values:

LC_ALL names the program’s entire locale; the other values for category name only a portion of the program’s locale. 

LC_COLLATE
affects the behavior of the strcoll(3C) and strxfrm(3C) functions. 

LC_CTYPE affects the behavior of certain of the character handling functions (see ctype(3C) and conv(3C)). 

LC_MESSAGES
affects the behavior of the message catalogue functions (see catopen(3C)). 

LC_MONETARY
affects the monetary formatting information returned by the localeconv(3C) function. 

LC_NUMERIC
affects the decimal-point character for the formatted input/output functions and the string conversion functions atof(3C), strtod(3C), and gcvt(3C), as well as the non-monetary formatting information returned by the localeconv function. 

LC_TIME affects the behavior of the strftime, cftime, ascftime, and getdate(3C) functions (see strftime(3C)). 

Locale is a character string which names a specific locale.  Its value must be a directory in /usr/lib/locale or else it must be "C" or an empty string.  Each category corresponds to a set of databases which contain the relevant information for each defined locale.  The location of a database is given by the path /usr/lib/locale/locale/category, where locale and category are the names of locale and category, respectively.  For example, the database for the LC_CTYPE category for the “german” locale would be found in /usr/lib/locale/german/LC_CTYPE. 

A value of "C" for locale specifies the minimal environment for C language translation.  Information about the "C" locale is not represented by database files. 

A value of "" specifies the native language locale, as determined from environment variables LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME, and LC_MESSAGES, which are consulted for the locale name to use for the corresponding category.  If the environment variable corresponding to a category is not defined or is defined as the null string, then the environment variable LANG is consulted.  If neither the appropriate environment variable nor LANG is defined, then the "C" locale is selected. 

At program start-up, the equivalent of

setlocale(LC_ALL, "C");

is executed.  This has the effect of initializing each category to the locale described by the environment "C". 

If a pointer to a string is given for locale and the selection can be honored, the setlocale function returns a pointer to the string associated with the specified category for the new locale.  If the selection is not honored, the setlocale function returns a null pointer and the program’s locale is not changed.  When category LC_ALL is used, the return value may be a composite locale name if there is a mixture of locales among the categories. 

A null pointer for locale causes the setlocale function to return a pointer to the string associated with the category for the program’s current locale.  The program’s locale is not changed. 

The pointer to the string returned by the setlocale function is such that a subsequent call with that string value and its associated category will restore that part of the program’s locale.  The string pointed to must not be modified by the program.  It may be overwritten by a subsequent call to the setlocale function. 

FILES

/usr/lib/locale/∗ directory that contains the locale information

SEE ALSO

atof(3C), catopen(3C), conv(3C), ctype(3C), gcvt(3C), getdate(3C), localeconv(3C), nl_langinfo(3C), strcoll(3C), strftime(3C), strtod(3C), strxfrm(3C), lconv(4), strftime(4), environ(5), langinfo(5). 
chrtbl(1M), colltbl(1M), gencat(1M), montbl(1M) in the CX/UX Administrator’s Reference Manual.

CX/UX Programmer’s Reference Manual

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026