VxWorks Reference Manual : Libraries
ansiLocale - ANSI locale documentation
localeconv( ) - set the components of an object with type lconv (ANSI)
setlocale( ) - set the appropriate locale (ANSI)
The header locale.h declares two functions and one type, and defines several macros. The type is:
- struct lconv
- contains members related to the formatting of numeric values. The structure should contain at least the members defined in locale.h, in any order.
ansiLocale, localeconv( ), setlocale( ), American National Standard X3.159-1989
localeconv( ) - set the components of an object with type lconv (ANSI)
struct lconv *localeconv (void)
This routine sets the components of an object with type struct lconv with values appropriate for the formatting of numeric quantities (monetary and otherwise) according to the rules of the current locale.
The members of the structure with type char * are pointers to strings any of which (except decimal_point) can point to "" to indicate that the value is not available in the current locale or is of zero length. The members with type char are nonnegative numbers, any of which can be CHAR_MAX to indicate that the value is not available in the current locale. The members include the following:
- char *decimal_point
- The decimal-point character used to format nonmonetary quantities.
- char *thousands_sep
- The character used to separate groups of digits before the decimal-point character in formatted nonmonetary quantities.
- char *grouping
- A string whose elements indicate the size of each group of digits in formatted nonmonetary quantities.
- char *int_curr_symbol
- The international currency symbol applicable to the current locale. The first three characters contain the alphabetic international currency symbol in accordance with those specified in ISO 4217:1987. The fourth character (immediately preceding the null character) is the character used to separate the international currency symbol from the monetary quantity.
- char *currency_symbol
- The local currency symbol applicable to the current locale.
- char *mon_decimal_point
- The decimal-point used to format monetary quantities.
- char *mon_thousands_sep
- The separator for groups of digits before the decimal-point in formatted monetary quantities.
- char *mon_grouping
- A string whose elements indicate the size of each group of digits in formatted monetary quantities.
- char *positive_sign
- The string used to indicate a nonnegative-valued formatted monetary quantity.
- char *negative_sign
- The string used to indicate a negative-valued formatted monetary quantity.
- char int_frac_digits
- The number of fractional digits (those after the decimal-point) to be displayed in an internationally formatted monetary quantity.
- char frac_digits
- The number of fractional digits (those after the decimal-point) to be displayed in a formatted monetary quantity.
- char p_cs_precedes
- Set to 1 or 0 if the currency_symbol respectively precedes or succeeds the value for a nonnegative formatted monetary quantity.
- char p_sep_by_space
- Set to 1 or 0 if the currency_symbol respectively is or is not separated by a space from the value for a nonnegative formatted monetary quantity.
- char n_cs_precedes
- Set to 1 or 0 if the currency_symbol respectively precedes or succeeds the value for a negative formatted monetary quantity.
- char n_sep_by_space
- Set to 1 or 0 if the currency_symbol respectively is or is not separated by a space from the value for a negative formatted monetary quantity.
- char p_sign_posn
- Set to a value indicating the positioning of the positive_sign for a nonnegative formatted monetary quantity.
- char n_sign_posn
- Set to a value indicating the positioning of the negative_sign for a negative formatted monetary quantity.
The elements of grouping and mon_grouping are interpreted according to the following:
- CHAR_MAX
- No further grouping is to be performed.
- 0
- The previous element is to be repeatedly used for the remainder of the digits.
- other
- The integer value is the number of the digits that comprise the current group. The next element is examined to determined the size of the next group of digits before the current group.
The values of p_sign_posn and n_sign_posn are interpreted according to the following:
- 0
- Parentheses surround the quantity and currency_symbol.
- 1
- The sign string precedes the quantity and currency_symbol.
- 2
- The sign string succeeds the quantity and currency_symbol.
- 3
- The sign string immediately precedes the currency_symbol.
- 4
- The sign string immediately succeeds the currency_symbol.
The implementation behaves as if no library function calls localeconv( ).
The localeconv( ) routine returns a pointer to the filled-in object. The structure pointed to by the return value is not modified by the program, but may be overwritten by a subsequent call to localeconv( ). In addition, calls to setlocale( ) with categories LC_ALL, LC_MONETARY, or LC_NUMERIC may overwrite the contents of the structure.
locale.h, limits.h
A pointer to the structure lconv.
setlocale( ) - set the appropriate locale (ANSI)
char *setlocale ( int category, /* category to change */ const char * localeName /* locale name */ )
This function is included for ANSI compatibility. Only the default is implemented. At program start-up, the equivalent of the following is executed:
setlocale (LC_ALL, "C");This specifies the program's entire locale and the minimal environment for C translation.
locale.h, string.h, stdlib.h
A pointer to the string "C".