localeconv

From RAD Studio
Jump to: navigation, search

Go Up to locale.h Index


Header File

locale.h

Category

Miscellaneous Routines

Prototype

struct lconv *localeconv(void);

Description

Queries the locale for numeric format.

This function provides information about the monetary and other numeric formats for the current locale. The information is stored in a struct lconv type. The structure can only be modified by the setlocale. Subsequent calls to localeconv will update the lconv structure.

The lconv structure is defined in locale.h. It contains the following fields:

char *decimal_point;	

Decimal point used in nonmonetary formats. This can never be an empty string.

char *thousands_sep;	

Separator used to group digits to the left of the decimal point. Not used with monetary quantities.

char *grouping;

Size of each group of digits. Not used with monetary quantities. See the value listing table below.

char *int_curr_symbol;	

International monetary symbol in the current locale. The symbol format is specified in the ISO 4217 Codes for the Representation of Currency and Funds.

char *currency_symbol;	

Local monetary symbol for the current locale.

char *mon_decimal_point;	

Decimal point used to format monetary quantities.

char *mon_thousands_sep;	

Separator used to group digits to the left of the decimal point for monetary quantities.

char *mon_grouping;

Size of each group of digits used in monetary quantities. See the value listing table below.

char *positive_sign;	

String indicating nonnegative monetary quantities.

char *negative_sign;

String indicating negative monetary quantities.

char int_frac_digits;

Number of digits after the decimal point that are to be displayed in an internationally formatted monetary quantity.

char frac_digits;

Number of digits after the decimal point that are to be displayed in a formatted monetary quantity.

char p_cs_precedes;	

Set to 1 if currency_symbol precedes a nonnegative formatted monetary quantity. If currency_symbol is after the quantity, it is set to 0.

char p_sep_by_space;	

Set to 1 if currency_symbol is to be separated from the nonnegative formatted monetary quantity by a space. Set to 0 if there is no space separation.

char n_cs_precedes;

Set to 1 if currency_symbol precedes a negative formatted monetary quantity. If currency_symbol is after the quantity, set to 0.

char n_sep_by_space;	

Set to 1 if currency_symbol is to be separated from the negative formatted monetary quantity by a space. Set to 0 if there is no space separation.

char p_sign_posn;	

Indicate where to position the positive sign in a nonnegative formatted monetary quantity.

char n_sign_posn;	

Indicate where to position the positive sign in a negative formatted monetary quantity.



Any of the above strings (except decimal_point) that is empty " " is not supported in the current locale. The nonstring char elements are nonnegative numbers. Any nonstring char element that is set to CHAR_MAX indicates that the element is not supported in the current locale.

The grouping and mon_grouping elements are set and interpreted as follows:

CHAR_MAX

No further grouping is to be performed.

0

The previous element is to be used repeatedly for the remainder of the digits.

any other integer

Indicates how many digits make up the current group. The next element is read to determine the size of the next group of digits before the current group.



The p_sign_posn and n_sign_posn elements are set and interpreted as follows:

0

Use parentheses to surround the quantity and currency_symbol.

1

Sign string precedes the quantity and currency_symbol.

2

Sign string succeeds the quantity and currency_symbol.

3

Sign string immediately precedes the quantity and currency_symbol.

4

Sign string immediately succeeds the quantity and currency_symbol.



Return Value

Returns a pointer to the the filled-in structure of type struct lconv. The values in the structure will change whenever setlocale modifies the LC_MONETARY or LC_NUMERIC categories.

Example

 #include <locale.h>
 #include <stdio.h>
 int main(void)
 {
    struct lconv ll;
    struct lconv *conv = &ll;
 /* read the locality conversion structure */
    conv = localeconv();
 /* display the structure */
   printf("Decimal Point                 : %s\n", conv-> decimal_point);
   printf("Thousands Separator           : %s\n", conv-> thousands_sep);
   printf("Grouping                      : %s\n", conv-> grouping);
   printf("International Currency symbol : %s\n", conv-> int_curr_symbol);
   printf("$ thousands separator         : %s\n", conv-> mon_thousands_sep);
   printf("$ grouping                    : %s\n", conv-> mon_grouping);
   printf("Positive sign                 : %s\n", conv-> positive_sign);
   printf("Negative sign                 : %s\n", conv-> negative_sign);
   printf("International fraction digits : %d\n", conv-> int_frac_digits);
   printf("Fraction digits               : %d\n", conv-> frac_digits);
   printf("Positive $ symbol precedes    : %d\n", conv-> p_cs_precedes);
   printf("Positive sign space separation: %d\n", conv-> p_sep_by_space);
   printf("Negative $ symbol precedes    : %d\n", conv-> n_cs_precedes);
   printf("Negative sign space separation: %d\n", conv-> n_sep_by_space);
   printf("Positive sign position        : %d\n", conv-> p_sign_posn);
   printf("Negative sign position        : %d\n", conv-> n_sign_posn);
   return 0;
 }

Portability

POSIX Win32 ANSI C ANSI C++

+

+

+

+