1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
|
/*++
Copyright (c) 1989 Microsoft Corporation
Module Name:
nls.c
Abstract:
This module contains the support for NLS
Author:
Michael Jarus (mjarus) 28-Jul-1992
Environment:
User Mode Only
Revision History:
--*/
#include <stdio.h>
#include <string.h>
#define WIN32_ONLY
#include "os2ses.h"
#include "os2nls.h"
#include "trans.h"
#include "os2win.h"
ULONG
NlsCountryToLoacle(
IN ULONG NlsCountryCode,
IN LCID *NlsLocaleID
);
#if DBG
BYTE NLSInitStr[] = "NLSInit";
#endif
DWORD
NLSInit()
{
ULONG i, Win32LCID, CurrentVioCP, CurrentKbdCP;
USHORT LocaleLang;
/*
* Get Current Console CP
*/
CurrentVioCP = (ULONG)Or2WinGetConsoleOutputCP(
#if DBG
NLSInitStr
#endif
);
CurrentKbdCP = (ULONG)Or2WinGetConsoleCP(
#if DBG
NLSInitStr
#endif
);
#ifdef DBCS
// MSKK Jun.16.1993 V-AkihiS
SesGrp->DosCP = (ULONG)Or2WinGetConsoleCP(
#if DBG
NLSInitStr
#endif
);
#endif
Win32LCID = (ULONG)Or2WinGetThreadLocale(
#if DBG
NLSInitStr
#endif
);
if ((Win32LCID != SesGrp->Win32LCID) &&
(SesGrp->Os2srvUseRegisterInfo ||
(Win32LCID != SesGrp->Os2ssLCID)))
{
/*
* Inherit NLS definitions from Win32
* We get here if the LOCALE inherit by Os2srv is different
* from the LOCALE inherit by the os2.exe
* We handle only COUNTRY and LOCALE parms. (not CP, which are equal)
*/
//SesGrp->Win32OEMCP = GetOEMCP();
//SesGrp->Win32ACP = GetACP();
SesGrp->Win32LCID = Win32LCID;
SesGrp->Win32LANGID = (ULONG)Or2WinGetUserDefaultLangID(
#if DBG
NLSInitStr
#endif
);
Or2NlsGetCountryFromLocale((LCID)SesGrp->Win32LCID, &SesGrp->Win32CountryCode);
//SesGrp->PrimaryCP = SesGrp->Win32OEMCP;
SesGrp->CountryCode = SesGrp->Win32CountryCode;
SesGrp->Os2ssLCID = SesGrp->Win32LCID;
#ifdef JAPAN
// MSKK Nov.04.1992 V-AkihiS
SesGrp->LanguageID = LANG_JAPANESE;
#else
SesGrp->LanguageID = LANG_ENGLISH;
#endif
LocaleLang = PRIMARYLANGID(LANGIDFROMLCID(Win32LCID));
for ( i = 0 ; Or2NlsLangIdTable[i] ; i++ )
{
if (Or2NlsLangIdTable[i] == LocaleLang)
{
SesGrp->LanguageID = Or2NlsLangIdTable[i];
break;
}
}
/*
* Get CtryInfo, DBCSEv, CollateTable, CaseMapTable for the default
* (We don't have to update CP-depent parms since CP,s are equal)
*/
Or2NlsGetCtryInfo(
(LCID)SesGrp->Os2ssLCID,
(UINT)SesGrp->PrimaryCP,
(PCOUNTRYINFO)&SesGrp->CountryInfo
);
#if DBG
/*
* Dump specail NLS info to the debugger
*/
IF_OD2_DEBUG( NLS )
{
KdPrint(("OS2SES(Os2-NLS): "));
}
#endif
//SesGrp->VioCP = SesGrp->KbdCP = SesGrp->DosCP = SesGrp->PrimaryCP;
} else
{
if (Win32LCID != SesGrp->Win32LCID)
{
Or2WinSetThreadLocale(
#if DBG
NLSInitStr,
#endif
(LCID)SesGrp->Win32LCID
);
}
#if DBG
/*
* Dump specail NLS info to the debugger
*/
IF_OD2_DEBUG( NLS )
{
KdPrint(("OS2SES(Os2-NLS): using OS2SRV NLS definitions\n "));
}
#endif
}
#if DBG
/*
* Dump all NLS info to the debugger
*/
IF_OD2_DEBUG( NLS )
{
KdPrint(("CP %lu (%lu,%lu), Country %lu, LangID %lx ,LCID %lx\n",
SesGrp->DosCP, SesGrp->PrimaryCP, SesGrp->SecondaryCP,
SesGrp->CountryCode, SesGrp->LanguageID, SesGrp->Os2ssLCID));
KdPrint(("OS2SES(Win32-NLS): OEMCP %lu, ACP %lu, Country %lu, LangID %lx\n",
SesGrp->Win32OEMCP, SesGrp->Win32ACP, SesGrp->Win32CountryCode,
SesGrp->Win32LANGID));
KdPrint((" LCID %lx, ConCP %lu, ConOutCP %lu\n",
SesGrp->Win32LCID, CurrentKbdCP, CurrentVioCP));
}
#endif
/*
* Complete the NLS initialization for Vio and KBD
*/
KbdInitForNLS(CurrentKbdCP);
VioInitForNLS(CurrentVioCP);
return (NO_ERROR);
}
DWORD
Ow2NlsGetCtryInfo(
IN ULONG NlsCodePage,
IN ULONG NlsCountryCode,
OUT PVOID NlsCountryInfo
)
{
ULONG Rc;
LCID NlsLocaleID;
Rc = NlsCountryToLoacle(
NlsCountryCode,
&NlsLocaleID
);
if (Rc)
{
#if DBG
IF_OD2_DEBUG2( NLS, OS2_EXE )
KdPrint(("OS2SES(NlsRequest-GetCtryInfo): cannot find LocaleID Rc %lu\n",
Rc));
#endif
return(Rc);
}
return (Or2NlsGetCtryInfo(
NlsLocaleID,
(UINT)NlsCodePage,
(PCOUNTRYINFO)NlsCountryInfo
));
}
DWORD
Ow2NlsGetCollateTable(
IN ULONG NlsCodePage,
IN ULONG NlsCountryCode,
OUT PVOID NlsColateTable
)
{
DWORD Rc;
LCID NlsLocaleID;
Rc = NlsCountryToLoacle(
NlsCountryCode,
&NlsLocaleID
);
if (Rc)
{
#if DBG
IF_OD2_DEBUG2( NLS, OS2_EXE )
KdPrint(("OS2SES(NlsRequest-GetCtryInfo): cannot find LocaleID Rc %lu\n",
Rc));
#endif
return(Rc);
}
Rc = Or2NlsGetMapTable(
NlsLocaleID,
(UINT)NlsCodePage,
LCMAP_SORTKEY,
(PUCHAR)NlsColateTable
);
if (Rc)
{
Rc = GetLastError();
#if DBG
IF_OD2_DEBUG2( NLS, OS2_EXE )
KdPrint(("OS2SES(NlsRequest-GetColateTable): Rc %lu\n",
Rc));
#endif
}
return(Rc);
}
DWORD
Ow2NlsGetCaseMapTable(
IN ULONG NlsCodePage,
IN ULONG NlsCountryCode,
OUT PVOID NlsColateTable
)
{
DWORD Rc;
LCID NlsLocaleID;
Rc = NlsCountryToLoacle(
NlsCountryCode,
&NlsLocaleID
);
if (Rc)
{
#if DBG
IF_OD2_DEBUG2( NLS, OS2_EXE )
KdPrint(("OS2SES(NlsRequest-GetCtryInfo): cannot find LocaleID Rc %lu\n",
Rc));
#endif
return(Rc);
}
Rc = Or2NlsGetMapTable(
NlsLocaleID,
(UINT)NlsCodePage,
LCMAP_UPPERCASE,
(PUCHAR)NlsColateTable
);
if (Rc)
{
Rc = GetLastError();
#if DBG
IF_OD2_DEBUG2( NLS, OS2_EXE )
KdPrint(("OS2SES(NlsRequest-GetCaseMap): Rc %lu\n",
Rc));
#endif
}
return(Rc);
}
DWORD
Ow2NlsGetDBCSEn(
IN ULONG NlsCodePage,
OUT PVOID NlsDBCSVec
)
{
POD2_DBCS_VECTOR_ENTRY DBCSVec = (POD2_DBCS_VECTOR_ENTRY) NlsDBCSVec;
return(Or2NlsGetCPInfo(
(UINT)NlsCodePage,
(POD2_DBCS_VECTOR_ENTRY) NlsDBCSVec
));
}
ULONG
NlsCountryToLoacle(
IN ULONG NlsCountryCode,
IN LCID *NlsLocaleID
)
{
// BUGBUG: find LocalId from CountryCode
*NlsLocaleID = (LCID) -1;
return (ERROR_NLS_NO_CTRY_CODE);
}
|