Localization: locale.h

I l @ ve RuBoard

Localization: locale.h

A locale is a group of settings controlling things such as the symbol used as a decimal point. Locale values are stored in a structure of type struct lconv , defined in the locale.h header file. A locale can be specified by a string, which acts to specify a particular set of values for the structure members . The default locale is designated by the string "C" . Table F.3 lists the localization functions, and a brief discussion follows .

Table  F.3. Localization functions.
Prototype Description
char * setlocale(int category, const char * locale); The function sets certain locale values to the values specified by the locale and indicated by locale . The category value controls which locale values get set (see Table F.4). The function returns the null pointer if it cannot honor the request. Otherwise, it returns a pointer associated with the specified category in the new locale.
struct lconv * localeconv (void); Returns a pointer to a struct lconv structure filled in with the values of the current locale.

The required possible values for the locale parameter to setlocale() are "C" , which is the default, and " " , which represents the implementation-defined native environment. An implementation can define additional locales. The possible values for the category parameter to setlocale() are represented by the macros listed in Table F.4.

Table  F.4. Category macros.
Macro Description
NULL Leave the locale unchanged and return a pointer to the current locale.
LC_ALL Change all locale values.
LC_COLLATE Change locale values for the collating sequence used by strcoll () and strxfrm () .
LC_CTYPE Change locale values for the character-handling functions and to the multibyte functions.
LC_MONETARY Change locale values for monetary formatting information.
LC_NUMERIC Change locale values for the decimal point symbol and non-monetary formatting wused by formatted I/O and by string conversion functions.
LC_TIME Change locale values for the time formatting used by strftime() .

Table F.5 lists the required members of a struct lconv structure.

Table  F.5. Required struct lconv members.
Macro Description
char *decimal_point Decimal-point character for non-monetary values.
char *thousands_sep Character used to separate groups of digits before the decimal point for non-monetary quantities .
char *grouping A string whose elements indicate the size of each group of digits for non-monetary quantities.
char *int_curr_symbol The international currency symbol.
char *currency_symbol The local currency symbol.
char *mon_decimal_point Decimal-point character for monetary values.
char *mon_thousands_sep Character used to separate groups of digits before the decimal point for non-monetary quantities.
char *mon_grouping A string whose elements indicate the size of each group of digits for monetary quantities.
char *positive_sign String used to indicate a non-negative formatted monetary value.
char *negative_sign String used to indicate a negative formatted monetary value.
char int_frac_digits Number of digits displayed after the decimal point for an internationally formatted monetary quantity.
char frac_digits Number of digits displayed after the decimal point for a locally formatted monetary quantity.
char p_cs_precedes Set to 1 or depending on whether currency_symbol precedes or follows the value of a non-negative formatted monetary quantity.
char p_sep_by_space Set to 1 or depending on whether currency_symbol is separated by a space from the value of a non-negative formatted monetary quantity.
char n_cs_precedes Set to 1 or depending on whether currency_symbol precedes or follows the value of a negative formatted monetary quantity.
char n_sep_by_space Set to 1 or depending on whether currency_symbo l is separated by a space from the value of a negative formatted monetary quantity.
char p_sign_posn Set to a value indicating the positioning of positive_sign string; means parentheses surround the quantity and currency symbol, 1 means the string precedes the quantity and currency symbol, 2 means the string follows the quantity and currency symbol, 3 means the string immediately precedes the currency symbol, and 4 means the string immediately follows the currency symbol.
char n_sign_posn Set to a value indicating the positioning of negative_sign string; the meaning is the same as for char p_sign_posn .
I l @ ve RuBoard


C++ Primer Plus
C Primer Plus (5th Edition)
ISBN: 0672326965
EAN: 2147483647
Year: 2000
Pages: 314
Authors: Stephen Prata

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net