home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2005 June (DVD) / DPPRO0605DVD.iso / dotNETSDK / SETUP.EXE / netfxsd1.cab / FL_utf_h________.3643236F_FC70_11D3_A536_0090278A1BB8 < prev    next >
Encoding:
Text File  |  2002-05-06  |  3.1 KB  |  104 lines

  1. /*++
  2.  
  3. Copyright (c) Microsoft Corporation  All rights reserved.
  4.  
  5. Module Name:
  6.  
  7.     utf.h
  8.  
  9. Abstract:
  10.  
  11.     This file contains the header information for the UTF module of NLS.
  12.  
  13. Revision History:
  14.  
  15.     02-06-96    JulieB    Created.
  16.  
  17. --*/
  18.  
  19.  
  20.  
  21. //
  22. //  Constant Declarations.
  23. //
  24.  
  25. #define ASCII             0x007f
  26.  
  27. #define SHIFT_IN          '+'     // beginning of a shift sequence
  28. #define SHIFT_OUT         '-'     // end       of a shift sequence
  29.  
  30. #define UTF8_2_MAX        0x07ff  // max UTF8 2-byte sequence (32 * 64 = 2048)
  31. #define UTF8_1ST_OF_2     0xc0    // 110x xxxx
  32. #define UTF8_1ST_OF_3     0xe0    // 1110 xxxx
  33. #define UTF8_TRAIL        0x80    // 10xx xxxx
  34.  
  35. #define HIGER_6_BIT(u)    ((u) >> 12)
  36. #define MIDDLE_6_BIT(u)   (((u) & 0x0fc0) >> 6)
  37. #define LOWER_6_BIT(u)    ((u) & 0x003f)
  38.  
  39. #define BIT7(a)           ((a) & 0x80)
  40. #define BIT6(a)           ((a) & 0x40)
  41.  
  42.  
  43.  
  44.  
  45. /////////////////////////
  46. //                     //
  47. //  Unicode -> UTF-7   //
  48. //                     //
  49. /////////////////////////
  50.  
  51. //
  52. //  Convert one Unicode to 2 2/3 Base64 chars in a shifted sequence.
  53. //  Each char represents a 6-bit portion of the 16-bit Unicode char.
  54. //
  55. CONST char cBase64[] =
  56.  
  57.   "ABCDEFGHIJKLMNOPQRSTUVWXYZ"  // A : 000000 .... 011001  ( 0 - 25)
  58.   "abcdefghijklmnopqrstuvwxyz"  // a : 011010 .... 110011  (26 - 51)
  59.   "0123456789"                  // 0 : 110100 .... 111101  (52 - 61)
  60.   "+/";                         // + : 111110, / : 111111  (62 - 63)
  61.  
  62. //
  63. //  To determine if an ASCII char needs to be shifted.
  64. //    1 :     to be shifted
  65. //    0 : not to be shifted
  66. //
  67. CONST BOOLEAN fShiftChar[] =
  68. {
  69.   0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1,    // Null, Tab, LF, CR
  70.   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  71.   0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0,    // Space '() +,-./
  72.   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0,    // 0123456789:    ?
  73.   1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,    //  ABCDEFGHIJKLMNO
  74.   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1,    // PQRSTUVWXYZ
  75.   1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,    //  abcdefghijklmno
  76.   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1     // pqrstuvwxyz
  77. };
  78.  
  79.  
  80.  
  81.  
  82. /////////////////////////
  83. //                     //
  84. //  UTF-7 -> Unicode   //
  85. //                     //
  86. /////////////////////////
  87.  
  88. //
  89. //  Convert a Base64 char in a shifted sequence to a 6-bit portion of a
  90. //  Unicode char.
  91. //  -1 means it is not a Base64
  92. //
  93. CONST char nBitBase64[] =
  94. {
  95.   -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  96.   -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  97.   -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,   //            +   /
  98.   52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,   // 0123456789
  99.   -1,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14,   //  ABCDEFGHIJKLMNO
  100.   15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,   // PQRSTUVWXYZ
  101.   -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,   //  abcdefghijklmno
  102.   41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1    // pqrstuvwxyz
  103. };
  104.