localeconv() — Query numeric conventions
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
ISO C |
both |
Format
#include <locale.h>
struct lconv *localeconv(void);
General description
Sets the components of a structure having type struct lconv to values appropriate for the current locale. The structure may be overwritten by another call to localeconv() or by calling setlocale() and passing LC_ALL, LC_MONETARY, or LC_NUMERIC.
For a list of the elements in the lconv structure, see Table 1.
Pointers to strings with a value of "" indicate that the value is not available in the C locale or is of 0 length. char types with a value of UCHAR_MAX indicate that the value is not available in the current locale.
Returned value
Returns a pointer to the structure.
Example
CELEBL06
/* CELEBL06
This example prints out the default decimal point for your locale and
then the decimal point for the Fr_CA locale.
*/
#include <stdio.h>
#include <locale.h>
int main(void)
{
char * string;
struct lconv * mylocale;
mylocale = localeconv();
/* Display default decimal point */
printf( "Default decimal point is a %s\n",
mylocale->decimal_point );
if (NULL != (string = setlocale(LC_ALL, "Fr_CA.IBM-1047" )))
{
mylocale = localeconv();
/* A comma is set to be the decimal point
when the locale is Fr_CA.IBM-1047 */
printf( "French-speaking Canadian decimal point is a %s\n",
mylocale->decimal_point );
}
else {
printf("setlocale(LC_ALL, Fr_CA.IBM-1047) returned <NULL>\n");
}
return 0;
}
Output
Default decimal-point is a .
French-speaking Canadian decimal-point is a ,
Related information
- See the topic about internationalization of locales and character sets in z/OS XL C/C++ Programming Guide
- locale.h
- localdtconv() — Date and time formatting convention inquiry
- localtime(), localtime64() — Convert time and correct for local time
- localtime_r(), localtime64_r() — Convert time value to broken-down local time
- setlocale() — Set locale