Open-Source-Software-Entwicklung und Downloads

Browse Subversion Repository

Diff of /trunk/teraterm/ttpcmn/language.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3226 by maya, Tue Mar 24 09:37:20 2009 UTC revision 3227 by maya, Tue Mar 24 15:10:33 2009 UTC
# Line 1  Line 1 
1  /* Tera Term  /* Tera Term
2   Copyright(C) 1994-1998 T. Teranishi   Copyright(C) 1994-1998 T. Teranishi
3   All rights reserved. */   All rights reserved. */
4    
5  // TTCMN.DLL character code conversion  // TTCMN.DLL character code conversion
6    
7  #include "teraterm.h"  #include "teraterm.h"
8  #include "tttypes.h"  #include "tttypes.h"
9  #include <mbstring.h>  #include <mbstring.h>
10  #include <locale.h>  #include <locale.h>
11    
12  #include "sjis2uni.map"  #include "sjis2uni.map"
13    
14  unsigned short ConvertUnicode(unsigned short code, codemap_t *table, int tmax)  unsigned short ConvertUnicode(unsigned short code, codemap_t *table, int tmax)
15  {  {
16          int low, mid, high;          int low, mid, high;
17          unsigned short result;          unsigned short result;
18    
19          low = 0;          low = 0;
20          high = tmax - 1;          high = tmax - 1;
21          result = 0; // convert error          result = 0; // convert error
22    
23          // binary search          // binary search
24          while (low < high) {          while (low < high) {
25                  mid = (low + high) / 2;                  mid = (low + high) / 2;
26                  if (table[mid].from_code < code) {                  if (table[mid].from_code < code) {
27                          low = mid + 1;                          low = mid + 1;
28                  } else {                  } else {
29                          high = mid;                          high = mid;
30                  }                  }
31          }          }
32    
33          if (table[low].from_code == code) {          if (table[low].from_code == code) {
34                  result = table[low].to_code;                  result = table[low].to_code;
35          }          }
36    
37          return (result);          return (result);
38  }  }
39    
40  unsigned int FAR PASCAL SJIS2UTF8(WORD KCode, int *byte, char *locale)  unsigned int FAR PASCAL SJIS2UTF8(WORD KCode, int *byte, char *locale)
41  {  {
42          wchar_t wchar;          wchar_t wchar;
43          int ret;          int ret;
44          unsigned int code = KCode;          unsigned int code = KCode;
45          unsigned int c, c1, c2, c3;          unsigned int c, c1, c2, c3;
46          unsigned char *ptr, buf[3];          unsigned char *ptr, buf[3];
47          unsigned short cset;          unsigned short cset;
48    
49          *byte = 2;          *byte = 2;
50    
51          // CP932からUTF-16LEへ変換する          // CP932からUTF-16LEへ変換する
52          setlocale(LC_ALL, locale);          setlocale(LC_ALL, locale);
53    
54          buf[0] = KCode >> 8;          buf[0] = KCode >> 8;
55          buf[1] = KCode & 0xff;          buf[1] = KCode & 0xff;
56          buf[2] = '\0';          buf[2] = '\0';
57          ret = mbtowc(&wchar, buf, 2);          ret = mbtowc(&wchar, buf, 2);
58          if (ret <= 0) { // 変換失敗          if (ret <= 0) { // 変換失敗
59                  cset = 0;                  cset = 0;
60                  if (_stricmp(locale, DEFAULT_LOCALE) == 0) {                  if (_stricmp(locale, DEFAULT_LOCALE) == 0) {
61                          cset = ConvertUnicode(KCode, mapSJISToUnicode, sizeof(mapSJISToUnicode)/sizeof(mapSJISToUnicode[0]));                          cset = ConvertUnicode(KCode, mapSJISToUnicode, sizeof(mapSJISToUnicode)/sizeof(mapSJISToUnicode[0]));
62                  }                  }
63                  if (cset == 0) {                  if (cset == 0) {
64                          goto error;                          goto error;
65                  } else {                  } else {
66                          c = cset;                          c = cset;
67                  }                  }
68          } else {          } else {
69                  ptr = (unsigned char *)&wchar;                  ptr = (unsigned char *)&wchar;
70                  if (ret >= 2) {                  if (ret >= 2) {
71                          c = ((ptr[1] << 8) | ptr[0]);                          c = ((ptr[1] << 8) | ptr[0]);
72                  } else {                  } else {
73                          c = '?';                          c = '?';
74                  }                  }
75          }          }
76    
77          // UTF-16LEからUTF-8へ変換する          // UTF-16LEからUTF-8へ変換する
78          if (0x00000000 <= c && c <= 0x0000007f) {          if (0x00000000 <= c && c <= 0x0000007f) {
79                  code = (c & 0xff);                  code = (c & 0xff);
80                  *byte = 1;                  *byte = 1;
81    
82          } else if (0x00000080 <= c && c <= 0x000007ff) {          } else if (0x00000080 <= c && c <= 0x000007ff) {
83                  c1 = ((c >> 6) & 0x1f) | 0xc0;                  c1 = ((c >> 6) & 0x1f) | 0xc0;
84                  c2 = (c & 0x3f) | 0x80;                  c2 = (c & 0x3f) | 0x80;
85                  code = (c1 << 8) | c2;                  code = (c1 << 8) | c2;
86                  *byte = 2;                  *byte = 2;
87    
88          } else if (0x00000800 <= c && c <= 0x0000ffff) {          } else if (0x00000800 <= c && c <= 0x0000ffff) {
89                  c1 = ((c >> 12) & 0xf) | 0xe0;                  c1 = ((c >> 12) & 0xf) | 0xe0;
90                  c2 = ((c >> 6) & 0x3f) | 0x80;                  c2 = ((c >> 6) & 0x3f) | 0x80;
91                  c3 = ((c) & 0x3f) | 0x80;                  c3 = ((c) & 0x3f) | 0x80;
92                  code = (c1 << 16) | (c2 << 8) | c3;                  code = (c1 << 16) | (c2 << 8) | c3;
93                  *byte = 3;                  *byte = 3;
94          }          }
95    
96  error:  error:
97    
98          return (code);          return (code);
99  }  }
100    
101    
102  // Japanese SJIS -> JIS  // Japanese SJIS -> JIS
103  WORD FAR PASCAL SJIS2JIS(WORD KCode)  WORD FAR PASCAL SJIS2JIS(WORD KCode)
104  {  {
105          WORD x0,x1,x2,y0;          WORD x0,x1,x2,y0;
106          BYTE b = LOBYTE(KCode);          BYTE b = LOBYTE(KCode);
107    
108          if ((b>=0x40) && (b<=0x7f)) {          if ((b>=0x40) && (b<=0x7f)) {
109                  x0 = 0x8140;                  x0 = 0x8140;
110                  y0 = 0x2121;                  y0 = 0x2121;
111          }          }
112          else if ((b>=0x80) && (b<=0x9e)) {          else if ((b>=0x80) && (b<=0x9e)) {
113                  x0 = 0x8180;                  x0 = 0x8180;
114                  y0 = 0x2160;                  y0 = 0x2160;
115          }          }
116          else {          else {
117                  x0 = 0x819f;                  x0 = 0x819f;
118                  y0 = 0x2221;                  y0 = 0x2221;
119          }          }
120          if (HIBYTE(KCode) >= 0xe0) {          if (HIBYTE(KCode) >= 0xe0) {
121                  x0 = x0 + 0x5f00;                  x0 = x0 + 0x5f00;
122                  y0 = y0 + 0x3e00;                  y0 = y0 + 0x3e00;
123          }          }
124          x1 = (KCode-x0) / 0x100;          x1 = (KCode-x0) / 0x100;
125          x2 = (KCode-x0) % 0x100;          x2 = (KCode-x0) % 0x100;
126          return (y0 + x1*0x200 + x2);          return (y0 + x1*0x200 + x2);
127  }  }
128    
129  // Japanese SJIS -> EUC  // Japanese SJIS -> EUC
130  WORD FAR PASCAL SJIS2EUC(WORD KCode)  WORD FAR PASCAL SJIS2EUC(WORD KCode)
131  {  {
132          return (SJIS2JIS(KCode) | 0x8080);          return (SJIS2JIS(KCode) | 0x8080);
133  }  }
134    
135  // Japanese JIS -> SJIS  // Japanese JIS -> SJIS
136  WORD FAR PASCAL JIS2SJIS(WORD KCode)  WORD FAR PASCAL JIS2SJIS(WORD KCode)
137  {  {
138          WORD n1, n2, SJIS;          WORD n1, n2, SJIS;
139    
140          n1 = (KCode-0x2121) / 0x200;          n1 = (KCode-0x2121) / 0x200;
141          n2 = (KCode-0x2121) % 0x200;          n2 = (KCode-0x2121) % 0x200;
142    
143          if (n1<=0x1e)          if (n1<=0x1e)
144                  SJIS = 0x8100 + n1*256;                  SJIS = 0x8100 + n1*256;
145          else          else
146                  SJIS = 0xC100 + n1*256;                  SJIS = 0xC100 + n1*256;
147    
148          if (n2<=0x3e)          if (n2<=0x3e)
149                  return (SJIS + n2 + 0x40);                  return (SJIS + n2 + 0x40);
150          else if ((n2>=0x3f) && (n2<=0x5d))          else if ((n2>=0x3f) && (n2<=0x5d))
151                  return (SJIS + n2 + 0x41);                  return (SJIS + n2 + 0x41);
152          else          else
153                  return (SJIS + n2 - 0x61);                  return (SJIS + n2 - 0x61);
154  }  }
155    
156  /* Russian charset conversion table by Andrey Nikiforov 19971114 */  /* Russian charset conversion table by Andrey Nikiforov 19971114 */
157  static BYTE cpconv[4][4][128] =  static BYTE cpconv[4][4][128] =
158  {  {
159  // 1251 -> 1251 = dummy  // 1251 -> 1251 = dummy
160  /*128-143*/  128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,  /*128-143*/  128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
161  /*144-159*/  144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,  /*144-159*/  144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
162  /*160-175*/  160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,  /*160-175*/  160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
163  /*176-191*/  176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,  /*176-191*/  176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
164  /*192-207*/  192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,  /*192-207*/  192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
165  /*208-223*/  208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,  /*208-223*/  208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
166  /*224-239*/  224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,  /*224-239*/  224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
167  /*240-255*/  240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,  /*240-255*/  240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,
168  // 1251 -> KOI8-R  // 1251 -> KOI8-R
169  /*128-143*/  128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,  /*128-143*/  128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
170  /*144-159*/  144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,  /*144-159*/  144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
171  /*160-175*/  160,161,162,164,165,166,167,168,179,169,170,171,172,173,174,175,  /*160-175*/  160,161,162,164,165,166,167,168,179,169,170,171,172,173,174,175,
172  /*176-191*/  176,177,178,180,181,182,183,184,163,185,186,187,188,189,190,191,  /*176-191*/  176,177,178,180,181,182,183,184,163,185,186,187,188,189,190,191,
173  /*192-207*/  225,226,247,231,228,229,246,250,233,234,235,236,237,238,239,240,  /*192-207*/  225,226,247,231,228,229,246,250,233,234,235,236,237,238,239,240,
174  /*208-223*/  242,243,244,245,230,232,227,254,251,253,255,249,248,252,224,241,  /*208-223*/  242,243,244,245,230,232,227,254,251,253,255,249,248,252,224,241,
175  /*224-239*/  193,194,215,199,196,197,214,218,201,202,203,204,205,206,207,208,  /*224-239*/  193,194,215,199,196,197,214,218,201,202,203,204,205,206,207,208,
176  /*240-255*/  210,211,212,213,198,200,195,222,219,221,223,217,216,220,192,209,  /*240-255*/  210,211,212,213,198,200,195,222,219,221,223,217,216,220,192,209,
177  // 1251 -> 866                              ,                       ,  // 1251 -> 866                              ,                       ,
178  /*128-143*/  176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,  /*128-143*/  176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
179  /*144-159*/  192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,  /*144-159*/  192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
180  /*160-175*/  208,246,247,209,253,210,211,212,240,213,242,214,215,216,217,244,  /*160-175*/  208,246,247,209,253,210,211,212,240,213,242,214,215,216,217,244,
181  /*176-191*/  248,218,219,220,221,222,223,249,241,252,243,250,251,254,255,245,  /*176-191*/  248,218,219,220,221,222,223,249,241,252,243,250,251,254,255,245,
182  /*192-207*/  128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,  /*192-207*/  128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
183  /*208-223*/  144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,  /*208-223*/  144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
184  /*224-239*/  160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,  /*224-239*/  160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
185  /*240-255*/  224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,  /*240-255*/  224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
186  // 1251 -> ISO                          ,                   ,  // 1251 -> ISO                          ,                   ,
187  /*128-143*/  162,163,128,243,129,130,131,132,133,134,169,135,170,172,171,175,  /*128-143*/  162,163,128,243,129,130,131,132,133,134,169,135,170,172,171,175,
188  /*144-159*/  242,136,137,138,139,140,141,142,143,144,249,145,250,252,251,255,  /*144-159*/  242,136,137,138,139,140,141,142,143,144,249,145,250,252,251,255,
189  /*160-175*/  146,174,254,168,147,148,149,150,161,151,164,152,153,154,155,167,  /*160-175*/  146,174,254,168,147,148,149,150,161,151,164,152,153,154,155,167,
190  /*176-191*/  156,157,166,246,158,159,160,173,241,240,244,253,248,165,245,247,  /*176-191*/  156,157,166,246,158,159,160,173,241,240,244,253,248,165,245,247,
191  /*192-207*/  176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,  /*192-207*/  176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
192  /*208-223*/  192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,  /*208-223*/  192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
193  /*224-239*/  208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,  /*224-239*/  208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
194  /*240-255*/  224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,  /*240-255*/  224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
195  // koi8-r -> 1251                       ,                   ,  // koi8-r -> 1251                       ,                   ,
196  /*128-143*/  128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,  /*128-143*/  128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
197  /*144-159*/  144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,  /*144-159*/  144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
198  /*160-175*/  160,161,162,184,163,164,165,166,167,169,170,171,172,173,174,175,  /*160-175*/  160,161,162,184,163,164,165,166,167,169,170,171,172,173,174,175,
199  /*176-191*/  176,177,178,168,179,180,181,182,183,185,186,187,188,189,190,191,  /*176-191*/  176,177,178,168,179,180,181,182,183,185,186,187,188,189,190,191,
200  /*192-207*/  254,224,225,246,228,229,244,227,245,232,233,234,235,236,237,238,  /*192-207*/  254,224,225,246,228,229,244,227,245,232,233,234,235,236,237,238,
201  /*208-223*/  239,255,240,241,242,243,230,226,252,251,231,248,253,249,247,250,  /*208-223*/  239,255,240,241,242,243,230,226,252,251,231,248,253,249,247,250,
202  /*224-239*/  222,192,193,214,196,197,212,195,213,200,201,202,203,204,205,206,  /*224-239*/  222,192,193,214,196,197,212,195,213,200,201,202,203,204,205,206,
203  /*240-255*/  207,223,208,209,210,211,198,194,220,219,199,216,221,217,215,218,  /*240-255*/  207,223,208,209,210,211,198,194,220,219,199,216,221,217,215,218,
204  // koi8-r -> koi8-r = dummy    // koi8-r -> koi8-r = dummy  
205  /*128-143*/  128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,  /*128-143*/  128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
206  /*144-159*/  144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,  /*144-159*/  144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
207  /*160-175*/  160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,  /*160-175*/  160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
208  /*176-191*/  176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,  /*176-191*/  176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
209  /*192-207*/  192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,  /*192-207*/  192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
210  /*208-223*/  208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,  /*208-223*/  208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
211  /*224-239*/  224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,  /*224-239*/  224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
212  /*240-255*/  240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,  /*240-255*/  240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,
213  // koi8-r -> 866  // koi8-r -> 866
214  /*128-143*/  176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,  /*128-143*/  176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
215  /*144-159*/  192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,  /*144-159*/  192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
216  /*160-175*/  208,209,210,241,211,212,213,214,215,216,217,218,219,220,221,222,  /*160-175*/  208,209,210,241,211,212,213,214,215,216,217,218,219,220,221,222,
217  /*176-191*/  223,242,243,240,244,245,246,247,248,249,250,251,252,253,254,255,  /*176-191*/  223,242,243,240,244,245,246,247,248,249,250,251,252,253,254,255,
218  /*192-207*/  238,160,161,230,164,165,228,163,229,168,169,170,171,172,173,174,  /*192-207*/  238,160,161,230,164,165,228,163,229,168,169,170,171,172,173,174,
219  /*208-223*/  175,239,224,225,226,227,166,162,236,235,167,232,237,233,231,234,  /*208-223*/  175,239,224,225,226,227,166,162,236,235,167,232,237,233,231,234,
220  /*224-239*/  158,128,129,150,132,133,148,131,149,136,137,138,139,140,141,142,  /*224-239*/  158,128,129,150,132,133,148,131,149,136,137,138,139,140,141,142,
221  /*240-255*/  143,159,144,145,146,147,134,130,156,155,135,152,157,153,151,154,  /*240-255*/  143,159,144,145,146,147,134,130,156,155,135,152,157,153,151,154,
222  // koi8-r -> ISO                        ,       ,   ,   ,   ,   ,   ,   ,  // koi8-r -> ISO                        ,       ,   ,   ,   ,   ,   ,   ,
223  /*128-143*/  128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,  /*128-143*/  128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
224  /*144-159*/  144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,  /*144-159*/  144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
225  /*160-175*/  160,162,163,241,164,165,166,167,168,169,170,171,172,173,174,175,  /*160-175*/  160,162,163,241,164,165,166,167,168,169,170,171,172,173,174,175,
226  /*176-191*/  240,242,243,161,244,245,246,247,248,249,250,251,252,253,254,255,  /*176-191*/  240,242,243,161,244,245,246,247,248,249,250,251,252,253,254,255,
227  /*192-207*/  238,208,209,230,212,213,228,211,229,216,217,218,219,220,221,222,  /*192-207*/  238,208,209,230,212,213,228,211,229,216,217,218,219,220,221,222,
228  /*208-223*/  223,239,224,225,226,227,214,210,236,235,215,232,237,233,231,234,  /*208-223*/  223,239,224,225,226,227,214,210,236,235,215,232,237,233,231,234,
229  /*224-239*/  206,176,177,198,180,181,196,179,197,184,185,186,187,188,189,190,  /*224-239*/  206,176,177,198,180,181,196,179,197,184,185,186,187,188,189,190,
230  /*240-255*/  191,207,192,193,194,195,182,178,204,203,183,200,205,201,199,202,  /*240-255*/  191,207,192,193,194,195,182,178,204,203,183,200,205,201,199,202,
231  // 866 -> 1251                                              ,       ,  // 866 -> 1251                                              ,       ,
232  /*128-143*/  192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,  /*128-143*/  192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
233  /*144-159*/  208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,  /*144-159*/  208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
234  /*160-175*/  224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,  /*160-175*/  224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
235  /*176-191*/  128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,  /*176-191*/  128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
236  /*192-207*/  144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,  /*192-207*/  144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
237  /*208-223*/  160,163,165,166,167,169,171,172,173,174,177,178,179,180,181,182,  /*208-223*/  160,163,165,166,167,169,171,172,173,174,177,178,179,180,181,182,
238  /*224-239*/  240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,  /*224-239*/  240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,
239  /*240-255*/  168,184,170,186,175,191,161,162,176,183,187,188,185,164,189,190,  /*240-255*/  168,184,170,186,175,191,161,162,176,183,187,188,185,164,189,190,
240  // 866 -> koi8-r                        ,   ,                       ,  // 866 -> koi8-r                        ,   ,                       ,
241  /*128-143*/  225,226,247,231,228,229,246,250,233,234,235,236,237,238,239,240,  /*128-143*/  225,226,247,231,228,229,246,250,233,234,235,236,237,238,239,240,
242  /*144-159*/  242,243,244,245,230,232,227,254,251,253,255,249,248,252,224,241,  /*144-159*/  242,243,244,245,230,232,227,254,251,253,255,249,248,252,224,241,
243  /*160-175*/  193,194,215,199,196,197,214,218,201,202,203,204,205,206,207,208,  /*160-175*/  193,194,215,199,196,197,214,218,201,202,203,204,205,206,207,208,
244  /*176-191*/  128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,  /*176-191*/  128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
245  /*192-207*/  144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,  /*192-207*/  144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
246  /*208-223*/  160,161,162,164,165,166,167,168,169,170,171,172,173,174,175,176,  /*208-223*/  160,161,162,164,165,166,167,168,169,170,171,172,173,174,175,176,
247  /*224-239*/  210,211,212,213,198,200,195,222,219,221,223,217,216,220,192,209,  /*224-239*/  210,211,212,213,198,200,195,222,219,221,223,217,216,220,192,209,
248  /*240-255*/  179,163,177,178,180,181,182,183,184,185,186,187,188,189,190,191,  /*240-255*/  179,163,177,178,180,181,182,183,184,185,186,187,188,189,190,191,
249  // 866 -> 866 = dummy                   ,                           ,          // 866 -> 866 = dummy                   ,                           ,        
250  /*128-143*/  128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,  /*128-143*/  128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
251  /*144-159*/  144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,  /*144-159*/  144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
252  /*160-175*/  160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,  /*160-175*/  160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
253  /*176-191*/  176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,  /*176-191*/  176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
254  /*192-207*/  192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,  /*192-207*/  192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
255  /*208-223*/  208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,  /*208-223*/  208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
256  /*224-239*/  224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,  /*224-239*/  224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
257  /*240-255*/  240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,  /*240-255*/  240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,
258  // 866 -> ISO  // 866 -> ISO
259  /*128-143*/  176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,  /*128-143*/  176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
260  /*144-159*/  192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,  /*144-159*/  192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
261  /*160-175*/  208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,  /*160-175*/  208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
262  /*176-191*/  128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,  /*176-191*/  128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
263  /*192-207*/  144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,  /*192-207*/  144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
264  /*208-223*/  160,162,163,165,166,168,169,170,171,172,173,175,240,242,243,245,  /*208-223*/  160,162,163,165,166,168,169,170,171,172,173,175,240,242,243,245,
265  /*224-239*/  224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,  /*224-239*/  224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
266  /*240-255*/  161,241,164,244,167,247,174,254,246,248,249,250,251,252,253,255,  /*240-255*/  161,241,164,244,167,247,174,254,246,248,249,250,251,252,253,255,
267  // ISO -> 1251                                                           ,  ,  // ISO -> 1251                                                           ,  ,
268  /*128-143*/  130,132,133,134,135,136,137,139,145,146,147,148,149,150,151,152,  /*128-143*/  130,132,133,134,135,136,137,139,145,146,147,148,149,150,151,152,
269  /*144-159*/  153,155,160,164,165,166,167,169,171,172,173,174,176,177,180,181,  /*144-159*/  153,155,160,164,165,166,167,169,171,172,173,174,176,177,180,181,
270  /*160-175*/  182,168,128,129,170,189,178,175,163,138,140,142,141,183,161,143,  /*160-175*/  182,168,128,129,170,189,178,175,163,138,140,142,141,183,161,143,
271  /*176-191*/  192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,  /*176-191*/  192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
272  /*192-207*/  208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,  /*192-207*/  208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
273  /*208-223*/  224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,  /*208-223*/  224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
274  /*224-239*/  240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,  /*224-239*/  240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,
275  /*240-255*/  185,184,144,131,186,190,179,191,188,154,156,158,157,187,162,159,  /*240-255*/  185,184,144,131,186,190,179,191,188,154,156,158,157,187,162,159,
276  // ISO -> koi8-r                        ,           ,                   ,   ,  // ISO -> koi8-r                        ,           ,                   ,   ,
277  /*128-143*/  128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,  /*128-143*/  128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
278  /*144-159*/  144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,  /*144-159*/  144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
279  /*160-175*/  160,179,161,162,164,165,166,167,168,169,170,171,172,173,174,175,  /*160-175*/  160,179,161,162,164,165,166,167,168,169,170,171,172,173,174,175,
280  /*176-191*/  225,226,247,231,228,229,246,250,233,234,235,236,237,238,239,240,  /*176-191*/  225,226,247,231,228,229,246,250,233,234,235,236,237,238,239,240,
281  /*192-207*/  242,243,244,245,230,232,227,254,251,253,255,249,248,252,224,241,  /*192-207*/  242,243,244,245,230,232,227,254,251,253,255,249,248,252,224,241,
282  /*208-223*/  193,194,215,199,196,197,214,218,201,202,203,204,205,206,207,208,  /*208-223*/  193,194,215,199,196,197,214,218,201,202,203,204,205,206,207,208,
283  /*224-239*/  210,211,212,213,198,200,195,222,219,221,223,217,216,220,192,209,  /*224-239*/  210,211,212,213,198,200,195,222,219,221,223,217,216,220,192,209,
284  /*240-255*/  176,163,177,178,180,181,182,183,184,185,186,187,188,189,190,191,  /*240-255*/  176,163,177,178,180,181,182,183,184,185,186,187,188,189,190,191,
285  // ISO -> 866                           ,           ,   ,                    ,  // ISO -> 866                           ,           ,   ,                    ,
286  /*128-143*/  176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,  /*128-143*/  176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
287  /*144-159*/  192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,  /*144-159*/  192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
288  /*160-175*/  208,240,209,210,242,211,212,244,213,214,215,216,217,218,246,219,  /*160-175*/  208,240,209,210,242,211,212,244,213,214,215,216,217,218,246,219,
289  /*176-191*/  128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,  /*176-191*/  128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
290  /*192-207*/  144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,  /*192-207*/  144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
291  /*208-223*/  160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,  /*208-223*/  160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
292  /*224-239*/  224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,  /*224-239*/  224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
293  /*240-255*/  220,241,221,222,243,223,248,245,249,250,251,252,253,254,247,255,  /*240-255*/  220,241,221,222,243,223,248,245,249,250,251,252,253,254,247,255,
294  // iso -> iso = dummy                                   ,    ,              ,  // iso -> iso = dummy                                   ,    ,              ,
295  /*128-143*/  128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,  /*128-143*/  128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
296  /*144-159*/  144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,  /*144-159*/  144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
297  /*160-175*/  160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,  /*160-175*/  160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
298  /*176-191*/  176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,  /*176-191*/  176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
299  /*192-207*/  192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,  /*192-207*/  192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
300  /*208-223*/  208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,  /*208-223*/  208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
301  /*224-239*/  224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,  /*224-239*/  224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
302  /*240-255*/  240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255  /*240-255*/  240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255
303  };  };
304    
305  // Russian character set conversion  // Russian character set conversion
306  BYTE FAR PASCAL RussConv(int cin, int cout, BYTE b)  BYTE FAR PASCAL RussConv(int cin, int cout, BYTE b)
307  // cin: input character set (IdWindows/IdKOI8/Id866/IdISO)  // cin: input character set (IdWindows/IdKOI8/Id866/IdISO)
308  // cin: output character set (IdWindows/IdKOI8/Id866/IdISO)  // cin: output character set (IdWindows/IdKOI8/Id866/IdISO)
309  {  {
310          if (b<128)          if (b<128)
311                  return b;                  return b;
312          return cpconv[cin-1][cout-1][b-128];          return cpconv[cin-1][cout-1][b-128];
313  }  }
314    
315  // Russian character set conversion for a character string  // Russian character set conversion for a character string
316  void FAR PASCAL RussConvStr(int cin, int cout, PCHAR Str, int count)  void FAR PASCAL RussConvStr(int cin, int cout, PCHAR Str, int count)
317  // cin: input character set (IdWindows/IdKOI8/Id866/IdISO)  // cin: input character set (IdWindows/IdKOI8/Id866/IdISO)
318  // cin: output character set (IdWindows/IdKOI8/Id866/IdISO)  // cin: output character set (IdWindows/IdKOI8/Id866/IdISO)
319  {  {
320          int i;          int i;
321    
322          if (count<=0)          if (count<=0)
323                  return;                  return;
324    
325          for (i=0; i<=count-1; i++)          for (i=0; i<=count-1; i++)
326                  if ((BYTE)Str[i]>=128)                  if ((BYTE)Str[i]>=128)
327                          Str[i] = (char)cpconv[cin-1][cout-1][(BYTE)Str[i]-128];                          Str[i] = (char)cpconv[cin-1][cout-1][(BYTE)Str[i]-128];
328  }  }

Legend:
Removed from v.3226  
changed lines
  Added in v.3227

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26