testlocale.c

text/plain

Filename: testlocale.c
Type: text/plain
Part: 0
Message: Re: [HACKERS] Re: Postgresql broken
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <limits.h>
#include <locale.h>

struct lconv *lconvert;

int main(int argc, char **argv) {
    int         fpoint;
    char        dsymbol,
                ssymbol,
                psymbol,
                nsymbol,
                csymbol;

    if (argc > 1)
      printf( "locale set to %s\n", setlocale(LC_MONETARY, getenv(argv[1])));

#if FALSE
    printf( "locale set to %s\n", setlocale(LC_MONETARY, "C"));
#endif

    lconvert = localeconv();

    /* frac_digits in the C locale seems to return CHAR_MAX */
    /* best guess is 2 in this case I think */
#if FALSE
    fpoint = ((lconvert->frac_digits != CHAR_MAX) ? lconvert->frac_digits : 2);     /* int_frac_digits? */
#endif
    fpoint = lconvert->frac_digits;     /* int_frac_digits? */

    dsymbol = *lconvert->mon_decimal_point;
    ssymbol = *lconvert->mon_thousands_sep;
    csymbol = *lconvert->currency_symbol;
    psymbol = *lconvert->positive_sign;
    nsymbol = *lconvert->negative_sign;

printf( "numeric decimal point '%c'\n", *lconvert->decimal_point);

printf( "cashin- frac digits '%d'; mon decimal '%c'; mon thousands '%c'; currency '%c'; positive '%c'; negative '%c'\n",
 fpoint, dsymbol, ssymbol, csymbol, psymbol, nsymbol);

  exit(0);
}