home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tolkit45.zip / os2tk45 / som / include / somtdbcs.c < prev    next >
C/C++ Source or Header  |  1999-02-22  |  3KB  |  117 lines

  1. /***!Start!***                                                                     
  2.  *                                                                                 
  3.  *   ORIGINS: 27                                                                   
  4.  *                                                                                 
  5.  *   IBM CONFIDENTIAL -- (IBM Confidential Restricted when                         
  6.  *   combined with the aggregated modules for this product)                        
  7.  *   OBJECT CODE ONLY SOURCE MATERIALS                                             
  8.  *                                                                                 
  9.  *    25H7912  (C)  COPYRIGHT International Business Machines Corp. 1992,1994,1996 
  10.  *   All Rights Reserved                                                           
  11.  *   Licensed Materials - Property of IBM                                          
  12.  *   The source code for this program is not published or otherwise divested       
  13.  *   of its trade secrets, irrespective of what has been deposited with the        
  14.  *   U.S. Copyright Office.                                                        
  15.  *                                                                                 
  16.  ***!End!***/                                                                      
  17.                                                                                    
  18. /*
  19.  * @(#) 1.4.1.1 src/somk/somtdbcs.c, somk.sys, som2.1 1/3/96 13:16:46 [7/30/96 15:23:26]
  20.  */
  21.  
  22. #ifndef somtdbcs_c
  23. #define somtdbcs_c
  24.  
  25. /*
  26.  * -- somtinitDbcs --
  27.  * This routine initialises the somtisDbcs routine for OS/2, AIX, DOS, etc.
  28.  */
  29.  
  30. #if defined(_WDOS) || defined(_WIN16)
  31.    #define CP_JAPAN     932
  32.    #define CP_KOREA     934
  33.    #define CP_SCHINESE  936
  34.    #define CP_TCHINESE  938
  35.  
  36.    #ifdef _WDOS
  37.        #include <dos.h>
  38.        #define DOS_GET_DBCP   0x6601
  39.        #define DOS_GET_DBCSEV 0x6300
  40.  
  41.     static int GetKBCodePage(void)
  42.     {
  43.         union REGS regs;
  44.         regs.x.ax = DOS_GET_DBCP;
  45.         intdos(®s, ®s);
  46.  
  47.         return (regs.x.bx);
  48.     }
  49.     #endif /* _WDOS  */
  50.  
  51. #elif defined(__OS2__)
  52.  
  53. #else /* AIX */
  54.  
  55.    #include <nl_types.h>
  56.    #include <locale.h>
  57.  
  58. #endif
  59.  
  60.  
  61. static void somtinitDbcs(char *dbcsBuf, size_t bufsize)
  62. {
  63. #if defined(_WDOS) || defined(_WIN16)
  64.     int cp = GetKBCodePage();
  65.  
  66.     switch (cp) {
  67.     case CP_JAPAN:
  68.         dbcsBuf[0] = 0x81;
  69.         dbcsBuf[1] = 0x9f;
  70.         dbcsBuf[2] = 0xe0;
  71.         dbcsBuf[3] = 0xfc;
  72.         dbcsBuf[4] = 0;
  73.         dbcsBuf[5] = 0;
  74.         break;
  75.  
  76.     case CP_KOREA:
  77.         dbcsBuf[0] = 0x81;
  78.         dbcsBuf[1] = 0xbf;
  79.         dbcsBuf[2] = 0;
  80.         dbcsBuf[3] = 0;
  81.         break;
  82.  
  83.     case CP_SCHINESE:
  84.         dbcsBuf[0] = 0x81;
  85.         dbcsBuf[1] = 0xfc;
  86.         dbcsBuf[2] = 0;
  87.         dbcsBuf[3] = 0;
  88.         break;
  89.  
  90.     case CP_TCHINESE:
  91.         dbcsBuf[0] = 0x81;
  92.         dbcsBuf[1] = 0xfc;
  93.         dbcsBuf[2] = 0;
  94.         dbcsBuf[3] = 0;
  95.         break;
  96.  
  97.     default:
  98.         dbcsBuf[0] = 0;
  99.         dbcsBuf[1] = 0;
  100.         break;
  101.     }
  102. #elif __OS2__
  103.     COUNTRYCODE    cc;
  104.  
  105.     cc.country  = 0; /* Use default country */
  106.     cc.codepage = 0; /* Use current codepage */
  107.     if (DosQueryDBCSEnv(bufsize, &cc, dbcsBuf)) {
  108.     dbcsBuf[0] = '\0';
  109.     dbcsBuf[1] = '\0';
  110.     }
  111. #else
  112.     setlocale(LC_CTYPE, "");
  113. #endif /* AIX */
  114. }
  115.  
  116. #endif /* somtdbcs_c */
  117.