Develop and Download Open Source Software

Browse Subversion Repository

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 9313 - (show annotations) (download) (as text)
Sun Jun 20 01:07:40 2021 UTC (2 years, 11 months ago) by zmatsuo
File MIME type: text/x-csrc
File size: 23737 byte(s)
locale設定を削除

- Cランタイムの文字コードの設定
  - 従来Cランタイムの文字コード変換関数を使用していたため必要だった
    - wctomb()
  - 現在Cランタイムの文字コード変換は使用していないため不要
    - OSのAPI WideCharToMultiByte(), MultiByteToWideChar() を使用
- setlocale()を削除
- 不要な locale.h の include を削除
- 設定ダイアログの locale 設定を削除
  - IDC_LOCALE_LABEL 削除
  - lng 内の DLG_TERM_LOCALE 削除
  - ドキュメント locale 設定個所を削除
- iniファイルのlocale読み書きを削除
- r9145
1 /*
2 * Copyright (C) 1994-1998 T. Teranishi
3 * (C) 2006- TeraTerm Project
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30 // TTCMN.DLL character code conversion
31
32 #include "teraterm.h"
33 #include "tttypes.h"
34 #include "codemap.h"
35
36 #define DllExport __declspec(dllexport)
37 #include "language.h"
38
39 // export����������
40 DllExport unsigned short ConvertUnicode(unsigned short code, const codemap_t *table, int tmax)
41 {
42 int low, mid, high;
43 unsigned short result;
44
45 low = 0;
46 high = tmax - 1;
47 result = 0; // convert error
48
49 // binary search
50 while (low < high) {
51 mid = (low + high) / 2;
52 if (table[mid].from_code < code) {
53 low = mid + 1;
54 } else {
55 high = mid;
56 }
57 }
58
59 if (table[low].from_code == code) {
60 result = table[low].to_code;
61 }
62
63 return (result);
64 }
65
66 // Japanese SJIS -> JIS
67 DllExport WORD PASCAL SJIS2JIS(WORD KCode)
68 {
69 WORD x0,x1,x2,y0;
70 BYTE b = LOBYTE(KCode);
71
72 if ((b>=0x40) && (b<=0x7f)) {
73 x0 = 0x8140;
74 y0 = 0x2121;
75 }
76 else if ((b>=0x80) && (b<=0x9e)) {
77 x0 = 0x8180;
78 y0 = 0x2160;
79 }
80 else {
81 x0 = 0x819f;
82 y0 = 0x2221;
83 }
84 if (HIBYTE(KCode) >= 0xe0) {
85 x0 = x0 + 0x5f00;
86 y0 = y0 + 0x3e00;
87 }
88 x1 = (KCode-x0) / 0x100;
89 x2 = (KCode-x0) % 0x100;
90 return (y0 + x1*0x200 + x2);
91 }
92
93 // Japanese SJIS -> EUC
94 DllExport WORD PASCAL SJIS2EUC(WORD KCode)
95 {
96 return (SJIS2JIS(KCode) | 0x8080);
97 }
98
99 // Japanese JIS -> SJIS
100 DllExport WORD PASCAL JIS2SJIS(WORD KCode)
101 {
102 WORD n1, n2, SJIS;
103
104 n1 = (KCode-0x2121) / 0x200;
105 n2 = (KCode-0x2121) % 0x200;
106
107 if (n1<=0x1e) {
108 SJIS = 0x8100 + n1*256;
109 }
110 else {
111 SJIS = 0xC100 + n1*256;
112 }
113
114 if (n2<=0x3e) {
115 return (SJIS + n2 + 0x40);
116 }
117 else if ((n2>=0x3f) && (n2<=0x5d)) {
118 return (SJIS + n2 + 0x41);
119 }
120 else {
121 return (SJIS + n2 - 0x61);
122 }
123 }
124
125 /* Russian charset conversion table by Andrey Nikiforov 19971114 */
126 /* Updated by NAGATA Shinya 20111228 */
127 // ���������������������E�L�������������������������\������
128 // �Y���������d������������������������(�I���W�i����������������������)
129 static const BYTE cpconv[4][4][128] =
130 {
131 {
132 {
133 // 1251 -> 1251 = dummy
134 /*128-143*/ 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
135 /*144-159*/ 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
136 /*160-175*/ 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
137 /*176-191*/ 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
138 /*192-207*/ 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
139 /*208-223*/ 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
140 /*224-239*/ 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
141 /*240-255*/ 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,
142 },
143 {
144 // 1251 -> KOI8-R
145 /*128-143*/ 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
146 /*144-159*/ 144,145,146,147,148,149,150,151,152,153,155,157,159,160,161,162,
147 /*160-175*/ 154,164,165,166,167,168,169,170,179,191,171,172,173,174,175,176,
148 /*176-191*/ 156,177,178,180,181,182,183,158,163,184,185,186,187,188,189,190,
149 /*192-207*/ 225,226,247,231,228,229,246,250,233,234,235,236,237,238,239,240,
150 /*208-223*/ 242,243,244,245,230,232,227,254,251,253,255,249,248,252,224,241,
151 /*224-239*/ 193,194,215,199,196,197,214,218,201,202,203,204,205,206,207,208,
152 /*240-255*/ 210,211,212,213,198,200,195,222,219,221,223,217,216,220,192,209,
153 // Non mapped character
154 //128-143 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
155 //144-159 144,145,146,147,148,149,150,151,152,153,155,157,159,160,161,162,
156 //160-175 ,164,165,166,167,168,169,170, , ,171,172,173,174,175,176,
157 //176-191 ,177,178,180,181,182,183, , ,184,185,186,187,188,189,190,
158 //192-207 , , , , , , , , , , , , , , , ,
159 //208-223 , , , , , , , , , , , , , , , ,
160 //224-239 , , , , , , , , , , , , , , , ,
161 //240-255 , , , , , , , , , , , , , , , ,
162 },
163 {
164 // 1251 -> 866
165 /*128-143*/ 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
166 /*144-159*/ 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
167 /*160-175*/ 255,246,247,208,209,210,211,212,240,213,242,214,215,216,217,244,
168 /*176-191*/ 248,218,219,220,221,222,223,250,241,252,243,249,251,253,254,245,
169 /*192-207*/ 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
170 /*208-223*/ 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
171 /*224-239*/ 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
172 /*240-255*/ 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
173 // Non mapped character
174 //128-143 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
175 //144-159 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
176 //160-175 , , ,208,209,210,211,212, ,213, ,214,215,216,217, ,
177 //176-191 ,218,219,220,221,222,223, , , , ,249,251,253,254, ,
178 //192-207 , , , , , , , , , , , , , , , ,
179 //208-223 , , , , , , , , , , , , , , , ,
180 //224-239 , , , , , , , , , , , , , , , ,
181 //240-255 , , , , , , , , , , , , , , , ,
182 },
183 {
184 // 1251 -> ISO
185 /*128-143*/ 162,163,128,243,129,130,131,132,133,134,169,135,170,172,171,175,
186 /*144-159*/ 242,136,137,138,139,140,141,142,143,144,249,145,250,252,251,255,
187 /*160-175*/ 160,174,254,168,146,147,148,253,161,149,164,150,151,173,152,167,
188 /*176-191*/ 153,154,166,246,155,156,157,158,241,240,244,159,248,165,245,247,
189 /*192-207*/ 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
190 /*208-223*/ 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
191 /*224-239*/ 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
192 /*240-255*/ 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
193 // Non mapped character
194 //128-143 , ,128, ,129,130,131,132,133,134, ,135, , , , ,
195 //144-159 ,136,137,138,139,140,141,142,143,144, ,145, , , , ,
196 //160-175 , , , ,146,147,148, , ,149, ,150,151, ,152, ,
197 //176-191 153,154, , ,155,156,157,158, , , ,159, , , , ,
198 //192-207 , , , , , , , , , , , , , , , ,
199 //208-223 , , , , , , , , , , , , , , , ,
200 //224-239 , , , , , , , , , , , , , , , ,
201 //240-255 , , , , , , , , , , , , , , , ,
202 },
203 },
204 {
205 {
206 // koi8-r -> 1251
207 /*128-143*/ 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
208 /*144-159*/ 144,145,146,147,148,149,150,151,152,153,160,154,176,155,183,156,
209 /*160-175*/ 157,158,159,184,161,162,163,164,165,166,167,170,171,172,173,174,
210 /*176-191*/ 175,177,178,168,179,180,181,182,185,186,187,188,189,190,191,169,
211 /*192-207*/ 254,224,225,246,228,229,244,227,245,232,233,234,235,236,237,238,
212 /*208-223*/ 239,255,240,241,242,243,230,226,252,251,231,248,253,249,247,250,
213 /*224-239*/ 222,192,193,214,196,197,212,195,213,200,201,202,203,204,205,206,
214 /*240-255*/ 207,223,208,209,210,211,198,194,220,219,199,216,221,217,215,218,
215 // Non mapped character
216 //128-143 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
217 //144-159 144,145,146,147,148,149,150,151,152,153, ,154, ,155, ,156,
218 //160-175 157,158,159, ,161,162,163,164,165,166,167,170,171,172,173,174,
219 //176-191 175,177,178, ,179,180,181,182,185,186,187,188,189,190,191, ,
220 //192-207 , , , , , , , , , , , , , , , ,
221 //208-223 , , , , , , , , , , , , , , , ,
222 //224-239 , , , , , , , , , , , , , , , ,
223 //240-255 , , , , , , , , , , , , , , , ,
224 },
225 {
226 // koi8-r -> koi8-r = dummy
227 /*128-143*/ 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
228 /*144-159*/ 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
229 /*160-175*/ 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
230 /*176-191*/ 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
231 /*192-207*/ 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
232 /*208-223*/ 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
233 /*224-239*/ 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
234 /*240-255*/ 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,
235 },
236 {
237 // koi8-r -> 866
238 /*128-143*/ 196,179,218,191,192,217,195,180,194,193,197,223,220,219,221,222,
239 /*144-159*/ 176,177,178,242,254,249,251,243,244,245,255,246,248,247,250,252,
240 /*160-175*/ 205,186,213,241,214,201,184,183,187,212,211,200,190,189,188,198,
241 /*176-191*/ 199,204,181,240,182,185,209,210,203,207,208,202,216,215,206,255,
242 /*192-207*/ 238,160,161,230,164,165,228,163,229,168,169,170,171,172,173,174,
243 /*208-223*/ 175,239,224,225,226,227,166,162,236,235,167,232,237,233,231,234,
244 /*224-239*/ 158,128,129,150,132,133,148,131,149,136,137,138,139,140,141,142,
245 /*240-255*/ 143,159,144,145,146,147,134,130,156,155,135,152,157,153,151,154,
246 // Non mapped character
247 //128-143 , , , , , , , , , , , , , , , ,
248 //144-159 , , ,242, , , ,243,244,245, ,246, ,247, ,252,
249 //160-175 , , , , , , , , , , , , , , , ,
250 //176-191 , , , , , , , , , , , , , , ,253,
251 //192-207 , , , , , , , , , , , , , , , ,
252 //208-223 , , , , , , , , , , , , , , , ,
253 //224-239 , , , , , , , , , , , , , , , ,
254 //240-255 , , , , , , , , , , , , , , , ,
255 },
256 {
257 // koi8-r -> ISO
258 /*128-143*/ 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
259 /*144-159*/ 144,145,146,147,148,149,150,151,152,153,160,154,155,156,157,158,
260 /*160-175*/ 159,162,163,241,164,165,166,167,168,169,170,171,172,173,174,175,
261 /*176-191*/ 240,242,243,161,244,245,246,247,248,249,250,251,252,253,254,255,
262 /*192-207*/ 238,208,209,230,212,213,228,211,229,216,217,218,219,220,221,222,
263 /*208-223*/ 223,239,224,225,226,227,214,210,236,235,215,232,237,233,231,234,
264 /*224-239*/ 206,176,177,198,180,181,196,179,197,184,185,186,187,188,189,190,
265 /*240-255*/ 191,207,192,193,194,195,182,178,204,203,183,200,205,201,199,202,
266 // Non mapped character
267 //128-143 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
268 //144-159 144,145,146,147,148,149,150,151,152,153, ,154,155,156,157,158,
269 //160-175 159,162,163, ,164,165,166,167,168,169,170,171,172,173,174,175,
270 //176-191 240,242,243, ,244,245,246,247,248,249,250,251,252,253,254,255,
271 //192-207 , , , , , , , , , , , , , , , ,
272 //208-223 , , , , , , , , , , , , , , , ,
273 //224-239 , , , , , , , , , , , , , , , ,
274 //240-255 , , , , , , , , , , , , , , , ,
275 },
276 },
277 {
278 {
279 // 866 -> 1251
280 /*128-143*/ 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
281 /*144-159*/ 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
282 /*160-175*/ 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
283 /*176-191*/ 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
284 /*192-207*/ 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
285 /*208-223*/ 160,163,165,166,167,169,171,172,173,174,177,178,179,180,181,182,
286 /*224-239*/ 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,
287 /*240-255*/ 168,184,170,186,175,191,161,162,176,187,183,188,185,189,190,160,
288 // Non mapped character
289 //128-143 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
290 //144-159 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
291 //160-175 163,164,165,166,167,169,171,172,173,174,177,178,179,180,181,182,
292 //176-191 , , , , , , , , , , , , , , , ,
293 //192-207 , , , , , , , , , , , , , , , ,
294 //208-223 , , , , , , , , , , , , , , , ,
295 //224-239 , , , , , , , , , , , , , , , ,
296 //240-255 , , , , , , , , ,187, ,188, ,189,190, ,
297 },
298 {
299 // 866 -> koi8-r
300 /*128-143*/ 225,226,247,231,228,229,246,250,233,234,235,236,237,238,239,240,
301 /*144-159*/ 242,243,244,245,230,232,227,254,251,253,255,249,248,252,224,241,
302 /*160-175*/ 193,194,215,199,196,197,214,218,201,202,203,204,205,206,207,208,
303 /*176-191*/ 144,145,146,129,135,178,180,167,166,181,161,168,174,173,172,131,
304 /*192-207*/ 132,137,136,134,128,138,175,176,171,165,187,184,177,160,190,185,
305 /*208-223*/ 186,182,183,170,169,162,164,189,188,133,130,141,140,142,143,139,
306 /*224-239*/ 210,211,212,213,198,200,195,222,219,221,223,217,216,220,192,209,
307 /*240-255*/ 179,163,147,151,152,153,155,157,156,149,158,150,159,191,148,154,
308 // Non mapped character
309 //128-143 , , , , , , , , , , , , , , , ,
310 //144-159 , , , , , , , , , , , , , , , ,
311 //160-175 , , , , , , , , , , , , , , , ,
312 //176-191 , , , , , , , , , , , , , , , ,
313 //192-207 , , , , , , , , , , , , , , , ,
314 //208-223 , , , , , , , , , , , , , , , ,
315 //224-239 , , , , , , , , , , , , , , , ,
316 //240-255 , ,147,151,152,153,155,157, , , , ,159,191, , ,
317 },
318 {
319 // 866 -> 866 = dummy
320 /*128-143*/ 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
321 /*144-159*/ 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
322 /*160-175*/ 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
323 /*176-191*/ 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
324 /*192-207*/ 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
325 /*208-223*/ 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
326 /*224-239*/ 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
327 /*240-255*/ 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,
328 },
329 {
330 // 866 -> ISO
331 /*128-143*/ 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
332 /*144-159*/ 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
333 /*160-175*/ 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
334 /*176-191*/ 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
335 /*192-207*/ 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
336 /*208-223*/ 162,163,165,166,168,169,170,171,172,173,175,240,242,243,245,246,
337 /*224-239*/ 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
338 /*240-255*/ 161,241,164,244,167,247,174,254,248,249,250,251,252,253,255,160,
339 // Non mapped character
340 //128-143 , , , , , , , , , , , , , , , ,
341 //144-159 , , , , , , , , , , , , , , , ,
342 //160-175 , , , , , , , , , , , , , , , ,
343 //176-191 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
344 //192-207 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
345 //208-223 162,163,165,166,168,169,170,171,172,173,175,240,242,243,245,246,
346 //224-239 , , , , , , , , , , , , , , , ,
347 //240-255 , , , , , , , ,248,249,250,251,252,253,255, ,
348 },
349 },
350 {
351 {
352 // ISO -> 1251
353 /*128-143*/ 130,132,133,134,135,136,137,139,145,146,147,148,149,150,151,152,
354 /*144-159*/ 153,155,164,165,166,169,171,172,174,176,177,180,181,182,183,187,
355 /*160-175*/ 160,168,128,129,170,189,178,175,163,138,140,142,141,173,161,143,
356 /*176-191*/ 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
357 /*192-207*/ 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
358 /*208-223*/ 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
359 /*224-239*/ 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,
360 /*240-255*/ 185,184,144,131,186,190,179,191,188,154,156,158,157,167,162,159,
361 // Non mapped character
362 //128-143 130,132,133,134,135,136,137,139,145,146,147,148,149,150,151,152,
363 //144-159 153,155,164,165,166,169,171,172,174,176,177,180,181,182,183,187,
364 //160-175 , , , , , , , , , , , , , , , ,
365 //176-191 , , , , , , , , , , , , , , , ,
366 //192-207 , , , , , , , , , , , , , , , ,
367 //208-223 , , , , , , , , , , , , , , , ,
368 //224-239 , , , , , , , , , , , , , , , ,
369 //240-255 , , , , , , , , , , , , , , , ,
370 },
371 {
372 // ISO -> koi8-r
373 /*128-143*/ 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
374 /*144-159*/ 144,145,146,147,148,149,150,151,152,153,155,156,157,158,159,160,
375 /*160-175*/ 154,179,161,162,164,165,166,167,168,169,170,171,172,173,174,175,
376 /*176-191*/ 225,226,247,231,228,229,246,250,233,234,235,236,237,238,239,240,
377 /*192-207*/ 242,243,244,245,230,232,227,254,251,253,255,249,248,252,224,241,
378 /*208-223*/ 193,194,215,199,196,197,214,218,201,202,203,204,205,206,207,208,
379 /*224-239*/ 210,211,212,213,198,200,195,222,219,221,223,217,216,220,192,209,
380 /*240-255*/ 176,163,177,178,180,181,182,183,184,185,186,187,188,189,190,191,
381 // Non mapped character
382 //128-143 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
383 //144-159 144,145,146,147,148,149,150,151,152,153,155,156,157,158,159,160,
384 //160-175 , ,161,162,164,165,166,167,168,169,170,171,172,173,174,175,
385 //176-191 , , , , , , , , , , , , , , , ,
386 //192-207 , , , , , , , , , , , , , , , ,
387 //208-223 , , , , , , , , , , , , , , , ,
388 //224-239 , , , , , , , , , , , , , , , ,
389 //240-255 176, ,177,178,180,181,182,183,184,185,186,187,188,189,190,191,
390 },
391 {
392 // ISO -> 866
393 /*128-143*/ 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
394 /*144-159*/ 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
395 /*160-175*/ 255,240,208,209,242,210,211,244,212,213,214,215,216,217,246,218,
396 /*176-191*/ 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
397 /*192-207*/ 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
398 /*208-223*/ 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
399 /*224-239*/ 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
400 /*240-255*/ 219,241,220,221,243,222,223,245,248,249,250,251,252,253,247,254,
401 // Non mapped character
402 //128-143 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
403 //144-159 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
404 //160-175 , ,208,209, ,210,211, ,212,213,214,215,216,217, ,218,
405 //176-191 , , , , , , , , , , , , , , , ,
406 //192-207 , , , , , , , , , , , , , , , ,
407 //208-223 , , , , , , , , , , , , , , , ,
408 //224-239 , , , , , , , , , , , , , , , ,
409 //240-255 219, ,220,221, ,222,223, ,248,249,250,251,252,253, ,254,
410 },
411 {
412 // iso -> iso = dummy
413 /*128-143*/ 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
414 /*144-159*/ 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
415 /*160-175*/ 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
416 /*176-191*/ 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
417 /*192-207*/ 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
418 /*208-223*/ 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
419 /*224-239*/ 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
420 /*240-255*/ 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255
421 }
422 }
423 };
424
425 static int RussIdToIndex(int id)
426 {
427 return
428 id == IdWindows ? 0:
429 id == IdKOI8 ? 1:
430 id == Id866 ? 2:
431 /*id == IdISO ? */ 3;
432 }
433
434 // Russian character set conversion
435 DllExport BYTE PASCAL RussConv(int cin, int cout, BYTE b)
436 // cin: input character set (IdWindows/IdKOI8/Id866/IdISO)
437 // cin: output character set (IdWindows/IdKOI8/Id866/IdISO)
438 {
439 if (b<128) {
440 return b;
441 }
442 cin = RussIdToIndex(cin);
443 cout = RussIdToIndex(cout);
444 return cpconv[cin][cout][b-128];
445 }
446
447 // Russian character set conversion for a character string
448 DllExport void PASCAL RussConvStr(int cin, int cout, PCHAR Str, int count)
449 // cin: input character set (IdWindows/IdKOI8/Id866/IdISO)
450 // cin: output character set (IdWindows/IdKOI8/Id866/IdISO)
451 {
452 int i;
453
454 if (count<=0) {
455 return;
456 }
457
458 for (i=0; i<=count-1; i++) {
459 if ((BYTE)Str[i]>=128) {
460 Str[i] = (char)cpconv[cin-1][cout-1][(BYTE)Str[i]-128];
461 }
462 }
463 }

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