O'Reilly logo

C Pocket Reference by Ulla Kirch-Prinz, Peter Prinz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

Table 1-42. Locale categories

Category

Portions of the locale affected

LC_ALL

The entire locale, including all of the categories below

LC_COLLATE

Only the functions strcoll() and strxfrm()

LC_CTYPE

Functions for character processing, such as isalpha() and the multibyte functions

LC_MONETARY

The currency formatting information returned by localeconv()

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 localeconv()

LC_TIME

Formatting of date and time information by strftime()

The following function is used to adapt a program to a specific locale:

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

The argument category is one of the symbolic constants described ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required