home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / i18nv104.zip / SAMPLE / SETLOC / SETL.C < prev    next >
C/C++ Source or Header  |  1996-02-13  |  3KB  |  58 lines

  1. /*****************************************************************************/
  2. /***     Include files.                                                    ***/
  3. /*****************************************************************************/
  4.  
  5. #include <stdio.h>                      /* Standard IO functions.            */
  6.  
  7. #include <wchar.h>                      /* XPG/4 library.                    */
  8.  
  9. /*****************************************************************************/
  10. /***     Main program.                                                     ***/
  11. /*****************************************************************************/
  12.  
  13. void main(void)
  14. {
  15.   char *ret_string;                     /* String returned from setlocale.   */
  16.  
  17.                                         /* Set all locale variables to value */
  18.                                         /*  defined in LC_ALL or LANG        */
  19.                                         /*  environment variables.           */
  20.   setlocale(-1, "");
  21.   ret_string = setlocale(-1, NULL);
  22.   printf("\nLocale settings are: %s\n", ret_string);
  23.  
  24.                                         /* Change the monetary locale to the */
  25.                                         /*  value set in the LC_MONETARY     */
  26.                                         /*  environment variable.  This is   */
  27.                                         /*  redundant, since it was already  */
  28.                                         /*  done in the first setlocale call.*/
  29.                                         /* Query and print the value to show */
  30.                                         /*  that it is no different.         */
  31.   setlocale(2, "");
  32.   ret_string = setlocale(-1, NULL);
  33.   printf("Locale settings are: %s\n", ret_string);
  34.  
  35.                                         /* Override the numeric locale to be */
  36.                                         /*  hardcoded to "italian in italy"  */
  37.                                         /*  locale.  NOTE: This is hardcoded */
  38.                                         /*  into the program.  There is no   */
  39.                                         /*  way for the application user to  */
  40.                                         /*  set the numeric locale to any    */
  41.                                         /*  other value at run-time.         */
  42.   setlocale(3, "it_it.850");
  43.  
  44.                                         /* Return the value of the locale    */
  45.                                         /*  settings.                        */
  46.                                         /* Print out the locale settings.    */
  47.   ret_string = setlocale(-1, NULL);
  48.   printf("Locale settings are: %s\n", ret_string);
  49.  
  50.                                         /* This returns the state of the     */
  51.                                         /*  groups back to the values set    */
  52.                                         /*  in the environment variables.    */
  53.                                         /* Query and print out the string.   */
  54.   setlocale(-1, "");
  55.   ret_string = setlocale(-1, NULL);
  56.   printf("Changed the settings back: %s\n", ret_string);
  57. }
  58.