|
Reference · Data types Standard C · assert.h · complex.h · ctype.h · fenv.h · float.h · locale.h · math.h · setjmp.h · signal.h · stdarg.h · stddef.h · stdio.h · stdlib.h · string.h · time.h Standard C++ · IOstream · new Win32 · gc.h DOS, DOS32, Win16 · bios.h · cerror.h · disp.h · dos.h · dos.h part 2 · emm.h · handle.h · int.h · msmouse.h · sound.h · swap.h · tsr.h · winio.h Other C · bitops.h · conio.h · controlc.h · direct.h · fltpnt.h · io.h · page.h · process.h · search.h · sys\stat.h · tabsize.h · trace.h · utime.h · unmangle.h · util.h Other C++ · regexp.h · class complex |
locale.hlocaleconvHeaderlocale.h Prototype struct lconv * localeconv(void); Description
localeconv returns a pointer to a filled-in struct lconv which
contains information specific to the current country or locale.
struct lconv looks like this:
struct lconv
{
char *decimal_point;
char *thousands_sep;
char *int_curr_symbol;
char *currency_symbol;
char *mon_decimal_point;
char *mon_thousands_sep;
char *negative_sign;
char frac_digits;
char p_cs_precedes;
char p_sep_by_space;
char n_cs_precedes;
char n_sep_by_space;
char n_sign_posn;
char lc[6];
};
The fields are:
Return Value A pointer to a struct lconv. The values contained within the structure should be regarded as read only. Compatibility DOS Windows 3.x Phar Lap DOSX Win32 See Also Example See setlocale setlocaleHeaderlocale.h Prototype char * setlocale(int category, const char * locale); Description setlocale changes locale-dependent behavior or checks on its current settings. category can be one of the following predefined constants. Digital Mars C++ supports the minimal ANSI C definition and therefore only the following constants have an effect.
The following locales are recognized:
It also recognizes Italy, Netherlands, Norway, Switzerland, UK, Japan, Korea, China. Information about the current locale can be obtained by calling setlocale with a NULL second argument. This will return the current locale for the category selected. Having set the locale, a call to localeconv will obtain a pointer to a filled in struct lconv with the specific locale values. See localeconv for details. Return Value A pointer containing the currently selected locale for the category specified. A NULL is returned if the locale specified is not supported. Compatibility DOS Windows 3.x Phar Lap DOSX Win32 See Also Example
/* Example for setlocale */
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *countries[] =
{
"USA",
"ITALY",
"NORWAY",
NULL
};
void main ()
{
char *loc,
*currency;
int i;
struct lconv *lcptr;
int money = 100; /* Something to display */
/*
setlocale can be called with a NULL locale to
check on its current setting
*/
loc = setlocale (LC_ALL, NULL);
printf (" The default locale is the \"%s\"
locale\n", loc);
for (i = 0; countries[i]; i++)
{
loc = setlocale (LC_ALL, countries[i]);
lcptr = localeconv ();
currency = malloc
(strlen (lcptr-> currency_symbol) + 1);
strcpy (currency, lcptr-> currency_symbol);
if (loc)
printf (" Monetary figure for %s locale:
%s%d\n", loc, currency, money);
free(currency);
}
}
Output
The default locale is the "C" locale |