Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ 3.0r4 - <b>setlocale</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
setlocale

Usage

   #include <locale.h>
   char * setlocale(int category, const char * locale);

   ANSI

Description

   setlocale is used to change locale dependent behavior or to check on its
   current settings. category can be one of six predefined constants.
   Zortech C++ supports the minimal ANSI C definition and therefore only

   those described below have any effect.

   LC_ALL           Specifies the entire locale.

   LC_COLLATE

   LC_CTYPE

   LC_MONETARY      Specifies monetary formatting characteristics.

   LC_NUMERIC       Specifies the character to be used for decimal point and
                    other nonmonetary formatting behavior.

   LC_TIME

   The following locales are recognized.

        C               The minimal default locale.

        USA             This is predefined in locale.h as the
                        "native" localle.  Calling setlocale(LC_ALL,"")
                        will select this.
        Italy
        Netherlands
        Norway
        Switzerland
        UK
        Japan
        Korea
        China

   Information as to the current locale can be obtained by a call to
   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.

Example 

   #include <locale.h>
   #include <stdio.h>
   #include <stdlib.h>
   #include <string.h>

   char * countries[] =
   {

       "USA",
       "ITALY",
       "NORWAY",
       NULL
   };

   int 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_MONETARY,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);
       }
       return EXIT_SUCCESS;
   }

Return Value

   A pointer containing the currently selected locale for the category
   specified. A NULL is returned if the locale specified is not supported.

See Also

   localeconv



See Also: localeconv

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson