previous next contents
The Concept of Locale

locale - language environment determined by the application at run time. Includes specification of language, territory, and codeset.

setlocale(category, locale) - function defined by ANSI C for initializing localization data. When locale is the NULL pointer, the locale of the process is queried according to the value of category. The content of the string returned is unspecified. Usually it is the current locale. When locale is a null string, setlocale() takes the name of the new locale for the specified category from the environment as determined by the locale precedence rules. If locale is not null, then setlocale() takes locale the name of the new locale for the specified category.

locale precedence rules - the rules determined by the definitions of LANG, LC_ALL, and the other LC_ environment variables for setting the locale associated with the various categories. If LC_ALL is not set and if any of the LC_* variables is not set or is set to the empty string, then the value of LANG is the locale for the corresponding category. In this case, if LANG is not set or is set to the empty string, then the implementation-defined default locale shall be used.

LANG - environment variable which determines the locale for any category not specifically selected via a variable starting with LC_. Additional semantics of this variable, if any, are implementation-defined.

LC_ALL - environment variable which shall override the value of the LANG variable and the value of any of the other variables starting with LC_. LC_ALL is also a symbol which may be passed as the value of the second parameter in a call to setlocale() which instructs setlocale() to associate the value of the first parameter with all categories.

heavyweight function - function requiring a lot of overhead and CPU resources.

setlocale() is a heavyweight function.

How setlocale() obtains a language when the language is not explicitly referenced in the call to setlocale() is system dependent.

On POSIX systems, the environment variable LANG and the LC_* variables are used to determine the locale when it is not explicitly specified in calls to setlocale().

Under any circumstances, if setlocale() is not called, the C locale will be in effect. Otherwise, if setlocale() is called and the locale is not supported, then the locale in effect is implementation-defined.

supported locale - a member of a set of locales supported by an operating system.

At the present time, there is no uniformity in the naming conventions for locales. Therefore, if a process on machine B executes on behalf of a process on machine A, even though the locale may have been transmitted the first process to the second, the results may not be acceptable. XPG/Uniforum is currently attempting to standardize these names.

LOCPATH - environment variable (defined in AIX only) which contains a colon-separated list of full or relative path names of directories to be searched by setlocale() when loading the locale database.

POSIX locale - the locale and its characteristics defined by POSIX, which is very nearly the same as the C locale.

Conforming implementations shall provide a POSIX locale.

locale utility - displays the values of LANG, LC_* environment variables, and the values of cultural data items for each of the categories for the currently set locale. The -a flag will display all of this information for each of the supported public locales. The -m flag writes name of available charmaps. The -k flag writes names and values of selected keywords. The -c flag writes the names of selected locale categories.

localedef utility - POSIX.2-defined utility which reads a charmap file and a locale definition file and creates a locale database for a locale. If POSIX2_LOCALEDEF is defined on a system, then localedef will be able to create a locale. Otherwise, only implementation-provided locale(s) can be used. In this case, localedef will terminate with an exit code indicating that the locale could not be created.

localedef syntax - localedef [-c][-f charmap][-i sourcefile] name where name is the name of the target locale, sourcefile is the name of the locale definition file, charmap is the name of the charmap file. If sourcefile is not specified, then stdin is read. -c causes localedef to create permanent output even if warning messages have been issued. If the -f option is not specified, the implementation-defined default charmap shall be used. If name does not contain any slash characters, the interpretation of the name is implementatijon defined and the locale shall be public. This capability may be restricted to users with appropriate privileges.

It is implementation-defined whether or not users or applications can provide additional charmap files. Therefore, the -f option of localedef might be operable only when an implementation-provided charmap is named.

public locale - locale available to any user.

private locale - locale available to a limited set of users based on file permission bits.

POSIX2_LOCALEDEF - symbol which, if defined, indicates that the localedef utility is capable of creating a locale.

When the value of a locale environment variable begins with a slash (/), it shall be interpreted as the pathname of the locale definition. If the value of the locale value does not begin with a slash, the mechanism used to locate the the locale is implementation-defined.

The value that shall be used to specify a locale when using enviornment variables is the name specified as the name operand to the localedef utility when the locale was created. This provides a verifiable method to create and invoke a locale.

default locale - Implementations must define a locale as the default locale, to be invoked when no environment variables are set, or set the empty string. This default locale can be the POSIX locale or any other,

implementation-defined locale. POSIX.2 does not require that the default locale be settable at installation time.

locale definition file - file accepted by the localedef utility which describes a locale. The yacc grammar for a locale definition is given in POSIX.2.

The locale definition file shall contain one or more locale category source definitions and shall not contain more than one definition for the same locale category. if the file contains source definitions for more than one category, implementation-defined categories, if proesent, shall appear after the POSIX-defined categories. In the event that some of the information for a locale category, as specified in POSIX.2, is missing from the locale source definition, the behavior of that category, if it is referenced, is unspecified.

If a locale category source definition within a locale definition file contains a copy statement, and the copy statement names a valid, existing locale, then localedef shall behave as if the source definition had contained a valid category source definition for the named locale.

The charmap file specifies only the content and encoding of the character set. The locale definition file specifies character classification and collation information for a locale.


previous next contents