RAD Studio
ContentsIndex
PreviousUpNext
localeconv

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 used in nonmonetary formats. This can never be an empty string. 
char 
Separator used to group digits to the left of the decimal point. Not used with monetary quantities. 
char 
Size of each group of digits. Not used with monetary quantities. See the value listing table below. 
char 
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 
Local monetary symbol for the current locale. 
char 
Decimal point used to format monetary quantities. 
char 
Separator used to group digits to the left of the decimal point for monetary quantities. 
char 
Size of each group of digits used in monetary quantities. See the value listing table below. 
char 
String indicating nonnegative monetary quantities. 
char 
String indicating negative monetary quantities. 
char 
Number of digits after the decimal point that are to be displayed in an internationally formatted monetary quantity. 
char 
Number of digits after the decimal point that are to be displayed in a formatted monetary quantity. 
char 
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 
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 
Set to 1 if currency_symbol precedes a negative formatted monetary quantity. If currency_symbol is after the quantity, set to 0. 
char 
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 
Indicate where to position the positive sign in a nonnegative formatted monetary quantity. 
char 
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. 
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:

Use parentheses to surround the quantity and currency_symbol. 
Sign string precedes the quantity and currency_symbol. 
Sign string succeeds the quantity and currency_symbol. 
Sign string immediately precedes the quantity and currency_symbol. 
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++ 
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!