Internationalization
The ANSI
standard supports the development of C programs that are adaptable to
language and country-specific customs, such as the formatting of
currency strings. The ANSI library also provides two functions, the
type lconv, and macros for dealing with locales.
These are declared in the header file
locale.h
.
All programs start with the default locale “C”, which contains no country or language-specific information. During execution, the program can change to another locale and retrieve locale-specific information. Since most applications do not require the full range of locale-specific information, this information is classified into categories, as shown in Table 1-42.
|
Category |
Portions of the locale affected |
LC_ALL |
The entire locale, including all of the categories below |
LC_COLLATE |
Only the functions |
LC_CTYPE |
Functions for character processing, such as
|
LC_MONETARY |
The currency formatting information returned by
|
LC_NUMERIC |
The decimal point character used by input/output and string
conversion functions, and the formatting of non-currency numeric
information, as returned by |
LC_TIME |
Formatting of date and time information by
|
The following function is used to adapt a program to a specific locale:
-
char *setlocale( intcategory, const char *name); The argument
categoryis one of the symbolic constants described ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access