[Previous]
[Contents]
[Next]

localeconv()

set up formatting of numeric quantities according to the current locale

Synopsis:

#include <locale.h>
struct lconv *localeconv( void );

Description:

The localeconv() function sets the components of an object of type struct lconv with values appropriate for the formatting of numeric quantities according to the current locale. The components of the struct lconv and their meanings are as follows:

char *decimal_point
The decimal-point character used to format nonmonetary quantities.
char *thousands_sep
The character used to separate groups of digits to the left of the decimal-point character 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 Codes for the Representation of Currency and Funds. 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 character used to format monetary quantities.
char *mon_thousands_sep
The character used to separate groups of digits to the left of the decimal-point character in formatted monetary quantities.
char *mon_grouping
A string whose elements indicate the size of each group of digits in formatted monetary quantities.
char *grouping
A string whose elements indicate the size of each group of digits in formatted nonmonetary quantities.
char *positive_sign
The string used to indicate a nonnegative-valued monetary quantity.
char *negative_sign
The string used to indicate a negative-valued monetary quantity.
char int_frac_digits
The number of fractional digits (those to the right of the decimal point) to be displayed in an internationally formatted monetary quantity.
char frac_digits
The number of fractional digits (those to the right of 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 follows 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 follows 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
The position of the positive_sign for a nonnegative formatted monetary quantity.
char n_sign_posn
The position of the positive_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 value is the number of digits that comprise the current group. The next element is examined to determine the size of the next group of digits to the left of the current group.

The value of p_sign_posn and n_sign_posn is interpreted as follows:

0
Parentheses surround the quantity and currency_symbol.
1
The sign string precedes the quantity and currency_symbol.
2
The sign string follows the quantity and currency_symbol.
3
The sign string immediately precedes the quantity and currency_symbol.
4
The sign string immediately follows the quantity and currency_symbol.

Returns:

A pointer to the filled-in object.

Examples:

#include <stdio.h>
#include <locale.h>

void main()
  {
    struct lconv *lc;

    lc = localeconv();
    printf( "*decimal_point (%s)\n",
      lc->decimal_point );

    printf( "*thousands_sep (%s)\n",
      lc->thousands_sep );

    printf( "*int_curr_symbol (%s)\n",
      lc->int_curr_symbol );

    printf( "*currency_symbol (%s)\n",
      lc->currency_symbol );

    printf( "*mon_decimal_point (%s)\n",
      lc->mon_decimal_point );

    printf( "*mon_thousands_sep (%s)\n",
      lc->mon_thousands_sep );

    printf( "*mon_grouping (%s)\n",
      lc->mon_grouping );

    printf( "*grouping (%s)\n",
      lc->grouping );

    printf( "*positive_sign (%s)\n",
      lc->positive_sign );

    printf( "*negative_sign (%s)\n",
      lc->negative_sign );

    printf( "int_frac_digits (%d)\n",
      lc->int_frac_digits );

    printf( "frac_digits (%d)\n",
      lc->frac_digits );

    printf( "p_cs_precedes (%d)\n",
      lc->p_cs_precedes );

    printf( "p_sep_by_space (%d)\n",
      lc->p_sep_by_space );

    printf( "n_cs_precedes (%d)\n",
      lc->n_cs_precedes );

    printf( "n_sep_by_space (%d)\n",
      lc->n_sep_by_space );

    printf( "p_sign_posn (%d)\n",
      lc->p_sign_posn );

    printf( "n_sign_posn (%d)\n",
      lc->n_sign_posn );
  }

Classification:

ANSI

Safety:
Interrupt handler No
Signal handler No
Thread Yes

See also:

setlocale()


[Previous]
[Contents]
[Next]