home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / i18nv102.zip / SAMPLE / INFO / INFO.C < prev    next >
C/C++ Source or Header  |  1995-08-28  |  3KB  |  62 lines

  1. /*****************************************************************************/
  2. /***     Include files                                                     ***/
  3. /*****************************************************************************/
  4.  
  5. #include <stdio.h>                      /* Standard IO functions.            */
  6.  
  7. #include <wchar.h>                      /* XPG/4 library.                    */
  8. #include <locale.h>                     /* Locale definitions.               */
  9. #include <langinfo.h>                   /* Definitions for locale defs.      */
  10.  
  11. /*****************************************************************************/
  12. /***     Get locale-specific info from the table.                          ***/
  13. /*****************************************************************************/
  14.  
  15. void get_locale_info(void)
  16. {
  17.   struct lconv *table;                  /* Table return info.                */
  18.  
  19.                                         /* Get the table of locale info.     */
  20.                                         /* Print a header.                   */
  21.                                         /* Print some information from the   */
  22.                                         /*  table.                           */
  23.   table = localeconv();
  24.   printf("\nData from LOCALECONV:\n");
  25.   printf("---------------------\n");
  26.   printf("International monetary symbol: %s\n", table->int_curr_symbol);
  27.   printf("Negative sign: %s\n", table->negative_sign);
  28.   printf("Number of fractional digits (after decimal point): %d\n",
  29.          table->frac_digits);
  30.  
  31.                                         /* Print a header.                   */
  32.                                         /* Print some information about the  */
  33.                                         /*  locale, using nl_langinfo.       */
  34.   printf("\nData from NL_LANGINFO:\n");
  35.   printf("----------------------\n");
  36.   printf("Days of the week: %s %s %s %s %s %s %s\n",
  37.          nl_langinfo(ABDAY_1), nl_langinfo(ABDAY_2), nl_langinfo(ABDAY_3),
  38.          nl_langinfo(ABDAY_4), nl_langinfo(ABDAY_5), nl_langinfo(ABDAY_6),
  39.          nl_langinfo(ABDAY_7));
  40.  
  41.   printf("Radix character is: %s\nThousands separator: %s\n",
  42.          nl_langinfo(RADIXCHAR), nl_langinfo(THOUSEP));
  43. }
  44.  
  45. /*****************************************************************************/
  46. /***     Main program                                                      ***/
  47. /*****************************************************************************/
  48.  
  49. void main(void)
  50. {
  51.                                         /* Set the locale based on env var.  */
  52.                                         /* Print a header.                   */
  53.                                         /* Print the locale values.          */
  54.   setlocale(LC_ALL, "");
  55.   printf("\nWARNING: Different values reported by this program are based on\n");
  56.   printf("         different locale settings (LC_MONETARY, LC_TIME...)\n\n");
  57.   printf("Locale settings: %s\n", setlocale(LC_ALL, NULL));
  58.  
  59.                                         /* Get info from locale table.       */
  60.   get_locale_info();
  61. }
  62.