Don't announce the WNetDirectoryNotify capability WNetGetConnection.
[wine/hacks.git] / ole / ole2nls.c
blob86a83f5e177a3fdd20c47c1433ed2f46bce6f4ff
1 /*
2 * OLE2NLS library
4 * Copyright 1995 Martin von Loewis
5 * Copyright 1998 David Lee Lambert
6 */
8 #include <string.h>
9 #include <ctype.h>
10 #include <stdlib.h>
11 #include "winuser.h"
12 #include "heap.h"
13 #include "options.h"
14 #include "winnls.h"
15 #include "winreg.h"
16 #include "winerror.h"
17 #include "debug.h"
18 #include "main.h"
20 struct NLS_langlocale {
21 const int lang;
22 struct NLS_localevar {
23 const int type;
24 const char *val;
25 } locvars[150];
28 #define LANG_BEGIN(l,s) { MAKELANGID(l,s), {
30 #define LOCVAL(type,value) {type,value},
32 #define LANG_END }},
34 static const struct NLS_langlocale langlocales[] = {
35 /* add languages in numerical order of main language (last two digits)
36 * it is much easier to find the missing holes that way */
38 LANG_BEGIN (LANG_CATALAN, SUBLANG_DEFAULT) /*0x0403*/
39 #include "nls/cat.nls"
40 LANG_END
42 LANG_BEGIN (LANG_CZECH, SUBLANG_DEFAULT) /*0x0405*/
43 #include "nls/cze.nls"
44 LANG_END
46 LANG_BEGIN (LANG_DANISH, SUBLANG_DEFAULT) /*0x0406*/
47 #include "nls/dan.nls"
48 LANG_END
50 LANG_BEGIN (LANG_GERMAN, SUBLANG_GERMAN) /*0x0407*/
51 #include "nls/deu.nls"
52 LANG_END
53 LANG_BEGIN (LANG_GERMAN, SUBLANG_GERMAN_SWISS) /*0x0807*/
54 #include "nls/des.nls"
55 LANG_END
56 LANG_BEGIN (LANG_GERMAN, SUBLANG_GERMAN_AUSTRIAN) /*0x0C07*/
57 #include "nls/dea.nls"
58 LANG_END
59 LANG_BEGIN (LANG_GERMAN, SUBLANG_GERMAN_LUXEMBOURG) /*0x1007*/
60 #include "nls/del.nls"
61 LANG_END
62 LANG_BEGIN (LANG_GERMAN, SUBLANG_GERMAN_LIECHTENSTEIN) /*0x1407*/
63 #include "nls/dec.nls"
64 LANG_END
66 LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_US) /*0x0409*/
67 #include "nls/enu.nls"
68 LANG_END
69 LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_UK) /*0x0809*/
70 #include "nls/eng.nls"
71 LANG_END
72 LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_AUS) /*0x0C09*/
73 #include "nls/ena.nls"
74 LANG_END
75 LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_CAN) /*0x1009*/
76 #include "nls/enc.nls"
77 LANG_END
78 LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_NZ) /*0x1409*/
79 #include "nls/enz.nls"
80 LANG_END
81 LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_EIRE) /*0x1809*/
82 #include "nls/irl.nls"
83 LANG_END
84 LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_SAFRICA) /*0x1C09*/
85 #include "nls/ens.nls"
86 LANG_END
87 LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_JAMAICA) /*0x2009*/
88 #include "nls/enj.nls"
89 LANG_END
90 LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_CARRIBEAN) /*0x2409*/
91 #include "nls/enb.nls"
92 LANG_END
93 LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_BELIZE) /*0x2809*/
94 #include "nls/enl.nls"
95 LANG_END
96 LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_TRINIDAD) /*0x2C09*/
97 #include "nls/ent.nls"
98 LANG_END
100 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH) /*0x040a*/
101 #include "nls/esp.nls"
102 LANG_END
103 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_MEXICAN) /*0x080a*/
104 #include "nls/esm.nls"
105 LANG_END
106 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_MODERN) /*0x0C0a*/
107 #include "nls/esn.nls"
108 LANG_END
109 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_GUATEMALA) /*0x100a*/
110 #include "nls/esg.nls"
111 LANG_END
112 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_COSTARICA) /*0x140a*/
113 #include "nls/esc.nls"
114 LANG_END
115 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_PANAMA) /*0x180a*/
116 #include "nls/esa.nls"
117 LANG_END
118 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_DOMINICAN) /*0x1C0A*/
119 #include "nls/esd.nls"
120 LANG_END
121 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_VENEZUELA) /*0x200a*/
122 #include "nls/esv.nls"
123 LANG_END
124 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_COLOMBIA) /*0x240a*/
125 #include "nls/eso.nls"
126 LANG_END
127 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_PERU) /*0x280a*/
128 #include "nls/esr.nls"
129 LANG_END
130 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_ARGENTINA) /*0x2c0a*/
131 #include "nls/ess.nls"
132 LANG_END
133 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_ECUADOR) /*0x300a*/
134 #include "nls/esf.nls"
135 LANG_END
136 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_CHILE) /*0x340a*/
137 #include "nls/esl.nls"
138 LANG_END
139 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_URUGUAY) /*0x380a*/
140 #include "nls/esy.nls"
141 LANG_END
142 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_PARAGUAY) /*0x3c0a*/
143 #include "nls/esz.nls"
144 LANG_END
145 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_BOLIVIA) /*0x400a*/
146 #include "nls/esb.nls"
147 LANG_END
148 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_EL_SALVADOR) /*0x440a*/
149 #include "nls/ese.nls"
150 LANG_END
151 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_HONDURAS) /*0x480a*/
152 #include "nls/esh.nls"
153 LANG_END
154 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_NICARAGUA) /*0x4c0a*/
155 #include "nls/esi.nls"
156 LANG_END
157 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_PUERTO_RICO) /*0x500a*/
158 #include "nls/esu.nls"
159 LANG_END
161 LANG_BEGIN (LANG_FINNISH, SUBLANG_DEFAULT) /*0x040B*/
162 #include "nls/fin.nls"
163 LANG_END
165 LANG_BEGIN (LANG_FRENCH, SUBLANG_FRENCH) /*0x040C*/
166 #include "nls/fra.nls"
167 LANG_END
168 LANG_BEGIN (LANG_FRENCH, SUBLANG_FRENCH_BELGIAN) /*0x080C*/
169 #include "nls/frb.nls"
170 LANG_END
171 LANG_BEGIN (LANG_FRENCH, SUBLANG_FRENCH_CANADIAN) /*0x0C0C*/
172 #include "nls/frc.nls"
173 LANG_END
174 LANG_BEGIN (LANG_FRENCH, SUBLANG_FRENCH_SWISS) /*0x100C*/
175 #include "nls/frs.nls"
176 LANG_END
177 LANG_BEGIN (LANG_FRENCH, SUBLANG_FRENCH_LUXEMBOURG) /*0x140C*/
178 #include "nls/frl.nls"
179 LANG_END
181 LANG_BEGIN (LANG_HUNGARIAN, SUBLANG_DEFAULT) /*0x040e*/
182 #include "nls/hun.nls"
183 LANG_END
185 LANG_BEGIN (LANG_ITALIAN, SUBLANG_ITALIAN) /*0x0410*/
186 #include "nls/ita.nls"
187 LANG_END
188 LANG_BEGIN (LANG_ITALIAN, SUBLANG_ITALIAN_SWISS) /*0x0810*/
189 #include "nls/its.nls"
190 LANG_END
192 LANG_BEGIN (LANG_KOREAN, SUBLANG_KOREAN) /*0x0412*/
193 #include "nls/kor.nls"
194 LANG_END
196 LANG_BEGIN (LANG_DUTCH, SUBLANG_DUTCH) /*0x0413*/
197 #include "nls/nld.nls"
198 LANG_END
199 LANG_BEGIN (LANG_DUTCH, SUBLANG_DUTCH_BELGIAN) /*0x0813*/
200 #include "nls/nlb.nls"
201 LANG_END
202 LANG_BEGIN (LANG_DUTCH, SUBLANG_DUTCH_SURINAM) /*0x0C13*/
203 #include "nls/nls.nls"
204 LANG_END
206 LANG_BEGIN (LANG_NORWEGIAN, SUBLANG_NORWEGIAN_BOKMAL) /*0x0414*/
207 #include "nls/nor.nls"
208 LANG_END
209 LANG_BEGIN (LANG_NORWEGIAN, SUBLANG_NORWEGIAN_NYNORSK) /*0x0814*/
210 #include "nls/non.nls"
211 LANG_END
213 LANG_BEGIN (LANG_POLISH, SUBLANG_DEFAULT) /*0x0415*/
214 #include "nls/plk.nls"
215 LANG_END
217 LANG_BEGIN (LANG_PORTUGUESE ,SUBLANG_PORTUGUESE_BRAZILIAN) /*0x0416*/
218 #include "nls/ptb.nls"
219 LANG_END
220 LANG_BEGIN (LANG_PORTUGUESE ,SUBLANG_PORTUGUESE) /*0x0816*/
221 #include "nls/ptg.nls"
222 LANG_END
224 LANG_BEGIN (LANG_RUSSIAN, SUBLANG_DEFAULT) /*0x419*/
225 #include "nls/rus.nls"
226 LANG_END
228 LANG_BEGIN (LANG_SLOVAK, SUBLANG_DEFAULT) /*0x041b*/
229 #include "nls/sky.nls"
230 LANG_END
232 LANG_BEGIN (LANG_SWEDISH, SUBLANG_SWEDISH) /*0x041d*/
233 #include "nls/sve.nls"
234 LANG_END
235 LANG_BEGIN (LANG_SWEDISH, SUBLANG_SWEDISH_FINLAND) /*0x081d*/
236 #include "nls/svf.nls"
237 LANG_END
239 LANG_BEGIN (LANG_THAI, SUBLANG_DEFAULT) /*0x41e*/
240 #include "nls/tha.nls"
241 LANG_END
243 LANG_BEGIN (LANG_ESPERANTO, SUBLANG_DEFAULT) /*0x048f*/
244 #include "nls/esperanto.nls"
245 LANG_END
247 LANG_BEGIN (LANG_WALON, SUBLANG_DEFAULT) /*0x0490*/
248 #include "nls/wal.nls"
249 LANG_END
253 /* Locale name to id map. used by EnumSystemLocales, GetLocalInfoA
254 * MUST contain all #defines from winnls.h
255 * last entry has NULL name, 0 id.
257 #define LOCALE_ENTRY(x) {#x,LOCALE_##x}
258 static struct tagLOCALE_NAME2ID {
259 char *name;
260 DWORD id;
261 } locale_name2id[]= {
262 LOCALE_ENTRY(ILANGUAGE),
263 LOCALE_ENTRY(SLANGUAGE),
264 LOCALE_ENTRY(SENGLANGUAGE),
265 LOCALE_ENTRY(SABBREVLANGNAME),
266 LOCALE_ENTRY(SNATIVELANGNAME),
267 LOCALE_ENTRY(ICOUNTRY),
268 LOCALE_ENTRY(SCOUNTRY),
269 LOCALE_ENTRY(SENGCOUNTRY),
270 LOCALE_ENTRY(SABBREVCTRYNAME),
271 LOCALE_ENTRY(SNATIVECTRYNAME),
272 LOCALE_ENTRY(IDEFAULTLANGUAGE),
273 LOCALE_ENTRY(IDEFAULTCOUNTRY),
274 LOCALE_ENTRY(IDEFAULTCODEPAGE),
275 LOCALE_ENTRY(IDEFAULTANSICODEPAGE),
276 LOCALE_ENTRY(IDEFAULTMACCODEPAGE),
277 LOCALE_ENTRY(SLIST),
278 LOCALE_ENTRY(IMEASURE),
279 LOCALE_ENTRY(SDECIMAL),
280 LOCALE_ENTRY(STHOUSAND),
281 LOCALE_ENTRY(SGROUPING),
282 LOCALE_ENTRY(IDIGITS),
283 LOCALE_ENTRY(ILZERO),
284 LOCALE_ENTRY(INEGNUMBER),
285 LOCALE_ENTRY(SNATIVEDIGITS),
286 LOCALE_ENTRY(SCURRENCY),
287 LOCALE_ENTRY(SINTLSYMBOL),
288 LOCALE_ENTRY(SMONDECIMALSEP),
289 LOCALE_ENTRY(SMONTHOUSANDSEP),
290 LOCALE_ENTRY(SMONGROUPING),
291 LOCALE_ENTRY(ICURRDIGITS),
292 LOCALE_ENTRY(IINTLCURRDIGITS),
293 LOCALE_ENTRY(ICURRENCY),
294 LOCALE_ENTRY(INEGCURR),
295 LOCALE_ENTRY(SDATE),
296 LOCALE_ENTRY(STIME),
297 LOCALE_ENTRY(SSHORTDATE),
298 LOCALE_ENTRY(SLONGDATE),
299 LOCALE_ENTRY(STIMEFORMAT),
300 LOCALE_ENTRY(IDATE),
301 LOCALE_ENTRY(ILDATE),
302 LOCALE_ENTRY(ITIME),
303 LOCALE_ENTRY(ITIMEMARKPOSN),
304 LOCALE_ENTRY(ICENTURY),
305 LOCALE_ENTRY(ITLZERO),
306 LOCALE_ENTRY(IDAYLZERO),
307 LOCALE_ENTRY(IMONLZERO),
308 LOCALE_ENTRY(S1159),
309 LOCALE_ENTRY(S2359),
310 LOCALE_ENTRY(ICALENDARTYPE),
311 LOCALE_ENTRY(IOPTIONALCALENDAR),
312 LOCALE_ENTRY(IFIRSTDAYOFWEEK),
313 LOCALE_ENTRY(IFIRSTWEEKOFYEAR),
314 LOCALE_ENTRY(SDAYNAME1),
315 LOCALE_ENTRY(SDAYNAME2),
316 LOCALE_ENTRY(SDAYNAME3),
317 LOCALE_ENTRY(SDAYNAME4),
318 LOCALE_ENTRY(SDAYNAME5),
319 LOCALE_ENTRY(SDAYNAME6),
320 LOCALE_ENTRY(SDAYNAME7),
321 LOCALE_ENTRY(SABBREVDAYNAME1),
322 LOCALE_ENTRY(SABBREVDAYNAME2),
323 LOCALE_ENTRY(SABBREVDAYNAME3),
324 LOCALE_ENTRY(SABBREVDAYNAME4),
325 LOCALE_ENTRY(SABBREVDAYNAME5),
326 LOCALE_ENTRY(SABBREVDAYNAME6),
327 LOCALE_ENTRY(SABBREVDAYNAME7),
328 LOCALE_ENTRY(SMONTHNAME1),
329 LOCALE_ENTRY(SMONTHNAME2),
330 LOCALE_ENTRY(SMONTHNAME3),
331 LOCALE_ENTRY(SMONTHNAME4),
332 LOCALE_ENTRY(SMONTHNAME5),
333 LOCALE_ENTRY(SMONTHNAME6),
334 LOCALE_ENTRY(SMONTHNAME7),
335 LOCALE_ENTRY(SMONTHNAME8),
336 LOCALE_ENTRY(SMONTHNAME9),
337 LOCALE_ENTRY(SMONTHNAME10),
338 LOCALE_ENTRY(SMONTHNAME11),
339 LOCALE_ENTRY(SMONTHNAME12),
340 LOCALE_ENTRY(SMONTHNAME13),
341 LOCALE_ENTRY(SABBREVMONTHNAME1),
342 LOCALE_ENTRY(SABBREVMONTHNAME2),
343 LOCALE_ENTRY(SABBREVMONTHNAME3),
344 LOCALE_ENTRY(SABBREVMONTHNAME4),
345 LOCALE_ENTRY(SABBREVMONTHNAME5),
346 LOCALE_ENTRY(SABBREVMONTHNAME6),
347 LOCALE_ENTRY(SABBREVMONTHNAME7),
348 LOCALE_ENTRY(SABBREVMONTHNAME8),
349 LOCALE_ENTRY(SABBREVMONTHNAME9),
350 LOCALE_ENTRY(SABBREVMONTHNAME10),
351 LOCALE_ENTRY(SABBREVMONTHNAME11),
352 LOCALE_ENTRY(SABBREVMONTHNAME12),
353 LOCALE_ENTRY(SABBREVMONTHNAME13),
354 LOCALE_ENTRY(SPOSITIVESIGN),
355 LOCALE_ENTRY(SNEGATIVESIGN),
356 LOCALE_ENTRY(IPOSSIGNPOSN),
357 LOCALE_ENTRY(INEGSIGNPOSN),
358 LOCALE_ENTRY(IPOSSYMPRECEDES),
359 LOCALE_ENTRY(IPOSSEPBYSPACE),
360 LOCALE_ENTRY(INEGSYMPRECEDES),
361 LOCALE_ENTRY(INEGSEPBYSPACE),
362 LOCALE_ENTRY(FONTSIGNATURE),
363 LOCALE_ENTRY(SISO639LANGNAME),
364 LOCALE_ENTRY(SISO3166CTRYNAME),
365 {NULL,0},
368 const struct map_lcid2str {
369 LCID langid;
370 const char *langname;
371 } languages[]={
372 {0x0401,"Arabic (Saudi Arabia)"},
373 {0x0801,"Arabic (Iraq)"},
374 {0x0c01,"Arabic (Egypt)"},
375 {0x1001,"Arabic (Libya)"},
376 {0x1401,"Arabic (Algeria)"},
377 {0x1801,"Arabic (Morocco)"},
378 {0x1c01,"Arabic (Tunisia)"},
379 {0x2001,"Arabic (Oman)"},
380 {0x2401,"Arabic (Yemen)"},
381 {0x2801,"Arabic (Syria)"},
382 {0x2c01,"Arabic (Jordan)"},
383 {0x3001,"Arabic (Lebanon)"},
384 {0x3401,"Arabic (Kuwait)"},
385 {0x3801,"Arabic (United Arab Emirates)"},
386 {0x3c01,"Arabic (Bahrain)"},
387 {0x4001,"Arabic (Qatar)"},
388 {0x0402,"Bulgarian"},
389 {0x0403,"Catalan"},
390 {0x0404,"Chinese (Taiwan)"},
391 {0x0804,"Chinese (People's Republic of China)"},
392 {0x0c04,"Chinese (Hong Kong)"},
393 {0x1004,"Chinese (Singapore)"},
394 {0x1404,"Chinese (Macau)"},
395 {0x0405,"Czech"},
396 {0x0406,"Danish"},
397 {0x0407,"German (Germany)"},
398 {0x0807,"German (Switzerland)"},
399 {0x0c07,"German (Austria)"},
400 {0x1007,"German (Luxembourg)"},
401 {0x1407,"German (Liechtenstein)"},
402 {0x0408,"Greek"},
403 {0x0409,"English (United States)"},
404 {0x0809,"English (United Kingdom)"},
405 {0x0c09,"English (Australia)"},
406 {0x1009,"English (Canada)"},
407 {0x1409,"English (New Zealand)"},
408 {0x1809,"English (Ireland)"},
409 {0x1c09,"English (South Africa)"},
410 {0x2009,"English (Jamaica)"},
411 {0x2409,"English (Caribbean)"},
412 {0x2809,"English (Belize)"},
413 {0x2c09,"English (Trinidad)"},
414 {0x3009,"English (Zimbabwe)"},
415 {0x3409,"English (Philippines)"},
416 {0x040a,"Spanish (Spain, traditional sorting)"},
417 {0x080a,"Spanish (Mexico)"},
418 {0x0c0a,"Spanish (Spain, international sorting)"},
419 {0x100a,"Spanish (Guatemala)"},
420 {0x140a,"Spanish (Costa Rica)"},
421 {0x180a,"Spanish (Panama)"},
422 {0x1c0a,"Spanish (Dominican Republic)"},
423 {0x200a,"Spanish (Venezuela)"},
424 {0x240a,"Spanish (Colombia)"},
425 {0x280a,"Spanish (Peru)"},
426 {0x2c0a,"Spanish (Argentina)"},
427 {0x300a,"Spanish (Ecuador)"},
428 {0x340a,"Spanish (Chile)"},
429 {0x380a,"Spanish (Uruguay)"},
430 {0x3c0a,"Spanish (Paraguay)"},
431 {0x400a,"Spanish (Bolivia)"},
432 {0x440a,"Spanish (El Salvador)"},
433 {0x480a,"Spanish (Honduras)"},
434 {0x4c0a,"Spanish (Nicaragua)"},
435 {0x500a,"Spanish (Puerto Rico)"},
436 {0x040b,"Finnish"},
437 {0x040c,"French (France)"},
438 {0x080c,"French (Belgium)"},
439 {0x0c0c,"French (Canada)"},
440 {0x100c,"French (Switzerland)"},
441 {0x140c,"French (Luxembourg)"},
442 {0x180c,"French (Monaco)"},
443 {0x040d,"Hebrew"},
444 {0x040e,"Hungarian"},
445 {0x040f,"Icelandic"},
446 {0x0410,"Italian (Italy)"},
447 {0x0810,"Italian (Switzerland)"},
448 {0x0411,"Japanese"},
449 {0x0412,"Korean (Wansung)"},
450 {0x0812,"Korean (Johab)"},
451 {0x0413,"Dutch (Netherlands)"},
452 {0x0813,"Dutch (Belgium)"},
453 {0x0414,"Norwegian (Bokmal)"},
454 {0x0814,"Norwegian (Nynorsk)"},
455 {0x0415,"Polish"},
456 {0x0416,"Portuguese (Brazil)"},
457 {0x0816,"Portuguese (Portugal)"},
458 {0x0417,"Rhaeto Romanic"},
459 {0x0418,"Romanian"},
460 {0x0818,"Moldavian"},
461 {0x0419,"Russian (Russia)"},
462 {0x0819,"Russian (Moldavia)"},
463 {0x041a,"Croatian"},
464 {0x081a,"Serbian (latin)"},
465 {0x0c1a,"Serbian (cyrillic)"},
466 {0x041b,"Slovak"},
467 {0x041c,"Albanian"},
468 {0x041d,"Swedish (Sweden)"},
469 {0x081d,"Swedish (Finland)"},
470 {0x041e,"Thai"},
471 {0x041f,"Turkish"},
472 {0x0420,"Urdu"},
473 {0x0421,"Indonesian"},
474 {0x0422,"Ukrainian"},
475 {0x0423,"Belarusian"},
476 {0x0424,"Slovene"},
477 {0x0425,"Estonian"},
478 {0x0426,"Latvian"},
479 {0x0427,"Lithuanian (modern)"},
480 {0x0827,"Lithuanian (classic)"},
481 {0x0428,"Maori"},
482 {0x0429,"Farsi"},
483 {0x042a,"Vietnamese"},
484 {0x042b,"Armenian"},
485 {0x042c,"Azeri (latin)"},
486 {0x082c,"Azeri (cyrillic)"},
487 {0x042d,"Basque"},
488 {0x042e,"Sorbian"},
489 {0x042f,"Macedonian"},
490 {0x0430,"Sutu"},
491 {0x0431,"Tsonga"},
492 {0x0432,"Tswana"},
493 {0x0433,"Venda"},
494 {0x0434,"Xhosa"},
495 {0x0435,"Zulu"},
496 {0x0436,"Afrikaans"},
497 {0x0437,"Georgian"},
498 {0x0438,"Faeroese"},
499 {0x0439,"Hindi"},
500 {0x043a,"Maltese"},
501 {0x043b,"Saami"},
502 {0x043c,"Irish gaelic"},
503 {0x083c,"Scottish gaelic"},
504 {0x043e,"Malay (Malaysia)"},
505 {0x083e,"Malay (Brunei Darussalam)"},
506 {0x043f,"Kazak"},
507 {0x0441,"Swahili"},
508 {0x0443,"Uzbek (latin)"},
509 {0x0843,"Uzbek (cyrillic)"},
510 {0x0444,"Tatar"},
511 {0x0445,"Bengali"},
512 {0x0446,"Punjabi"},
513 {0x0447,"Gujarati"},
514 {0x0448,"Oriya"},
515 {0x0449,"Tamil"},
516 {0x044a,"Telugu"},
517 {0x044b,"Kannada"},
518 {0x044c,"Malayalam"},
519 {0x044d,"Assamese"},
520 {0x044e,"Marathi"},
521 {0x044f,"Sanskrit"},
522 {0x0457,"Konkani"},
523 {0x048f,"Esperanto"}, /* Non official */
524 {0x0490,"Walon"}, /* Non official */
525 {0x0000,"Unknown"}
526 }, languages_de[]={
527 {0x0401,"Arabic"},
528 {0x0402,"Bulgarisch"},
529 {0x0403,"Katalanisch"},
530 {0x0404,"Traditionales Chinesisch"},
531 {0x0405,"Tschecisch"},
532 {0x0406,"Dänisch"},
533 {0x0407,"Deutsch"},
534 {0x0408,"Griechisch"},
535 {0x0409,"Amerikanisches Englisch"},
536 {0x040A,"Kastilisches Spanisch"},
537 {0x040B,"Finnisch"},
538 {0x040C,"Franzvsisch"},
539 {0x040D,"Hebrdisch"},
540 {0x040E,"Ungarisch"},
541 {0x040F,"Isldndisch"},
542 {0x0410,"Italienisch"},
543 {0x0411,"Japanisch"},
544 {0x0412,"Koreanisch"},
545 {0x0413,"Niederldndisch"},
546 {0x0414,"Norwegisch-Bokmal"},
547 {0x0415,"Polnisch"},
548 {0x0416,"Brasilianisches Portugiesisch"},
549 {0x0417,"Rdtoromanisch"},
550 {0x0418,"Rumdnisch"},
551 {0x0419,"Russisch"},
552 {0x041A,"Kroatoserbisch (lateinisch)"},
553 {0x041B,"Slowenisch"},
554 {0x041C,"Albanisch"},
555 {0x041D,"Schwedisch"},
556 {0x041E,"Thai"},
557 {0x041F,"Türkisch"},
558 {0x0420,"Urdu"},
559 {0x0421,"Bahasa"},
560 {0x0804,"Vereinfachtes Chinesisch"},
561 {0x0807,"Schweizerdeutsch"},
562 {0x0809,"Britisches Englisch"},
563 {0x080A,"Mexikanisches Spanisch"},
564 {0x080C,"Belgisches Franzvsisch"},
565 {0x0810,"Schweizerisches Italienisch"},
566 {0x0813,"Belgisches Niederldndisch"},
567 {0x0814,"Norgwegisch-Nynorsk"},
568 {0x0816,"Portugiesisch"},
569 {0x081A,"Serbokratisch (kyrillisch)"},
570 {0x0C1C,"Kanadisches Franzvsisch"},
571 {0x100C,"Schweizerisches Franzvsisch"},
572 {0x0000,"Unbekannt"},
575 /***********************************************************************
576 * GetUserDefaultLCID (OLE2NLS.1)
578 LCID WINAPI GetUserDefaultLCID()
580 return MAKELCID( GetUserDefaultLangID() , SORT_DEFAULT );
583 /***********************************************************************
584 * GetSystemDefaultLCID (OLE2NLS.2)
586 LCID WINAPI GetSystemDefaultLCID()
588 return GetUserDefaultLCID();
591 /***********************************************************************
592 * GetUserDefaultLangID (OLE2NLS.3)
594 LANGID WINAPI GetUserDefaultLangID()
596 /* caching result, if defined from environment, which should (?) not change during a WINE session */
597 static LANGID userLCID = 0;
598 if (Options.language) {
599 return Languages[Options.language].langid;
602 if (userLCID == 0) {
603 char *buf=NULL;
604 char *lang,*country,*charset,*dialect,*next;
605 int ret=0;
607 buf=getenv("LANGUAGE");
608 if (!buf) buf=getenv("LANG");
609 if (!buf) buf=getenv("LC_ALL");
610 if (!buf) buf=getenv("LC_MESSAGES");
611 if (!buf) buf=getenv("LC_CTYPE");
612 if (!buf) return userLCID = MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT );
614 if (!strcmp(buf,"POSIX") || !strcmp(buf,"C")) {
615 return MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT );
618 lang=buf;
620 do {
621 next=strchr(lang,':'); if (next) *next++='\0';
622 dialect=strchr(lang,'@'); if (dialect) *dialect++='\0';
623 charset=strchr(lang,'.'); if (charset) *charset++='\0';
624 country=strchr(lang,'_'); if (country) *country++='\0';
626 ret=MAIN_GetLanguageID(lang, country, charset, dialect);
628 lang=next;
630 } while (lang && !ret);
632 /* FIXME : are strings returned by getenv() to be free()'ed ? */
633 userLCID = (LANGID)ret;
635 return userLCID;
638 /***********************************************************************
639 * GetSystemDefaultLangID (OLE2NLS.4)
641 LANGID WINAPI GetSystemDefaultLangID()
643 return GetUserDefaultLangID();
646 /******************************************************************************
647 * GetLocaleInfo16 [OLE2NLS.5]
648 * Is the last parameter really WORD for Win16?
650 INT16 WINAPI GetLocaleInfo16(LCID lcid,LCTYPE LCType,LPSTR buf,INT16 len)
652 return GetLocaleInfoA(lcid,LCType,buf,len);
654 /******************************************************************************
655 * ConvertDefaultLocale32 [KERNEL32.147]
657 LCID WINAPI ConvertDefaultLocale32 (LCID lcid)
658 { switch (lcid)
659 { case LOCALE_SYSTEM_DEFAULT:
660 return GetSystemDefaultLCID();
661 case LOCALE_USER_DEFAULT:
662 return GetUserDefaultLCID();
663 case 0:
664 return MAKELCID (LANG_NEUTRAL, SUBLANG_NEUTRAL);
666 return MAKELANGID( PRIMARYLANGID(lcid), SUBLANG_NEUTRAL);
668 /******************************************************************************
669 * GetLocaleInfo32A [KERNEL32.342]
671 * NOTES
672 * LANG_NEUTRAL is equal to LOCALE_SYSTEM_DEFAULT
674 * MS online documentation states that the string returned is NULL terminated
675 * except for LOCALE_FONTSIGNATURE which "will return a non-NULL
676 * terminated string".
678 INT WINAPI GetLocaleInfoA(LCID lcid,LCTYPE LCType,LPSTR buf,INT len)
680 LPCSTR retString;
681 int found,i;
682 int lang=0;
684 TRACE(ole,"(lcid=0x%lx,lctype=0x%lx,%p,%x)\n",lcid,LCType,buf,len);
686 if (len && (! buf) ) {
687 SetLastError(ERROR_INSUFFICIENT_BUFFER);
688 return 0;
691 if (lcid ==0 || lcid == LANG_SYSTEM_DEFAULT || (LCType & LOCALE_NOUSEROVERRIDE) ) /* 0x00, 0x400 */
693 lcid = GetSystemDefaultLCID();
695 else if (lcid == LANG_USER_DEFAULT) /*0x800*/
697 lcid = GetUserDefaultLCID();
699 LCType &= ~(LOCALE_NOUSEROVERRIDE|LOCALE_USE_CP_ACP);
701 /* As an option, we could obtain the value from win.ini.
702 This would not match the Wine compile-time option.
703 Also, not all identifiers are available from win.ini */
704 retString=0;
705 /* If we are through all of this, retLen should not be zero anymore.
706 If it is, the value is not supported */
707 i=0;
708 while (locale_name2id[i].name!=NULL) {
709 if (LCType == locale_name2id[i].id) {
710 retString = locale_name2id[i].name;
711 break;
713 i++;
715 if (!retString) {
716 FIXME(ole,"Unkown LC type %lX\n",LCType);
717 return 0;
720 found=0;lang=lcid;
721 for (i=0;(i<3 && !found);i++) {
722 int j;
724 for (j=0;j<sizeof(langlocales)/sizeof(langlocales[0]);j++) {
725 if (langlocales[j].lang == lang) {
726 int k;
728 for (k=0;k<sizeof(langlocales[j].locvars)/sizeof(langlocales[j].locvars[0]) && (langlocales[j].locvars[k].type);k++) {
729 if (langlocales[j].locvars[k].type == LCType) {
730 found = 1;
731 retString = langlocales[j].locvars[k].val;
732 break;
735 if (found)
736 break;
739 /* language not found, try without a sublanguage*/
740 if (i==1) lang=MAKELANGID( PRIMARYLANGID(lang), SUBLANG_DEFAULT);
741 /* mask the LC Value */
742 if (i==2) LCType &= 0xfff;
745 if(!found) {
746 ERR(ole,"'%s' not supported for your language (%04X).\n",
747 retString,(WORD)lcid);
748 SetLastError(ERROR_INVALID_PARAMETER);
749 return 0;
751 /* a FONTSIGNATURE is not a string, just 6 DWORDs */
752 if (LCType == LOCALE_FONTSIGNATURE) {
753 if (len)
754 memcpy(buf, retString, (len<=sizeof(FONTSIGNATURE))?len:sizeof(FONTSIGNATURE));
755 return sizeof(FONTSIGNATURE);
757 /* if len=0 return only the length, don't touch the buffer*/
758 if (len) lstrcpynA(buf,retString,len);
759 return strlen(retString)+1;
762 /******************************************************************************
763 * GetLocaleInfo32W [KERNEL32.343]
765 * NOTES
766 * MS documentation states that len "specifies the size, in bytes (ANSI version)
767 * or characters (Unicode version), of" wbuf. Thus the number returned is
768 * the same between GetLocaleInfo32W and GetLocaleInfo32A.
770 INT WINAPI GetLocaleInfoW(LCID lcid,LCTYPE LCType,LPWSTR wbuf,INT len)
771 { WORD wlen;
772 LPSTR abuf;
774 if (len && (! wbuf) )
775 { SetLastError(ERROR_INSUFFICIENT_BUFFER);
776 return 0;
779 abuf = (LPSTR)HeapAlloc(GetProcessHeap(),0,len);
780 wlen = GetLocaleInfoA(lcid, LCType, abuf, len);
782 if (wlen && len) /* if len=0 return only the length*/
783 lstrcpynAtoW(wbuf,abuf,len);
785 HeapFree(GetProcessHeap(),0,abuf);
786 return wlen;
789 /******************************************************************************
790 * SetLocaleInfoA [KERNEL32.656]
792 BOOL16 WINAPI SetLocaleInfoA(DWORD lcid, DWORD lctype, LPCSTR data)
794 FIXME(ole,"(%ld,%ld,%s): stub\n",lcid,lctype,data);
795 return TRUE;
798 /******************************************************************************
799 * IsValidLocale [KERNEL32.489]
801 BOOL WINAPI IsValidLocale(LCID lcid,DWORD flags)
803 /* we support ANY language. Well, at least say that...*/
804 return TRUE;
807 /******************************************************************************
808 * EnumSystemLocales32W [KERNEL32.209]
810 BOOL WINAPI EnumSystemLocalesW( LOCALE_ENUMPROCW lpfnLocaleEnum,
811 DWORD flags )
813 int i;
814 BOOL ret;
815 WCHAR buffer[200];
816 HKEY xhkey;
818 TRACE(win32,"(%p,%08lx)\n",lpfnLocaleEnum,flags );
819 /* see if we can reuse the Win95 registry entries.... */
820 if (ERROR_SUCCESS==RegOpenKeyA(HKEY_LOCAL_MACHINE,"System\\CurrentControlSet\\control\\Nls\\Locale\\",&xhkey)) {
821 i=0;
822 while (1) {
823 if (ERROR_SUCCESS!=RegEnumKeyW(xhkey,i,buffer,sizeof(buffer)))
824 break;
825 if (!lpfnLocaleEnum(buffer))
826 break;
827 i++;
829 RegCloseKey(xhkey);
830 return TRUE;
833 i=0;
834 while (languages[i].langid!=0)
836 LPWSTR cp;
837 char xbuffer[10];
839 sprintf(xbuffer,"%08lx",(DWORD)languages[i].langid);
841 cp = HEAP_strdupAtoW( GetProcessHeap(), 0, xbuffer );
842 ret = lpfnLocaleEnum(cp);
843 HeapFree( GetProcessHeap(), 0, cp );
844 if (!ret) break;
845 i++;
847 return TRUE;
850 /******************************************************************************
851 * EnumSystemLocales32A [KERNEL32.208]
853 BOOL WINAPI EnumSystemLocalesA(LOCALE_ENUMPROCA lpfnLocaleEnum,
854 DWORD flags)
856 int i;
857 CHAR buffer[200];
858 HKEY xhkey;
860 TRACE(win32,"(%p,%08lx)\n",
861 lpfnLocaleEnum,flags
863 if (ERROR_SUCCESS==RegOpenKeyA(HKEY_LOCAL_MACHINE,"System\\CurrentControlSet\\control\\Nls\\Locale\\",&xhkey)) {
864 i=0;
865 while (1) {
866 if (ERROR_SUCCESS!=RegEnumKeyA(xhkey,i,buffer,sizeof(buffer)))
867 break;
868 if (!lpfnLocaleEnum(buffer))
869 break;
870 i++;
872 RegCloseKey(xhkey);
873 return TRUE;
875 i=0;
876 while (languages[i].langid!=0) {
877 sprintf(buffer,"%08lx",(DWORD)languages[i].langid);
878 if (!lpfnLocaleEnum(buffer))
879 break;
880 i++;
882 return TRUE;
885 static const unsigned char CT_CType2_LUT[] = {
886 C2_NOTAPPLICABLE, /* - 0 */
887 C2_NOTAPPLICABLE, /* - 1 */
888 C2_NOTAPPLICABLE, /* - 2 */
889 C2_NOTAPPLICABLE, /* - 3 */
890 C2_NOTAPPLICABLE, /* - 4 */
891 C2_NOTAPPLICABLE, /* - 5 */
892 C2_NOTAPPLICABLE, /* - 6 */
893 C2_NOTAPPLICABLE, /* - 7 */
894 C2_NOTAPPLICABLE, /* - 8 */
895 C2_SEGMENTSEPARATOR, /* - 9 */
896 C2_NOTAPPLICABLE, /* - 10 */
897 C2_NOTAPPLICABLE, /* - 11 */
898 C2_NOTAPPLICABLE, /* - 12 */
899 C2_NOTAPPLICABLE, /* - 13 */
900 C2_NOTAPPLICABLE, /* - 14 */
901 C2_NOTAPPLICABLE, /* - 15 */
902 C2_NOTAPPLICABLE, /* - 16 */
903 C2_NOTAPPLICABLE, /* - 17 */
904 C2_NOTAPPLICABLE, /* - 18 */
905 C2_NOTAPPLICABLE, /* - 19 */
906 C2_NOTAPPLICABLE, /* - 20 */
907 C2_NOTAPPLICABLE, /* - 21 */
908 C2_NOTAPPLICABLE, /* - 22 */
909 C2_NOTAPPLICABLE, /* - 23 */
910 C2_NOTAPPLICABLE, /* - 24 */
911 C2_NOTAPPLICABLE, /* - 25 */
912 C2_NOTAPPLICABLE, /* - 26 */
913 C2_NOTAPPLICABLE, /* - 27 */
914 C2_NOTAPPLICABLE, /* - 28 */
915 C2_NOTAPPLICABLE, /* - 29 */
916 C2_NOTAPPLICABLE, /* - 30 */
917 C2_NOTAPPLICABLE, /* - 31 */
918 C2_WHITESPACE, /* - 32 */
919 C2_OTHERNEUTRAL, /* ! - 33 */
920 C2_OTHERNEUTRAL, /* " - 34 */ /* " */
921 C2_EUROPETERMINATOR, /* # - 35 */
922 C2_EUROPETERMINATOR, /* $ - 36 */
923 C2_EUROPETERMINATOR, /* % - 37 */
924 C2_LEFTTORIGHT, /* & - 38 */
925 C2_OTHERNEUTRAL, /* ' - 39 */
926 C2_OTHERNEUTRAL, /* ( - 40 */
927 C2_OTHERNEUTRAL, /* ) - 41 */
928 C2_OTHERNEUTRAL, /* * - 42 */
929 C2_EUROPETERMINATOR, /* + - 43 */
930 C2_COMMONSEPARATOR, /* , - 44 */
931 C2_EUROPETERMINATOR, /* - - 45 */
932 C2_EUROPESEPARATOR, /* . - 46 */
933 C2_EUROPESEPARATOR, /* / - 47 */
934 C2_EUROPENUMBER, /* 0 - 48 */
935 C2_EUROPENUMBER, /* 1 - 49 */
936 C2_EUROPENUMBER, /* 2 - 50 */
937 C2_EUROPENUMBER, /* 3 - 51 */
938 C2_EUROPENUMBER, /* 4 - 52 */
939 C2_EUROPENUMBER, /* 5 - 53 */
940 C2_EUROPENUMBER, /* 6 - 54 */
941 C2_EUROPENUMBER, /* 7 - 55 */
942 C2_EUROPENUMBER, /* 8 - 56 */
943 C2_EUROPENUMBER, /* 9 - 57 */
944 C2_COMMONSEPARATOR, /* : - 58 */
945 C2_OTHERNEUTRAL, /* ; - 59 */
946 C2_OTHERNEUTRAL, /* < - 60 */
947 C2_OTHERNEUTRAL, /* = - 61 */
948 C2_OTHERNEUTRAL, /* > - 62 */
949 C2_OTHERNEUTRAL, /* ? - 63 */
950 C2_LEFTTORIGHT, /* @ - 64 */
951 C2_LEFTTORIGHT, /* A - 65 */
952 C2_LEFTTORIGHT, /* B - 66 */
953 C2_LEFTTORIGHT, /* C - 67 */
954 C2_LEFTTORIGHT, /* D - 68 */
955 C2_LEFTTORIGHT, /* E - 69 */
956 C2_LEFTTORIGHT, /* F - 70 */
957 C2_LEFTTORIGHT, /* G - 71 */
958 C2_LEFTTORIGHT, /* H - 72 */
959 C2_LEFTTORIGHT, /* I - 73 */
960 C2_LEFTTORIGHT, /* J - 74 */
961 C2_LEFTTORIGHT, /* K - 75 */
962 C2_LEFTTORIGHT, /* L - 76 */
963 C2_LEFTTORIGHT, /* M - 77 */
964 C2_LEFTTORIGHT, /* N - 78 */
965 C2_LEFTTORIGHT, /* O - 79 */
966 C2_LEFTTORIGHT, /* P - 80 */
967 C2_LEFTTORIGHT, /* Q - 81 */
968 C2_LEFTTORIGHT, /* R - 82 */
969 C2_LEFTTORIGHT, /* S - 83 */
970 C2_LEFTTORIGHT, /* T - 84 */
971 C2_LEFTTORIGHT, /* U - 85 */
972 C2_LEFTTORIGHT, /* V - 86 */
973 C2_LEFTTORIGHT, /* W - 87 */
974 C2_LEFTTORIGHT, /* X - 88 */
975 C2_LEFTTORIGHT, /* Y - 89 */
976 C2_LEFTTORIGHT, /* Z - 90 */
977 C2_OTHERNEUTRAL, /* [ - 91 */
978 C2_OTHERNEUTRAL, /* \ - 92 */
979 C2_OTHERNEUTRAL, /* ] - 93 */
980 C2_OTHERNEUTRAL, /* ^ - 94 */
981 C2_OTHERNEUTRAL, /* _ - 95 */
982 C2_OTHERNEUTRAL, /* ` - 96 */
983 C2_LEFTTORIGHT, /* a - 97 */
984 C2_LEFTTORIGHT, /* b - 98 */
985 C2_LEFTTORIGHT, /* c - 99 */
986 C2_LEFTTORIGHT, /* d - 100 */
987 C2_LEFTTORIGHT, /* e - 101 */
988 C2_LEFTTORIGHT, /* f - 102 */
989 C2_LEFTTORIGHT, /* g - 103 */
990 C2_LEFTTORIGHT, /* h - 104 */
991 C2_LEFTTORIGHT, /* i - 105 */
992 C2_LEFTTORIGHT, /* j - 106 */
993 C2_LEFTTORIGHT, /* k - 107 */
994 C2_LEFTTORIGHT, /* l - 108 */
995 C2_LEFTTORIGHT, /* m - 109 */
996 C2_LEFTTORIGHT, /* n - 110 */
997 C2_LEFTTORIGHT, /* o - 111 */
998 C2_LEFTTORIGHT, /* p - 112 */
999 C2_LEFTTORIGHT, /* q - 113 */
1000 C2_LEFTTORIGHT, /* r - 114 */
1001 C2_LEFTTORIGHT, /* s - 115 */
1002 C2_LEFTTORIGHT, /* t - 116 */
1003 C2_LEFTTORIGHT, /* u - 117 */
1004 C2_LEFTTORIGHT, /* v - 118 */
1005 C2_LEFTTORIGHT, /* w - 119 */
1006 C2_LEFTTORIGHT, /* x - 120 */
1007 C2_LEFTTORIGHT, /* y - 121 */
1008 C2_LEFTTORIGHT, /* z - 122 */
1009 C2_OTHERNEUTRAL, /* { - 123 */
1010 C2_OTHERNEUTRAL, /* | - 124 */
1011 C2_OTHERNEUTRAL, /* } - 125 */
1012 C2_OTHERNEUTRAL, /* ~ - 126 */
1013 C2_NOTAPPLICABLE, /* \x7f - 127 */
1014 C2_NOTAPPLICABLE, /* € - 128 */
1015 C2_NOTAPPLICABLE, /* � - 129 */
1016 C2_OTHERNEUTRAL, /* ‚ - 130 */
1017 C2_LEFTTORIGHT, /* ƒ - 131 */
1018 C2_OTHERNEUTRAL, /* „ - 132 */
1019 C2_OTHERNEUTRAL, /* … - 133 */
1020 C2_OTHERNEUTRAL, /* † - 134 */
1021 C2_OTHERNEUTRAL, /* ‡ - 135 */
1022 C2_LEFTTORIGHT, /* ˆ - 136 */
1023 C2_EUROPETERMINATOR, /* ‰ - 137 */
1024 C2_LEFTTORIGHT, /* Š - 138 */
1025 C2_OTHERNEUTRAL, /* ‹ - 139 */
1026 C2_LEFTTORIGHT, /* Π- 140 */
1027 C2_NOTAPPLICABLE, /* � - 141 */
1028 C2_NOTAPPLICABLE, /* Ž - 142 */
1029 C2_NOTAPPLICABLE, /* � - 143 */
1030 C2_NOTAPPLICABLE, /* � - 144 */
1031 C2_OTHERNEUTRAL, /* ‘ - 145 */
1032 C2_OTHERNEUTRAL, /* ’ - 146 */
1033 C2_OTHERNEUTRAL, /* “ - 147 */
1034 C2_OTHERNEUTRAL, /* ” - 148 */
1035 C2_OTHERNEUTRAL, /* • - 149 */
1036 C2_OTHERNEUTRAL, /* – - 150 */
1037 C2_OTHERNEUTRAL, /* — - 151 */
1038 C2_LEFTTORIGHT, /* ˜ - 152 */
1039 C2_OTHERNEUTRAL, /* ™ - 153 */
1040 C2_LEFTTORIGHT, /* š - 154 */
1041 C2_OTHERNEUTRAL, /* › - 155 */
1042 C2_LEFTTORIGHT, /* œ - 156 */
1043 C2_NOTAPPLICABLE, /* � - 157 */
1044 C2_NOTAPPLICABLE, /* ž - 158 */
1045 C2_LEFTTORIGHT, /* Ÿ - 159 */
1046 C2_WHITESPACE, /*   - 160 */
1047 C2_OTHERNEUTRAL, /* ¡ - 161 */
1048 C2_EUROPETERMINATOR, /* ¢ - 162 */
1049 C2_EUROPETERMINATOR, /* £ - 163 */
1050 C2_EUROPETERMINATOR, /* ¤ - 164 */
1051 C2_EUROPETERMINATOR, /* ¥ - 165 */
1052 C2_OTHERNEUTRAL, /* ¦ - 166 */
1053 C2_OTHERNEUTRAL, /* § - 167 */
1054 C2_OTHERNEUTRAL, /* ¨ - 168 */
1055 C2_OTHERNEUTRAL, /* © - 169 */
1056 C2_OTHERNEUTRAL, /* ª - 170 */
1057 C2_OTHERNEUTRAL, /* « - 171 */
1058 C2_OTHERNEUTRAL, /* ¬ - 172 */
1059 C2_OTHERNEUTRAL, /* ­ - 173 */
1060 C2_OTHERNEUTRAL, /* ® - 174 */
1061 C2_OTHERNEUTRAL, /* ¯ - 175 */
1062 C2_EUROPETERMINATOR, /* ° - 176 */
1063 C2_EUROPETERMINATOR, /* ± - 177 */
1064 C2_EUROPENUMBER, /* ² - 178 */
1065 C2_EUROPENUMBER, /* ³ - 179 */
1066 C2_OTHERNEUTRAL, /* ´ - 180 */
1067 C2_OTHERNEUTRAL, /* µ - 181 */
1068 C2_OTHERNEUTRAL, /* ¶ - 182 */
1069 C2_OTHERNEUTRAL, /* · - 183 */
1070 C2_OTHERNEUTRAL, /* ¸ - 184 */
1071 C2_EUROPENUMBER, /* ¹ - 185 */
1072 C2_OTHERNEUTRAL, /* º - 186 */
1073 C2_OTHERNEUTRAL, /* » - 187 */
1074 C2_OTHERNEUTRAL, /* ¼ - 188 */
1075 C2_OTHERNEUTRAL, /* ½ - 189 */
1076 C2_OTHERNEUTRAL, /* ¾ - 190 */
1077 C2_OTHERNEUTRAL, /* ¿ - 191 */
1078 C2_LEFTTORIGHT, /* À - 192 */
1079 C2_LEFTTORIGHT, /* Á - 193 */
1080 C2_LEFTTORIGHT, /* Â - 194 */
1081 C2_LEFTTORIGHT, /* Ã - 195 */
1082 C2_LEFTTORIGHT, /* Ä - 196 */
1083 C2_LEFTTORIGHT, /* Å - 197 */
1084 C2_LEFTTORIGHT, /* Æ - 198 */
1085 C2_LEFTTORIGHT, /* Ç - 199 */
1086 C2_LEFTTORIGHT, /* È - 200 */
1087 C2_LEFTTORIGHT, /* É - 201 */
1088 C2_LEFTTORIGHT, /* Ê - 202 */
1089 C2_LEFTTORIGHT, /* Ë - 203 */
1090 C2_LEFTTORIGHT, /* Ì - 204 */
1091 C2_LEFTTORIGHT, /* Í - 205 */
1092 C2_LEFTTORIGHT, /* Î - 206 */
1093 C2_LEFTTORIGHT, /* Ï - 207 */
1094 C2_LEFTTORIGHT, /* Ð - 208 */
1095 C2_LEFTTORIGHT, /* Ñ - 209 */
1096 C2_LEFTTORIGHT, /* Ò - 210 */
1097 C2_LEFTTORIGHT, /* Ó - 211 */
1098 C2_LEFTTORIGHT, /* Ô - 212 */
1099 C2_LEFTTORIGHT, /* Õ - 213 */
1100 C2_LEFTTORIGHT, /* Ö - 214 */
1101 C2_OTHERNEUTRAL, /* × - 215 */
1102 C2_LEFTTORIGHT, /* Ø - 216 */
1103 C2_LEFTTORIGHT, /* Ù - 217 */
1104 C2_LEFTTORIGHT, /* Ú - 218 */
1105 C2_LEFTTORIGHT, /* Û - 219 */
1106 C2_LEFTTORIGHT, /* Ü - 220 */
1107 C2_LEFTTORIGHT, /* Ý - 221 */
1108 C2_LEFTTORIGHT, /* Þ - 222 */
1109 C2_LEFTTORIGHT, /* ß - 223 */
1110 C2_LEFTTORIGHT, /* à - 224 */
1111 C2_LEFTTORIGHT, /* á - 225 */
1112 C2_LEFTTORIGHT, /* â - 226 */
1113 C2_LEFTTORIGHT, /* ã - 227 */
1114 C2_LEFTTORIGHT, /* ä - 228 */
1115 C2_LEFTTORIGHT, /* å - 229 */
1116 C2_LEFTTORIGHT, /* æ - 230 */
1117 C2_LEFTTORIGHT, /* ç - 231 */
1118 C2_LEFTTORIGHT, /* è - 232 */
1119 C2_LEFTTORIGHT, /* é - 233 */
1120 C2_LEFTTORIGHT, /* ê - 234 */
1121 C2_LEFTTORIGHT, /* ë - 235 */
1122 C2_LEFTTORIGHT, /* ì - 236 */
1123 C2_LEFTTORIGHT, /* í - 237 */
1124 C2_LEFTTORIGHT, /* î - 238 */
1125 C2_LEFTTORIGHT, /* ï - 239 */
1126 C2_LEFTTORIGHT, /* ð - 240 */
1127 C2_LEFTTORIGHT, /* ñ - 241 */
1128 C2_LEFTTORIGHT, /* ò - 242 */
1129 C2_LEFTTORIGHT, /* ó - 243 */
1130 C2_LEFTTORIGHT, /* ô - 244 */
1131 C2_LEFTTORIGHT, /* õ - 245 */
1132 C2_LEFTTORIGHT, /* ö - 246 */
1133 C2_OTHERNEUTRAL, /* ÷ - 247 */
1134 C2_LEFTTORIGHT, /* ø - 248 */
1135 C2_LEFTTORIGHT, /* ù - 249 */
1136 C2_LEFTTORIGHT, /* ú - 250 */
1137 C2_LEFTTORIGHT, /* û - 251 */
1138 C2_LEFTTORIGHT, /* ü - 252 */
1139 C2_LEFTTORIGHT, /* ý - 253 */
1140 C2_LEFTTORIGHT, /* þ - 254 */
1141 C2_LEFTTORIGHT /* ÿ - 255 */
1144 const WORD OLE2NLS_CT_CType3_LUT[] = {
1145 0x0000, /* - 0 */
1146 0x0000, /* - 1 */
1147 0x0000, /* - 2 */
1148 0x0000, /* - 3 */
1149 0x0000, /* - 4 */
1150 0x0000, /* - 5 */
1151 0x0000, /* - 6 */
1152 0x0000, /* - 7 */
1153 0x0000, /* - 8 */
1154 0x0008, /* - 9 */
1155 0x0008, /* - 10 */
1156 0x0008, /* - 11 */
1157 0x0008, /* - 12 */
1158 0x0008, /* - 13 */
1159 0x0000, /* - 14 */
1160 0x0000, /* - 15 */
1161 0x0000, /* - 16 */
1162 0x0000, /* - 17 */
1163 0x0000, /* - 18 */
1164 0x0000, /* - 19 */
1165 0x0000, /* - 20 */
1166 0x0000, /* - 21 */
1167 0x0000, /* - 22 */
1168 0x0000, /* - 23 */
1169 0x0000, /* - 24 */
1170 0x0000, /* - 25 */
1171 0x0000, /* - 26 */
1172 0x0000, /* - 27 */
1173 0x0000, /* - 28 */
1174 0x0000, /* - 29 */
1175 0x0000, /* - 30 */
1176 0x0000, /* - 31 */
1177 0x0048, /* - 32 */
1178 0x0048, /* ! - 33 */
1179 0x0448, /* " - 34 */ /* " */
1180 0x0048, /* # - 35 */
1181 0x0448, /* $ - 36 */
1182 0x0048, /* % - 37 */
1183 0x0048, /* & - 38 */
1184 0x0440, /* ' - 39 */
1185 0x0048, /* ( - 40 */
1186 0x0048, /* ) - 41 */
1187 0x0048, /* * - 42 */
1188 0x0048, /* + - 43 */
1189 0x0048, /* , - 44 */
1190 0x0440, /* - - 45 */
1191 0x0048, /* . - 46 */
1192 0x0448, /* / - 47 */
1193 0x0040, /* 0 - 48 */
1194 0x0040, /* 1 - 49 */
1195 0x0040, /* 2 - 50 */
1196 0x0040, /* 3 - 51 */
1197 0x0040, /* 4 - 52 */
1198 0x0040, /* 5 - 53 */
1199 0x0040, /* 6 - 54 */
1200 0x0040, /* 7 - 55 */
1201 0x0040, /* 8 - 56 */
1202 0x0040, /* 9 - 57 */
1203 0x0048, /* : - 58 */
1204 0x0048, /* ; - 59 */
1205 0x0048, /* < - 60 */
1206 0x0448, /* = - 61 */
1207 0x0048, /* > - 62 */
1208 0x0048, /* ? - 63 */
1209 0x0448, /* @ - 64 */
1210 0x8040, /* A - 65 */
1211 0x8040, /* B - 66 */
1212 0x8040, /* C - 67 */
1213 0x8040, /* D - 68 */
1214 0x8040, /* E - 69 */
1215 0x8040, /* F - 70 */
1216 0x8040, /* G - 71 */
1217 0x8040, /* H - 72 */
1218 0x8040, /* I - 73 */
1219 0x8040, /* J - 74 */
1220 0x8040, /* K - 75 */
1221 0x8040, /* L - 76 */
1222 0x8040, /* M - 77 */
1223 0x8040, /* N - 78 */
1224 0x8040, /* O - 79 */
1225 0x8040, /* P - 80 */
1226 0x8040, /* Q - 81 */
1227 0x8040, /* R - 82 */
1228 0x8040, /* S - 83 */
1229 0x8040, /* T - 84 */
1230 0x8040, /* U - 85 */
1231 0x8040, /* V - 86 */
1232 0x8040, /* W - 87 */
1233 0x8040, /* X - 88 */
1234 0x8040, /* Y - 89 */
1235 0x8040, /* Z - 90 */
1236 0x0048, /* [ - 91 */
1237 0x0448, /* \ - 92 */
1238 0x0048, /* ] - 93 */
1239 0x0448, /* ^ - 94 */
1240 0x0448, /* _ - 95 */
1241 0x0448, /* ` - 96 */
1242 0x8040, /* a - 97 */
1243 0x8040, /* b - 98 */
1244 0x8040, /* c - 99 */
1245 0x8040, /* d - 100 */
1246 0x8040, /* e - 101 */
1247 0x8040, /* f - 102 */
1248 0x8040, /* g - 103 */
1249 0x8040, /* h - 104 */
1250 0x8040, /* i - 105 */
1251 0x8040, /* j - 106 */
1252 0x8040, /* k - 107 */
1253 0x8040, /* l - 108 */
1254 0x8040, /* m - 109 */
1255 0x8040, /* n - 110 */
1256 0x8040, /* o - 111 */
1257 0x8040, /* p - 112 */
1258 0x8040, /* q - 113 */
1259 0x8040, /* r - 114 */
1260 0x8040, /* s - 115 */
1261 0x8040, /* t - 116 */
1262 0x8040, /* u - 117 */
1263 0x8040, /* v - 118 */
1264 0x8040, /* w - 119 */
1265 0x8040, /* x - 120 */
1266 0x8040, /* y - 121 */
1267 0x8040, /* z - 122 */
1268 0x0048, /* { - 123 */
1269 0x0048, /* | - 124 */
1270 0x0048, /* } - 125 */
1271 0x0448, /* ~ - 126 */
1272 0x0000, /* \x7f - 127 */
1273 0x0000, /* € - 128 */
1274 0x0000, /* � - 129 */
1275 0x0008, /* ‚ - 130 */
1276 0x8000, /* ƒ - 131 */
1277 0x0008, /* „ - 132 */
1278 0x0008, /* … - 133 */
1279 0x0008, /* † - 134 */
1280 0x0008, /* ‡ - 135 */
1281 0x0001, /* ˆ - 136 */
1282 0x0008, /* ‰ - 137 */
1283 0x8003, /* Š - 138 */
1284 0x0008, /* ‹ - 139 */
1285 0x8000, /* Π- 140 */
1286 0x0000, /* � - 141 */
1287 0x0000, /* Ž - 142 */
1288 0x0000, /* � - 143 */
1289 0x0000, /* � - 144 */
1290 0x0088, /* ‘ - 145 */
1291 0x0088, /* ’ - 146 */
1292 0x0088, /* “ - 147 */
1293 0x0088, /* ” - 148 */
1294 0x0008, /* • - 149 */
1295 0x0400, /* – - 150 */
1296 0x0400, /* — - 151 */
1297 0x0408, /* ˜ - 152 */
1298 0x0000, /* ™ - 153 */
1299 0x8003, /* š - 154 */
1300 0x0008, /* › - 155 */
1301 0x8000, /* œ - 156 */
1302 0x0000, /* � - 157 */
1303 0x0000, /* ž - 158 */
1304 0x8003, /* Ÿ - 159 */
1305 0x0008, /*   - 160 */
1306 0x0008, /* ¡ - 161 */
1307 0x0048, /* ¢ - 162 */
1308 0x0048, /* £ - 163 */
1309 0x0008, /* ¤ - 164 */
1310 0x0048, /* ¥ - 165 */
1311 0x0048, /* ¦ - 166 */
1312 0x0008, /* § - 167 */
1313 0x0408, /* ¨ - 168 */
1314 0x0008, /* © - 169 */
1315 0x0400, /* ª - 170 */
1316 0x0008, /* « - 171 */
1317 0x0048, /* ¬ - 172 */
1318 0x0408, /* ­ - 173 */
1319 0x0008, /* ® - 174 */
1320 0x0448, /* ¯ - 175 */
1321 0x0008, /* ° - 176 */
1322 0x0008, /* ± - 177 */
1323 0x0000, /* ² - 178 */
1324 0x0000, /* ³ - 179 */
1325 0x0408, /* ´ - 180 */
1326 0x0008, /* µ - 181 */
1327 0x0008, /* ¶ - 182 */
1328 0x0008, /* · - 183 */
1329 0x0408, /* ¸ - 184 */
1330 0x0000, /* ¹ - 185 */
1331 0x0400, /* º - 186 */
1332 0x0008, /* » - 187 */
1333 0x0000, /* ¼ - 188 */
1334 0x0000, /* ½ - 189 */
1335 0x0000, /* ¾ - 190 */
1336 0x0008, /* ¿ - 191 */
1337 0x8003, /* À - 192 */
1338 0x8003, /* Á - 193 */
1339 0x8003, /* Â - 194 */
1340 0x8003, /* Ã - 195 */
1341 0x8003, /* Ä - 196 */
1342 0x8003, /* Å - 197 */
1343 0x8000, /* Æ - 198 */
1344 0x8003, /* Ç - 199 */
1345 0x8003, /* È - 200 */
1346 0x8003, /* É - 201 */
1347 0x8003, /* Ê - 202 */
1348 0x8003, /* Ë - 203 */
1349 0x8003, /* Ì - 204 */
1350 0x8003, /* Í - 205 */
1351 0x8003, /* Î - 206 */
1352 0x8003, /* Ï - 207 */
1353 0x8000, /* Ð - 208 */
1354 0x8003, /* Ñ - 209 */
1355 0x8003, /* Ò - 210 */
1356 0x8003, /* Ó - 211 */
1357 0x8003, /* Ô - 212 */
1358 0x8003, /* Õ - 213 */
1359 0x8003, /* Ö - 214 */
1360 0x0008, /* × - 215 */
1361 0x8003, /* Ø - 216 */
1362 0x8003, /* Ù - 217 */
1363 0x8003, /* Ú - 218 */
1364 0x8003, /* Û - 219 */
1365 0x8003, /* Ü - 220 */
1366 0x8003, /* Ý - 221 */
1367 0x8000, /* Þ - 222 */
1368 0x8000, /* ß - 223 */
1369 0x8003, /* à - 224 */
1370 0x8003, /* á - 225 */
1371 0x8003, /* â - 226 */
1372 0x8003, /* ã - 227 */
1373 0x8003, /* ä - 228 */
1374 0x8003, /* å - 229 */
1375 0x8000, /* æ - 230 */
1376 0x8003, /* ç - 231 */
1377 0x8003, /* è - 232 */
1378 0x8003, /* é - 233 */
1379 0x8003, /* ê - 234 */
1380 0x8003, /* ë - 235 */
1381 0x8003, /* ì - 236 */
1382 0x8003, /* í - 237 */
1383 0x8003, /* î - 238 */
1384 0x8003, /* ï - 239 */
1385 0x8000, /* ð - 240 */
1386 0x8003, /* ñ - 241 */
1387 0x8003, /* ò - 242 */
1388 0x8003, /* ó - 243 */
1389 0x8003, /* ô - 244 */
1390 0x8003, /* õ - 245 */
1391 0x8003, /* ö - 246 */
1392 0x0008, /* ÷ - 247 */
1393 0x8003, /* ø - 248 */
1394 0x8003, /* ù - 249 */
1395 0x8003, /* ú - 250 */
1396 0x8003, /* û - 251 */
1397 0x8003, /* ü - 252 */
1398 0x8003, /* ý - 253 */
1399 0x8000, /* þ - 254 */
1400 0x8003 /* ÿ - 255 */
1403 /******************************************************************************
1404 * GetStringType16 [OLE2NLS.7]
1406 BOOL16 WINAPI GetStringType16(LCID locale,DWORD dwInfoType,LPCSTR src,
1407 INT16 cchSrc,LPWORD chartype)
1409 return GetStringTypeExA(locale,dwInfoType,src,cchSrc,chartype);
1411 /******************************************************************************
1412 * GetStringType32A [KERNEL32.396]
1414 BOOL WINAPI GetStringTypeA(LCID locale,DWORD dwInfoType,LPCSTR src,
1415 INT cchSrc,LPWORD chartype)
1417 return GetStringTypeExA(locale,dwInfoType,src,cchSrc,chartype);
1420 /******************************************************************************
1421 * GetStringTypeEx32A [KERNEL32.397]
1423 * FIXME: Ignores the locale.
1425 BOOL WINAPI GetStringTypeExA(LCID locale,DWORD dwInfoType,LPCSTR src,
1426 INT cchSrc,LPWORD chartype)
1428 int i;
1430 if ((src==NULL) || (chartype==NULL) || (src==(LPSTR)chartype))
1432 SetLastError(ERROR_INVALID_PARAMETER);
1433 return FALSE;
1436 if (cchSrc==-1)
1437 cchSrc=lstrlenA(src)+1;
1439 switch (dwInfoType) {
1440 case CT_CTYPE1:
1441 for (i=0;i<cchSrc;i++)
1443 chartype[i] = 0;
1444 if (isdigit(src[i])) chartype[i]|=C1_DIGIT;
1445 if (isalpha(src[i])) chartype[i]|=C1_ALPHA;
1446 if (islower(src[i])) chartype[i]|=C1_LOWER;
1447 if (isupper(src[i])) chartype[i]|=C1_UPPER;
1448 if (isspace(src[i])) chartype[i]|=C1_SPACE;
1449 if (ispunct(src[i])) chartype[i]|=C1_PUNCT;
1450 if (iscntrl(src[i])) chartype[i]|=C1_CNTRL;
1451 /* FIXME: isblank() is a GNU extension */
1452 /* if (isblank(src[i])) chartype[i]|=C1_BLANK; */
1453 if ((src[i] == ' ') || (src[i] == '\t')) chartype[i]|=C1_BLANK;
1454 /* C1_XDIGIT */
1456 return TRUE;
1458 case CT_CTYPE2:
1459 for (i=0;i<cchSrc;i++)
1461 chartype[i]=(WORD)CT_CType2_LUT[i];
1463 return TRUE;
1465 case CT_CTYPE3:
1466 for (i=0;i<cchSrc;i++)
1468 chartype[i]=OLE2NLS_CT_CType3_LUT[i];
1470 return TRUE;
1472 default:
1473 ERR(ole,"Unknown dwInfoType:%ld\n",dwInfoType);
1474 return FALSE;
1478 /******************************************************************************
1479 * GetStringType32W [KERNEL32.399]
1481 * NOTES
1482 * Yes, this is missing LCID locale. MS fault.
1484 BOOL WINAPI GetStringTypeW(DWORD dwInfoType,LPCWSTR src,INT cchSrc,
1485 LPWORD chartype)
1487 return GetStringTypeExW(0/*defaultlocale*/,dwInfoType,src,cchSrc,chartype);
1490 /******************************************************************************
1491 * GetStringTypeEx32W [KERNEL32.398]
1493 * FIXME: unicode chars are assumed chars
1495 BOOL WINAPI GetStringTypeExW(LCID locale,DWORD dwInfoType,LPCWSTR src,
1496 INT cchSrc,LPWORD chartype)
1498 int i;
1501 if (cchSrc==-1)
1502 cchSrc=lstrlenW(src)+1;
1504 switch (dwInfoType) {
1505 case CT_CTYPE2:
1506 FIXME(ole,"CT_CTYPE2 not supported.\n");
1507 return FALSE;
1508 case CT_CTYPE3:
1509 FIXME(ole,"CT_CTYPE3 not supported.\n");
1510 return FALSE;
1511 default:break;
1513 for (i=0;i<cchSrc;i++) {
1514 chartype[i] = 0;
1515 if (isdigit(src[i])) chartype[i]|=C1_DIGIT;
1516 if (isalpha(src[i])) chartype[i]|=C1_ALPHA;
1517 if (islower(src[i])) chartype[i]|=C1_LOWER;
1518 if (isupper(src[i])) chartype[i]|=C1_UPPER;
1519 if (isspace(src[i])) chartype[i]|=C1_SPACE;
1520 if (ispunct(src[i])) chartype[i]|=C1_PUNCT;
1521 if (iscntrl(src[i])) chartype[i]|=C1_CNTRL;
1522 /* FIXME: isblank() is a GNU extension */
1523 /* if (isblank(src[i])) chartype[i]|=C1_BLANK; */
1524 if ((src[i] == ' ') || (src[i] == '\t')) chartype[i]|=C1_BLANK;
1525 /* C1_XDIGIT */
1527 return TRUE;
1530 /*****************************************************************
1531 * WINE_GetLanguageName [internal]
1533 * FIXME: Windows keeps language names in a string table
1534 * resource in VER.DLL ...
1536 LPCSTR WINE_GetLanguageName( UINT langid )
1538 int i;
1539 for ( i = 0; languages[i].langid != 0; i++ )
1540 if ( langid == languages[i].langid )
1541 break;
1543 return languages[i].langname;
1546 static const unsigned char LCM_Unicode_LUT[] = {
1547 6 , 3, /* - 1 */
1548 6 , 4, /* - 2 */
1549 6 , 5, /* - 3 */
1550 6 , 6, /* - 4 */
1551 6 , 7, /* - 5 */
1552 6 , 8, /* - 6 */
1553 6 , 9, /* - 7 */
1554 6 , 10, /* - 8 */
1555 7 , 5, /* - 9 */
1556 7 , 6, /* - 10 */
1557 7 , 7, /* - 11 */
1558 7 , 8, /* - 12 */
1559 7 , 9, /* - 13 */
1560 6 , 11, /* - 14 */
1561 6 , 12, /* - 15 */
1562 6 , 13, /* - 16 */
1563 6 , 14, /* - 17 */
1564 6 , 15, /* - 18 */
1565 6 , 16, /* - 19 */
1566 6 , 17, /* - 20 */
1567 6 , 18, /* - 21 */
1568 6 , 19, /* - 22 */
1569 6 , 20, /* - 23 */
1570 6 , 21, /* - 24 */
1571 6 , 22, /* - 25 */
1572 6 , 23, /* - 26 */
1573 6 , 24, /* - 27 */
1574 6 , 25, /* - 28 */
1575 6 , 26, /* - 29 */
1576 6 , 27, /* - 30 */
1577 6 , 28, /* - 31 */
1578 7 , 2, /* - 32 */
1579 7 , 28, /* ! - 33 */
1580 7 , 29, /* " - 34 */ /* " */
1581 7 , 31, /* # - 35 */
1582 7 , 33, /* $ - 36 */
1583 7 , 35, /* % - 37 */
1584 7 , 37, /* & - 38 */
1585 6 , 128, /* ' - 39 */
1586 7 , 39, /* ( - 40 */
1587 7 , 42, /* ) - 41 */
1588 7 , 45, /* * - 42 */
1589 8 , 3, /* + - 43 */
1590 7 , 47, /* , - 44 */
1591 6 , 130, /* - - 45 */
1592 7 , 51, /* . - 46 */
1593 7 , 53, /* / - 47 */
1594 12 , 3, /* 0 - 48 */
1595 12 , 33, /* 1 - 49 */
1596 12 , 51, /* 2 - 50 */
1597 12 , 70, /* 3 - 51 */
1598 12 , 88, /* 4 - 52 */
1599 12 , 106, /* 5 - 53 */
1600 12 , 125, /* 6 - 54 */
1601 12 , 144, /* 7 - 55 */
1602 12 , 162, /* 8 - 56 */
1603 12 , 180, /* 9 - 57 */
1604 7 , 55, /* : - 58 */
1605 7 , 58, /* ; - 59 */
1606 8 , 14, /* < - 60 */
1607 8 , 18, /* = - 61 */
1608 8 , 20, /* > - 62 */
1609 7 , 60, /* ? - 63 */
1610 7 , 62, /* @ - 64 */
1611 14 , 2, /* A - 65 */
1612 14 , 9, /* B - 66 */
1613 14 , 10, /* C - 67 */
1614 14 , 26, /* D - 68 */
1615 14 , 33, /* E - 69 */
1616 14 , 35, /* F - 70 */
1617 14 , 37, /* G - 71 */
1618 14 , 44, /* H - 72 */
1619 14 , 50, /* I - 73 */
1620 14 , 53, /* J - 74 */
1621 14 , 54, /* K - 75 */
1622 14 , 72, /* L - 76 */
1623 14 , 81, /* M - 77 */
1624 14 , 112, /* N - 78 */
1625 14 , 124, /* O - 79 */
1626 14 , 126, /* P - 80 */
1627 14 , 137, /* Q - 81 */
1628 14 , 138, /* R - 82 */
1629 14 , 145, /* S - 83 */
1630 14 , 153, /* T - 84 */
1631 14 , 159, /* U - 85 */
1632 14 , 162, /* V - 86 */
1633 14 , 164, /* W - 87 */
1634 14 , 166, /* X - 88 */
1635 14 , 167, /* Y - 89 */
1636 14 , 169, /* Z - 90 */
1637 7 , 63, /* [ - 91 */
1638 7 , 65, /* \ - 92 */
1639 7 , 66, /* ] - 93 */
1640 7 , 67, /* ^ - 94 */
1641 7 , 68, /* _ - 95 */
1642 7 , 72, /* ` - 96 */
1643 14 , 2, /* a - 97 */
1644 14 , 9, /* b - 98 */
1645 14 , 10, /* c - 99 */
1646 14 , 26, /* d - 100 */
1647 14 , 33, /* e - 101 */
1648 14 , 35, /* f - 102 */
1649 14 , 37, /* g - 103 */
1650 14 , 44, /* h - 104 */
1651 14 , 50, /* i - 105 */
1652 14 , 53, /* j - 106 */
1653 14 , 54, /* k - 107 */
1654 14 , 72, /* l - 108 */
1655 14 , 81, /* m - 109 */
1656 14 , 112, /* n - 110 */
1657 14 , 124, /* o - 111 */
1658 14 , 126, /* p - 112 */
1659 14 , 137, /* q - 113 */
1660 14 , 138, /* r - 114 */
1661 14 , 145, /* s - 115 */
1662 14 , 153, /* t - 116 */
1663 14 , 159, /* u - 117 */
1664 14 , 162, /* v - 118 */
1665 14 , 164, /* w - 119 */
1666 14 , 166, /* x - 120 */
1667 14 , 167, /* y - 121 */
1668 14 , 169, /* z - 122 */
1669 7 , 74, /* { - 123 */
1670 7 , 76, /* | - 124 */
1671 7 , 78, /* } - 125 */
1672 7 , 80, /* ~ - 126 */
1673 6 , 29, /* \x7f - 127 */
1674 6 , 30, /* € - 128 */
1675 6 , 31, /* � - 129 */
1676 7 , 123, /* ‚ - 130 */
1677 14 , 35, /* ƒ - 131 */
1678 7 , 127, /* „ - 132 */
1679 10 , 21, /* … - 133 */
1680 10 , 15, /* † - 134 */
1681 10 , 16, /* ‡ - 135 */
1682 7 , 67, /* ˆ - 136 */
1683 10 , 22, /* ‰ - 137 */
1684 14 , 145, /* Š - 138 */
1685 7 , 136, /* ‹ - 139 */
1686 14 + 16 , 124, /* Π- 140 */
1687 6 , 43, /* � - 141 */
1688 6 , 44, /* Ž - 142 */
1689 6 , 45, /* � - 143 */
1690 6 , 46, /* � - 144 */
1691 7 , 121, /* ‘ - 145 */
1692 7 , 122, /* ’ - 146 */
1693 7 , 125, /* “ - 147 */
1694 7 , 126, /* ” - 148 */
1695 10 , 17, /* • - 149 */
1696 6 , 137, /* – - 150 */
1697 6 , 139, /* — - 151 */
1698 7 , 93, /* ˜ - 152 */
1699 14 , 156, /* ™ - 153 */
1700 14 , 145, /* š - 154 */
1701 7 , 137, /* › - 155 */
1702 14 + 16 , 124, /* œ - 156 */
1703 6 , 59, /* � - 157 */
1704 6 , 60, /* ž - 158 */
1705 14 , 167, /* Ÿ - 159 */
1706 7 , 4, /*   - 160 */
1707 7 , 81, /* ¡ - 161 */
1708 10 , 2, /* ¢ - 162 */
1709 10 , 3, /* £ - 163 */
1710 10 , 4, /* ¤ - 164 */
1711 10 , 5, /* ¥ - 165 */
1712 7 , 82, /* ¦ - 166 */
1713 10 , 6, /* § - 167 */
1714 7 , 83, /* ¨ - 168 */
1715 10 , 7, /* © - 169 */
1716 14 , 2, /* ª - 170 */
1717 8 , 24, /* « - 171 */
1718 10 , 8, /* ¬ - 172 */
1719 6 , 131, /* ­ - 173 */
1720 10 , 9, /* ® - 174 */
1721 7 , 84, /* ¯ - 175 */
1722 10 , 10, /* ° - 176 */
1723 8 , 23, /* ± - 177 */
1724 12 , 51, /* ² - 178 */
1725 12 , 70, /* ³ - 179 */
1726 7 , 85, /* ´ - 180 */
1727 10 , 11, /* µ - 181 */
1728 10 , 12, /* ¶ - 182 */
1729 10 , 13, /* · - 183 */
1730 7 , 86, /* ¸ - 184 */
1731 12 , 33, /* ¹ - 185 */
1732 14 , 124, /* º - 186 */
1733 8 , 26, /* » - 187 */
1734 12 , 21, /* ¼ - 188 */
1735 12 , 25, /* ½ - 189 */
1736 12 , 29, /* ¾ - 190 */
1737 7 , 87, /* ¿ - 191 */
1738 14 , 2, /* À - 192 */
1739 14 , 2, /* Á - 193 */
1740 14 , 2, /* Â - 194 */
1741 14 , 2, /* Ã - 195 */
1742 14 , 2, /* Ä - 196 */
1743 14 , 2, /* Å - 197 */
1744 14 + 16 , 2, /* Æ - 198 */
1745 14 , 10, /* Ç - 199 */
1746 14 , 33, /* È - 200 */
1747 14 , 33, /* É - 201 */
1748 14 , 33, /* Ê - 202 */
1749 14 , 33, /* Ë - 203 */
1750 14 , 50, /* Ì - 204 */
1751 14 , 50, /* Í - 205 */
1752 14 , 50, /* Î - 206 */
1753 14 , 50, /* Ï - 207 */
1754 14 , 26, /* Ð - 208 */
1755 14 , 112, /* Ñ - 209 */
1756 14 , 124, /* Ò - 210 */
1757 14 , 124, /* Ó - 211 */
1758 14 , 124, /* Ô - 212 */
1759 14 , 124, /* Õ - 213 */
1760 14 , 124, /* Ö - 214 */
1761 8 , 28, /* × - 215 */
1762 14 , 124, /* Ø - 216 */
1763 14 , 159, /* Ù - 217 */
1764 14 , 159, /* Ú - 218 */
1765 14 , 159, /* Û - 219 */
1766 14 , 159, /* Ü - 220 */
1767 14 , 167, /* Ý - 221 */
1768 14 + 32 , 153, /* Þ - 222 */
1769 14 + 48 , 145, /* ß - 223 */
1770 14 , 2, /* à - 224 */
1771 14 , 2, /* á - 225 */
1772 14 , 2, /* â - 226 */
1773 14 , 2, /* ã - 227 */
1774 14 , 2, /* ä - 228 */
1775 14 , 2, /* å - 229 */
1776 14 + 16 , 2, /* æ - 230 */
1777 14 , 10, /* ç - 231 */
1778 14 , 33, /* è - 232 */
1779 14 , 33, /* é - 233 */
1780 14 , 33, /* ê - 234 */
1781 14 , 33, /* ë - 235 */
1782 14 , 50, /* ì - 236 */
1783 14 , 50, /* í - 237 */
1784 14 , 50, /* î - 238 */
1785 14 , 50, /* ï - 239 */
1786 14 , 26, /* ð - 240 */
1787 14 , 112, /* ñ - 241 */
1788 14 , 124, /* ò - 242 */
1789 14 , 124, /* ó - 243 */
1790 14 , 124, /* ô - 244 */
1791 14 , 124, /* õ - 245 */
1792 14 , 124, /* ö - 246 */
1793 8 , 29, /* ÷ - 247 */
1794 14 , 124, /* ø - 248 */
1795 14 , 159, /* ù - 249 */
1796 14 , 159, /* ú - 250 */
1797 14 , 159, /* û - 251 */
1798 14 , 159, /* ü - 252 */
1799 14 , 167, /* ý - 253 */
1800 14 + 32 , 153, /* þ - 254 */
1801 14 , 167 /* ÿ - 255 */ };
1803 static const unsigned char LCM_Unicode_LUT_2[] = { 33, 44, 145 };
1805 #define LCM_Diacritic_Start 131
1807 static const unsigned char LCM_Diacritic_LUT[] = {
1808 123, /* ƒ - 131 */
1809 2, /* „ - 132 */
1810 2, /* … - 133 */
1811 2, /* † - 134 */
1812 2, /* ‡ - 135 */
1813 3, /* ˆ - 136 */
1814 2, /* ‰ - 137 */
1815 20, /* Š - 138 */
1816 2, /* ‹ - 139 */
1817 2, /* Π- 140 */
1818 2, /* � - 141 */
1819 2, /* Ž - 142 */
1820 2, /* � - 143 */
1821 2, /* � - 144 */
1822 2, /* ‘ - 145 */
1823 2, /* ’ - 146 */
1824 2, /* “ - 147 */
1825 2, /* ” - 148 */
1826 2, /* • - 149 */
1827 2, /* – - 150 */
1828 2, /* — - 151 */
1829 2, /* ˜ - 152 */
1830 2, /* ™ - 153 */
1831 20, /* š - 154 */
1832 2, /* › - 155 */
1833 2, /* œ - 156 */
1834 2, /* � - 157 */
1835 2, /* ž - 158 */
1836 19, /* Ÿ - 159 */
1837 2, /*   - 160 */
1838 2, /* ¡ - 161 */
1839 2, /* ¢ - 162 */
1840 2, /* £ - 163 */
1841 2, /* ¤ - 164 */
1842 2, /* ¥ - 165 */
1843 2, /* ¦ - 166 */
1844 2, /* § - 167 */
1845 2, /* ¨ - 168 */
1846 2, /* © - 169 */
1847 3, /* ª - 170 */
1848 2, /* « - 171 */
1849 2, /* ¬ - 172 */
1850 2, /* ­ - 173 */
1851 2, /* ® - 174 */
1852 2, /* ¯ - 175 */
1853 2, /* ° - 176 */
1854 2, /* ± - 177 */
1855 2, /* ² - 178 */
1856 2, /* ³ - 179 */
1857 2, /* ´ - 180 */
1858 2, /* µ - 181 */
1859 2, /* ¶ - 182 */
1860 2, /* · - 183 */
1861 2, /* ¸ - 184 */
1862 2, /* ¹ - 185 */
1863 3, /* º - 186 */
1864 2, /* » - 187 */
1865 2, /* ¼ - 188 */
1866 2, /* ½ - 189 */
1867 2, /* ¾ - 190 */
1868 2, /* ¿ - 191 */
1869 15, /* À - 192 */
1870 14, /* Á - 193 */
1871 18, /* Â - 194 */
1872 25, /* Ã - 195 */
1873 19, /* Ä - 196 */
1874 26, /* Å - 197 */
1875 2, /* Æ - 198 */
1876 28, /* Ç - 199 */
1877 15, /* È - 200 */
1878 14, /* É - 201 */
1879 18, /* Ê - 202 */
1880 19, /* Ë - 203 */
1881 15, /* Ì - 204 */
1882 14, /* Í - 205 */
1883 18, /* Î - 206 */
1884 19, /* Ï - 207 */
1885 104, /* Ð - 208 */
1886 25, /* Ñ - 209 */
1887 15, /* Ò - 210 */
1888 14, /* Ó - 211 */
1889 18, /* Ô - 212 */
1890 25, /* Õ - 213 */
1891 19, /* Ö - 214 */
1892 2, /* × - 215 */
1893 33, /* Ø - 216 */
1894 15, /* Ù - 217 */
1895 14, /* Ú - 218 */
1896 18, /* Û - 219 */
1897 19, /* Ü - 220 */
1898 14, /* Ý - 221 */
1899 2, /* Þ - 222 */
1900 2, /* ß - 223 */
1901 15, /* à - 224 */
1902 14, /* á - 225 */
1903 18, /* â - 226 */
1904 25, /* ã - 227 */
1905 19, /* ä - 228 */
1906 26, /* å - 229 */
1907 2, /* æ - 230 */
1908 28, /* ç - 231 */
1909 15, /* è - 232 */
1910 14, /* é - 233 */
1911 18, /* ê - 234 */
1912 19, /* ë - 235 */
1913 15, /* ì - 236 */
1914 14, /* í - 237 */
1915 18, /* î - 238 */
1916 19, /* ï - 239 */
1917 104, /* ð - 240 */
1918 25, /* ñ - 241 */
1919 15, /* ò - 242 */
1920 14, /* ó - 243 */
1921 18, /* ô - 244 */
1922 25, /* õ - 245 */
1923 19, /* ö - 246 */
1924 2, /* ÷ - 247 */
1925 33, /* ø - 248 */
1926 15, /* ù - 249 */
1927 14, /* ú - 250 */
1928 18, /* û - 251 */
1929 19, /* ü - 252 */
1930 14, /* ý - 253 */
1931 2, /* þ - 254 */
1932 19, /* ÿ - 255 */
1935 /******************************************************************************
1936 * OLE2NLS_isPunctuation [INTERNAL]
1938 static int OLE2NLS_isPunctuation(unsigned char c)
1940 /* "punctuation character" in this context is a character which is
1941 considered "less important" during word sort comparison.
1942 See LCMapString implementation for the precise definition
1943 of "less important". */
1945 return (LCM_Unicode_LUT[-2+2*c]==6);
1948 /******************************************************************************
1949 * OLE2NLS_isNonSpacing [INTERNAL]
1951 static int OLE2NLS_isNonSpacing(unsigned char c)
1953 /* This function is used by LCMapString32A. Characters
1954 for which it returns true are ignored when mapping a
1955 string with NORM_IGNORENONSPACE */
1956 return ((c==136) || (c==170) || (c==186));
1959 /******************************************************************************
1960 * OLE2NLS_isSymbol [INTERNAL]
1962 static int OLE2NLS_isSymbol(unsigned char c)
1964 /* This function is used by LCMapString32A. Characters
1965 for which it returns true are ignored when mapping a
1966 string with NORM_IGNORESYMBOLS */
1967 return ( (c!=0) && !IsCharAlphaNumericA(c) );
1970 /******************************************************************************
1971 * identity [Internal]
1973 static int identity(int c)
1975 return c;
1978 /*************************************************************************
1979 * LCMapString32A [KERNEL32.492]
1981 * Convert a string, or generate a sort key from it.
1983 * If (mapflags & LCMAP_SORTKEY), the function will generate
1984 * a sort key for the source string. Else, it will convert it
1985 * accordingly to the flags LCMAP_UPPERCASE, LCMAP_LOWERCASE,...
1987 * RETURNS
1988 * Error : 0.
1989 * Success : length of the result string.
1991 * NOTES
1992 * If called with scrlen = -1, the function will compute the length
1993 * of the 0-terminated string strsrc by itself.
1995 * If called with dstlen = 0, returns the buffer length that
1996 * would be required.
1998 * NORM_IGNOREWIDTH means to compare ASCII and wide characters
1999 * as if they are equal.
2000 * In the only code page implemented so far, there may not be
2001 * wide characters in strings passed to LCMapString32A,
2002 * so there is nothing to be done for this flag.
2004 INT WINAPI LCMapStringA(
2005 LCID lcid /* locale identifier created with MAKELCID;
2006 LOCALE_SYSTEM_DEFAULT and LOCALE_USER_DEFAULT are
2007 predefined values. */,
2008 DWORD mapflags /* flags */,
2009 LPCSTR srcstr /* source buffer */,
2010 INT srclen /* source length */,
2011 LPSTR dststr /* destination buffer */,
2012 INT dstlen /* destination buffer length */)
2014 int i;
2016 TRACE(string,"(0x%04lx,0x%08lx,%s,%d,%p,%d)\n",
2017 lcid,mapflags,srcstr,srclen,dststr,dstlen);
2019 if ( ((dstlen!=0) && (dststr==NULL)) || (srcstr==NULL) )
2021 ERR(ole, "(src=%s,dest=%s): Invalid NULL string\n", srcstr, dststr);
2022 SetLastError(ERROR_INVALID_PARAMETER);
2023 return 0;
2025 if (srclen == -1)
2026 srclen = lstrlenA(srcstr) + 1 ; /* (include final '\0') */
2028 #define LCMAPSTRINGA_SUPPORTED_FLAGS (LCMAP_UPPERCASE | \
2029 LCMAP_LOWERCASE | \
2030 LCMAP_SORTKEY | \
2031 NORM_IGNORECASE | \
2032 NORM_IGNORENONSPACE | \
2033 SORT_STRINGSORT | \
2034 NORM_IGNOREWIDTH)
2036 if (mapflags & ~LCMAPSTRINGA_SUPPORTED_FLAGS)
2038 FIXME(string,"(0x%04lx,0x%08lx,%p,%d,%p,%d): "
2039 "unimplemented flags: 0x%08lx\n",
2040 lcid,
2041 mapflags,
2042 srcstr,
2043 srclen,
2044 dststr,
2045 dstlen,
2046 mapflags & ~LCMAPSTRINGA_SUPPORTED_FLAGS
2050 if ( !(mapflags & LCMAP_SORTKEY) )
2052 int i,j;
2053 int (*f)(int) = identity;
2054 int flag_ignorenonspace = mapflags & NORM_IGNORENONSPACE;
2055 int flag_ignoresymbols = mapflags & NORM_IGNORESYMBOLS;
2057 if (flag_ignorenonspace || flag_ignoresymbols)
2059 /* For some values of mapflags, the length of the resulting
2060 string is not known at this point. Windows does map the string
2061 and does not SetLastError ERROR_INSUFFICIENT_BUFFER in
2062 these cases. */
2063 if (dstlen==0)
2065 /* Compute required length */
2066 for (i=j=0; i < srclen; i++)
2068 if ( !(flag_ignorenonspace && OLE2NLS_isNonSpacing(srcstr[i]))
2069 && !(flag_ignoresymbols && OLE2NLS_isSymbol(srcstr[i])) )
2070 j++;
2072 return j;
2075 else
2077 if (dstlen==0)
2078 return srclen;
2079 if (dstlen<srclen)
2081 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2082 return 0;
2085 if (mapflags & LCMAP_UPPERCASE)
2086 f = toupper;
2087 else if (mapflags & LCMAP_LOWERCASE)
2088 f = tolower;
2089 /* FIXME: NORM_IGNORENONSPACE requires another conversion */
2090 for (i=j=0; (i<srclen) && (j<dstlen) ; i++)
2092 if ( !(flag_ignorenonspace && OLE2NLS_isNonSpacing(srcstr[i]))
2093 && !(flag_ignoresymbols && OLE2NLS_isSymbol(srcstr[i])) )
2095 dststr[j] = (CHAR) f(srcstr[i]);
2096 j++;
2099 return j;
2102 /* else ... (mapflags & LCMAP_SORTKEY) */
2104 int unicode_len=0;
2105 int case_len=0;
2106 int diacritic_len=0;
2107 int delayed_punctuation_len=0;
2108 char *case_component;
2109 char *diacritic_component;
2110 char *delayed_punctuation_component;
2111 int room,count;
2112 int flag_stringsort = mapflags & SORT_STRINGSORT;
2114 /* compute how much room we will need */
2115 for (i=0;i<srclen;i++)
2117 int ofs;
2118 unsigned char source_char = srcstr[i];
2119 if (source_char!='\0')
2121 if (flag_stringsort || !OLE2NLS_isPunctuation(source_char))
2123 unicode_len++;
2124 if ( LCM_Unicode_LUT[-2+2*source_char] & ~15 )
2125 unicode_len++; /* double letter */
2127 else
2129 delayed_punctuation_len++;
2133 if (isupper(source_char))
2134 case_len=unicode_len;
2136 ofs = source_char - LCM_Diacritic_Start;
2137 if ((ofs>=0) && (LCM_Diacritic_LUT[ofs]!=2))
2138 diacritic_len=unicode_len;
2141 if (mapflags & NORM_IGNORECASE)
2142 case_len=0;
2143 if (mapflags & NORM_IGNORENONSPACE)
2144 diacritic_len=0;
2146 room = 2 * unicode_len /* "unicode" component */
2147 + diacritic_len /* "diacritic" component */
2148 + case_len /* "case" component */
2149 + 4 * delayed_punctuation_len /* punctuation in word sort mode */
2150 + 4 /* four '\1' separators */
2151 + 1 ; /* terminal '\0' */
2152 if (dstlen==0)
2153 return room;
2154 else if (dstlen<room)
2156 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2157 return 0;
2160 /*FIXME the Pointercheck should not be nessesary */
2161 if (IsBadWritePtr (dststr,room))
2162 { ERR (string,"bad destination buffer (dststr) : %p,%d\n",dststr,dstlen);
2163 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2164 return 0;
2167 /* locate each component, write separators */
2168 diacritic_component = dststr + 2*unicode_len ;
2169 *diacritic_component++ = '\1';
2170 case_component = diacritic_component + diacritic_len ;
2171 *case_component++ = '\1';
2172 delayed_punctuation_component = case_component + case_len ;
2173 *delayed_punctuation_component++ = '\1';
2174 *delayed_punctuation_component++ = '\1';
2176 /* read source string char by char, write
2177 corresponding weight in each component. */
2178 for (i=0,count=0;i<srclen;i++)
2180 unsigned char source_char=srcstr[i];
2181 if (source_char!='\0')
2183 int type,longcode;
2184 type = LCM_Unicode_LUT[-2+2*source_char];
2185 longcode = type >> 4;
2186 type &= 15;
2187 if (!flag_stringsort && OLE2NLS_isPunctuation(source_char))
2189 UINT16 encrypted_location = (1<<15) + 7 + 4*count;
2190 *delayed_punctuation_component++ = (unsigned char) (encrypted_location>>8);
2191 *delayed_punctuation_component++ = (unsigned char) (encrypted_location&255);
2192 /* big-endian is used here because it lets string comparison be
2193 compatible with numerical comparison */
2195 *delayed_punctuation_component++ = type;
2196 *delayed_punctuation_component++ = LCM_Unicode_LUT[-1+2*source_char];
2197 /* assumption : a punctuation character is never a
2198 double or accented letter */
2200 else
2202 dststr[2*count] = type;
2203 dststr[2*count+1] = LCM_Unicode_LUT[-1+2*source_char];
2204 if (longcode)
2206 if (count<case_len)
2207 case_component[count] = ( isupper(source_char) ? 18 : 2 ) ;
2208 if (count<diacritic_len)
2209 diacritic_component[count] = 2; /* assumption: a double letter
2210 is never accented */
2211 count++;
2213 dststr[2*count] = type;
2214 dststr[2*count+1] = *(LCM_Unicode_LUT_2 - 1 + longcode);
2215 /* 16 in the first column of LCM_Unicode_LUT --> longcode = 1
2216 32 in the first column of LCM_Unicode_LUT --> longcode = 2
2217 48 in the first column of LCM_Unicode_LUT --> longcode = 3 */
2220 if (count<case_len)
2221 case_component[count] = ( isupper(source_char) ? 18 : 2 ) ;
2222 if (count<diacritic_len)
2224 int ofs = source_char - LCM_Diacritic_Start;
2225 diacritic_component[count] = (ofs>=0 ? LCM_Diacritic_LUT[ofs] : 2);
2227 count++;
2231 dststr[room-1] = '\0';
2232 return room;
2236 /*************************************************************************
2237 * LCMapString32W [KERNEL32.493]
2239 * Convert a string, or generate a sort key from it.
2241 * NOTE
2243 * See LCMapString32A for documentation
2245 INT WINAPI LCMapStringW(
2246 LCID lcid,DWORD mapflags,LPCWSTR srcstr,INT srclen,LPWSTR dststr,
2247 INT dstlen)
2249 int i;
2251 TRACE(string,"(0x%04lx,0x%08lx,%p,%d,%p,%d)\n",
2252 lcid,mapflags,srcstr,srclen,dststr,dstlen);
2254 if ( ((dstlen!=0) && (dststr==NULL)) || (srcstr==NULL) )
2256 ERR(ole, "(src=%p,dst=%p): Invalid NULL string\n", srcstr, dststr);
2257 SetLastError(ERROR_INVALID_PARAMETER);
2258 return 0;
2260 if (srclen==-1)
2261 srclen = lstrlenW(srcstr)+1;
2262 if (mapflags & LCMAP_SORTKEY)
2264 FIXME(string,"(0x%04lx,0x%08lx,%p,%d,%p,%d): "
2265 "unimplemented flags: 0x%08lx\n",
2266 lcid,mapflags,srcstr,srclen,dststr,dstlen,mapflags);
2267 return 0;
2269 else
2271 int (*f)(int)=identity;
2273 if (dstlen==0)
2274 return srclen;
2275 if (dstlen<srclen) {
2276 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2277 return 0;
2279 if (mapflags & LCMAP_UPPERCASE)
2280 f = toupper;
2281 else if (mapflags & LCMAP_LOWERCASE)
2282 f = tolower;
2283 for (i=0; i < srclen; i++)
2284 dststr[i] = (WCHAR) f(srcstr[i]);
2285 return srclen;
2289 /***********************************************************************
2290 * CompareString16 (OLE2NLS.8)
2292 UINT16 WINAPI CompareString16(DWORD lcid,DWORD fdwStyle,
2293 LPCSTR s1,DWORD l1,LPCSTR s2,DWORD l2)
2295 return (UINT16)CompareStringA(lcid,fdwStyle,s1,l1,s2,l2);
2298 /******************************************************************************
2299 * CompareString32A [KERNEL32.143]
2300 * Compares two strings using locale
2302 * RETURNS
2304 * success: CSTR_LESS_THAN, CSTR_EQUAL, CSTR_GREATER_THAN
2305 * failure: 0
2307 * NOTES
2309 * Defaults to a word sort, but uses a string sort if
2310 * SORT_STRINGSORT is set.
2311 * Calls SetLastError for ERROR_INVALID_FLAGS, ERROR_INVALID_PARAMETER.
2313 * BUGS
2315 * This implementation ignores the locale
2317 * FIXME
2319 * Quite inefficient.
2321 UINT WINAPI CompareStringA(
2322 DWORD lcid, /* locale ID */
2323 DWORD fdwStyle, /* comparison-style options */
2324 LPCSTR s1, /* first string */
2325 DWORD l1, /* length of first string */
2326 LPCSTR s2, /* second string */
2327 DWORD l2) /* length of second string */
2329 int mapstring_flags;
2330 int len1,len2;
2331 int result;
2332 LPSTR sk1,sk2;
2333 TRACE(ole,"%s and %s\n",
2334 debugstr_a (s1), debugstr_a (s2));
2336 if ( (s1==NULL) || (s2==NULL) )
2338 ERR(ole, "(s1=%s,s2=%s): Invalid NULL string\n", s1, s2);
2339 SetLastError(ERROR_INVALID_PARAMETER);
2340 return 0;
2343 if(fdwStyle & NORM_IGNORESYMBOLS)
2344 FIXME(ole, "IGNORESYMBOLS not supported\n");
2346 mapstring_flags = LCMAP_SORTKEY | fdwStyle ;
2347 len1 = LCMapStringA(lcid,mapstring_flags,s1,l1,NULL,0);
2348 len2 = LCMapStringA(lcid,mapstring_flags,s2,l2,NULL,0);
2350 if ((len1==0)||(len2==0))
2351 return 0; /* something wrong happened */
2353 sk1 = (LPSTR)HeapAlloc(GetProcessHeap(),0,len1);
2354 sk2 = (LPSTR)HeapAlloc(GetProcessHeap(),0,len2);
2355 if ( (!LCMapStringA(lcid,mapstring_flags,s1,l1,sk1,len1))
2356 || (!LCMapStringA(lcid,mapstring_flags,s2,l2,sk2,len2)) )
2358 ERR(ole,"Bug in LCmapString32A.\n");
2359 result = 0;
2361 else
2363 /* strcmp doesn't necessarily return -1, 0, or 1 */
2364 result = strcmp(sk1,sk2);
2366 HeapFree(GetProcessHeap(),0,sk1);
2367 HeapFree(GetProcessHeap(),0,sk2);
2369 if (result < 0)
2370 return 1;
2371 if (result == 0)
2372 return 2;
2374 /* must be greater, if we reach this point */
2375 return 3;
2378 /******************************************************************************
2379 * CompareString32W [KERNEL32.144]
2380 * This implementation ignores the locale
2381 * FIXME : Does only string sort. Should
2382 * be reimplemented the same way as CompareString32A.
2384 UINT WINAPI CompareStringW(DWORD lcid, DWORD fdwStyle,
2385 LPCWSTR s1, DWORD l1, LPCWSTR s2,DWORD l2)
2387 int len,ret;
2388 if(fdwStyle & NORM_IGNORENONSPACE)
2389 FIXME(ole,"IGNORENONSPACE not supprted\n");
2390 if(fdwStyle & NORM_IGNORESYMBOLS)
2391 FIXME(ole,"IGNORESYMBOLS not supported\n");
2393 /* Is strcmp defaulting to string sort or to word sort?? */
2394 /* FIXME: Handle NORM_STRINGSORT */
2395 l1 = (l1==-1)?lstrlenW(s1):l1;
2396 l2 = (l2==-1)?lstrlenW(s2):l2;
2397 len = l1<l2 ? l1:l2;
2398 ret = (fdwStyle & NORM_IGNORECASE) ?
2399 lstrncmpiW(s1,s2,len) : lstrncmpW(s1,s2,len);
2400 /* not equal, return 1 or 3 */
2401 if(ret!=0) return ret+2;
2402 /* same len, return 2 */
2403 if(l1==l2) return 2;
2404 /* the longer one is lexically greater */
2405 return (l1<l2)? 1 : 3;
2408 /******************************************************************************
2409 * OLE_GetFormatA [Internal]
2411 * FIXME
2412 * If datelen == 0, it should return the reguired string length.
2414 This function implements stuff for GetDateFormat() and
2415 GetTimeFormat().
2417 d single-digit (no leading zero) day (of month)
2418 dd two-digit day (of month)
2419 ddd short day-of-week name
2420 dddd long day-of-week name
2421 M single-digit month
2422 MM two-digit month
2423 MMM short month name
2424 MMMM full month name
2425 y two-digit year, no leading 0
2426 yy two-digit year
2427 yyyy four-digit year
2428 gg era string
2429 h hours with no leading zero (12-hour)
2430 hh hours with full two digits
2431 H hours with no leading zero (24-hour)
2432 HH hours with full two digits
2433 m minutes with no leading zero
2434 mm minutes with full two digits
2435 s seconds with no leading zero
2436 ss seconds with full two digits
2437 t time marker (A or P)
2438 tt time marker (AM, PM)
2439 '' used to quote literal characters
2440 '' (within a quoted string) indicates a literal '
2442 These functions REQUIRE valid locale, date, and format.
2444 static INT OLE_GetFormatA(LCID locale,
2445 DWORD flags,
2446 DWORD tflags,
2447 LPSYSTEMTIME xtime,
2448 LPCSTR _format, /*in*/
2449 LPSTR date, /*out*/
2450 INT datelen)
2452 INT inpos, outpos;
2453 int count, type, inquote, Overflow;
2454 char buf[40];
2455 char format[40];
2456 char * pos;
2457 int buflen;
2459 const char * _dgfmt[] = { "%d", "%02d" };
2460 const char ** dgfmt = _dgfmt - 1;
2462 /* report, for debugging */
2463 TRACE(ole, "(0x%lx,0x%lx, 0x%lx, time(d=%d,h=%d,m=%d,s=%d), fmt=%p \'%s\' , %p, len=%d)\n",
2464 locale, flags, tflags,
2465 xtime->wDay, xtime->wHour, xtime->wMinute, xtime->wSecond,
2466 _format, _format, date, datelen);
2468 if(datelen == 0) {
2469 FIXME(ole, "datelen = 0, returning 255\n");
2470 return 255;
2473 /* initalize state variables and output buffer */
2474 inpos = outpos = 0;
2475 count = 0; inquote = 0; Overflow = 0;
2476 type = '\0';
2477 date[0] = buf[0] = '\0';
2479 strcpy(format,_format);
2481 /* alter the formatstring, while it works for all languages now in wine
2482 its possible that it fails when the time looks like ss:mm:hh as example*/
2483 if (tflags & (TIME_NOMINUTESORSECONDS))
2484 { if ((pos = strstr ( format, ":mm")))
2485 { memcpy ( pos, pos+3, strlen(format)-(pos-format)-2 );
2488 if (tflags & (TIME_NOSECONDS))
2489 { if ((pos = strstr ( format, ":ss")))
2490 { memcpy ( pos, pos+3, strlen(format)-(pos-format)-2 );
2494 for (inpos = 0;; inpos++) {
2495 /* TRACE(ole, "STATE inpos=%2d outpos=%2d count=%d inquote=%d type=%c buf,date = %c,%c\n", inpos, outpos, count, inquote, type, buf[inpos], date[outpos]); */
2496 if (inquote) {
2497 if (format[inpos] == '\'') {
2498 if (format[inpos+1] == '\'') {
2499 inpos += 1;
2500 date[outpos++] = '\'';
2501 } else {
2502 inquote = 0;
2503 continue; /* we did nothing to the output */
2505 } else if (format[inpos] == '\0') {
2506 date[outpos++] = '\0';
2507 if (outpos > datelen) Overflow = 1;
2508 break;
2509 } else {
2510 date[outpos++] = format[inpos];
2511 if (outpos > datelen) {
2512 Overflow = 1;
2513 date[outpos-1] = '\0'; /* this is the last place where
2514 it's safe to write */
2515 break;
2518 } else if ( (count && (format[inpos] != type))
2519 || count == 4
2520 || (count == 2 && strchr("ghHmst", type)) )
2522 if (type == 'd') {
2523 if (count == 4) {
2524 GetLocaleInfoA(locale,
2525 LOCALE_SDAYNAME1
2526 + xtime->wDayOfWeek - 1,
2527 buf, sizeof(buf));
2528 } else if (count == 3) {
2529 GetLocaleInfoA(locale,
2530 LOCALE_SABBREVDAYNAME1
2531 + xtime->wDayOfWeek - 1,
2532 buf, sizeof(buf));
2533 } else {
2534 sprintf(buf, dgfmt[count], xtime->wDay);
2536 } else if (type == 'M') {
2537 if (count == 3) {
2538 GetLocaleInfoA(locale,
2539 LOCALE_SABBREVMONTHNAME1
2540 + xtime->wMonth - 1,
2541 buf, sizeof(buf));
2542 } else if (count == 4) {
2543 GetLocaleInfoA(locale,
2544 LOCALE_SMONTHNAME1
2545 + xtime->wMonth - 1,
2546 buf, sizeof(buf));
2547 } else {
2548 sprintf(buf, dgfmt[count], xtime->wMonth);
2550 } else if (type == 'y') {
2551 if (count == 4) {
2552 sprintf(buf, "%d", xtime->wYear);
2553 } else if (count == 3) {
2554 strcpy(buf, "yyy");
2555 WARN(ole, "unknown format, c=%c, n=%d\n", type, count);
2556 } else {
2557 sprintf(buf, dgfmt[count], xtime->wYear % 100);
2559 } else if (type == 'g') {
2560 if (count == 2) {
2561 FIXME(ole, "LOCALE_ICALENDARTYPE unimp.\n");
2562 strcpy(buf, "AD");
2563 } else {
2564 strcpy(buf, "g");
2565 WARN(ole, "unknown format, c=%c, n=%d\n", type, count);
2567 } else if (type == 'h') {
2568 /* gives us hours 1:00 -- 12:00 */
2569 sprintf(buf, dgfmt[count], (xtime->wHour-1)%12 +1);
2570 } else if (type == 'H') {
2571 /* 24-hour time */
2572 sprintf(buf, dgfmt[count], xtime->wHour);
2573 } else if ( type == 'm') {
2574 sprintf(buf, dgfmt[count], xtime->wMinute);
2575 } else if ( type == 's') {
2576 sprintf(buf, dgfmt[count], xtime->wSecond);
2577 } else if (type == 't') {
2578 if (count == 1) {
2579 sprintf(buf, "%c", (xtime->wHour < 12) ? 'A' : 'P');
2580 } else if (count == 2) {
2581 /* sprintf(buf, "%s", (xtime->wHour < 12) ? "AM" : "PM"); */
2582 GetLocaleInfoA(locale,
2583 (xtime->wHour<12)
2584 ? LOCALE_S1159 : LOCALE_S2359,
2585 buf, sizeof(buf));
2589 /* we need to check the next char in the format string
2590 again, no matter what happened */
2591 inpos--;
2593 /* add the contents of buf to the output */
2594 buflen = strlen(buf);
2595 if (outpos + buflen < datelen) {
2596 date[outpos] = '\0'; /* for strcat to hook onto */
2597 strcat(date, buf);
2598 outpos += buflen;
2599 } else {
2600 date[outpos] = '\0';
2601 strncat(date, buf, datelen - outpos);
2602 date[datelen - 1] = '\0';
2603 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2604 WARN(ole, "insufficient buffer\n");
2605 return 0;
2608 /* reset the variables we used to keep track of this item */
2609 count = 0;
2610 type = '\0';
2611 } else if (format[inpos] == '\0') {
2612 /* we can't check for this at the loop-head, because
2613 that breaks the printing of the last format-item */
2614 date[outpos] = '\0';
2615 break;
2616 } else if (count) {
2617 /* continuing a code for an item */
2618 count +=1;
2619 continue;
2620 } else if (strchr("hHmstyMdg", format[inpos])) {
2621 type = format[inpos];
2622 count = 1;
2623 continue;
2624 } else if (format[inpos] == '\'') {
2625 inquote = 1;
2626 continue;
2627 } else {
2628 date[outpos++] = format[inpos];
2630 /* now deal with a possible buffer overflow */
2631 if (outpos >= datelen) {
2632 date[datelen - 1] = '\0';
2633 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2634 return 0;
2638 if (Overflow) {
2639 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2642 /* finish it off with a string terminator */
2643 outpos++;
2644 /* sanity check */
2645 if (outpos > datelen-1) outpos = datelen-1;
2646 date[outpos] = '\0';
2648 TRACE(ole, "OLE_GetFormatA returns string '%s', len %d\n",
2649 date, outpos);
2650 return outpos;
2653 /******************************************************************************
2654 * OLE_GetFormatW [INTERNAL]
2656 static INT OLE_GetFormatW(LCID locale, DWORD flags, DWORD tflags,
2657 LPSYSTEMTIME xtime,
2658 LPCWSTR format,
2659 LPWSTR output, INT outlen)
2661 INT inpos, outpos;
2662 int count, type=0, inquote;
2663 int Overflow; /* loop check */
2664 WCHAR buf[40];
2665 int buflen=0;
2666 WCHAR arg0[] = {0}, arg1[] = {'%','d',0};
2667 WCHAR arg2[] = {'%','0','2','d',0};
2668 WCHAR *argarr[] = {arg0, arg1, arg2};
2669 int datevars=0, timevars=0;
2671 /* make a debug report */
2672 TRACE(ole, "args: 0x%lx, 0x%lx, 0x%lx, time(d=%d,h=%d,m=%d,s=%d), fmt:%s (at %p),
2673 %p with max len %d\n",
2674 locale, flags, tflags,
2675 xtime->wDay, xtime->wHour, xtime->wMinute, xtime->wSecond,
2676 debugstr_w(format), format, output, outlen);
2678 if(outlen == 0) {
2679 FIXME(ole, "outlen = 0, returning 255\n");
2680 return 255;
2683 /* initialize state variables */
2684 inpos = outpos = 0;
2685 count = 0;
2686 inquote = Overflow = 0;
2687 /* this is really just a sanity check */
2688 output[0] = buf[0] = 0;
2690 /* this loop is the core of the function */
2691 for (inpos = 0; /* we have several break points */ ; inpos++) {
2692 if (inquote) {
2693 if (format[inpos] == (WCHAR) '\'') {
2694 if (format[inpos+1] == '\'') {
2695 inpos++;
2696 output[outpos++] = '\'';
2697 } else {
2698 inquote = 0;
2699 continue;
2701 } else if (format[inpos] == 0) {
2702 output[outpos++] = 0;
2703 if (outpos > outlen) Overflow = 1;
2704 break; /* normal exit (within a quote) */
2705 } else {
2706 output[outpos++] = format[inpos]; /* copy input */
2707 if (outpos > outlen) {
2708 Overflow = 1;
2709 output[outpos-1] = 0;
2710 break;
2713 } else if ( (count && (format[inpos] != type))
2714 || ( (count==4 && type =='y') ||
2715 (count==4 && type =='M') ||
2716 (count==4 && type =='d') ||
2717 (count==2 && type =='g') ||
2718 (count==2 && type =='h') ||
2719 (count==2 && type =='H') ||
2720 (count==2 && type =='m') ||
2721 (count==2 && type =='s') ||
2722 (count==2 && type =='t') ) ) {
2723 if (type == 'd') {
2724 if (count == 3) {
2725 GetLocaleInfoW(locale,
2726 LOCALE_SDAYNAME1 + xtime->wDayOfWeek -1,
2727 buf, sizeof(buf)/sizeof(WCHAR) );
2728 } else if (count == 3) {
2729 GetLocaleInfoW(locale,
2730 LOCALE_SABBREVDAYNAME1 +
2731 xtime->wDayOfWeek -1,
2732 buf, sizeof(buf)/sizeof(WCHAR) );
2733 } else {
2734 wsnprintfW(buf, 5, argarr[count], xtime->wDay );
2736 } else if (type == 'M') {
2737 if (count == 4) {
2738 GetLocaleInfoW(locale, LOCALE_SMONTHNAME1 +
2739 xtime->wMonth -1, buf,
2740 sizeof(buf)/sizeof(WCHAR) );
2741 } else if (count == 3) {
2742 GetLocaleInfoW(locale, LOCALE_SABBREVMONTHNAME1 +
2743 xtime->wMonth -1, buf,
2744 sizeof(buf)/sizeof(WCHAR) );
2745 } else {
2746 wsnprintfW(buf, 5, argarr[count], xtime->wMonth);
2748 } else if (type == 'y') {
2749 if (count == 4) {
2750 wsnprintfW(buf, 6, argarr[1] /* "%d" */,
2751 xtime->wYear);
2752 } else if (count == 3) {
2753 lstrcpynAtoW(buf, "yyy", 5);
2754 } else {
2755 wsnprintfW(buf, 6, argarr[count],
2756 xtime->wYear % 100);
2758 } else if (type == 'g') {
2759 if (count == 2) {
2760 FIXME(ole, "LOCALE_ICALENDARTYPE unimplemented\n");
2761 lstrcpynAtoW(buf, "AD", 5);
2762 } else {
2763 /* Win API sez we copy it verbatim */
2764 lstrcpynAtoW(buf, "g", 5);
2766 } else if (type == 'h') {
2767 /* hours 1:00-12:00 --- is this right? */
2768 wsnprintfW(buf, 5, argarr[count],
2769 (xtime->wHour-1)%12 +1);
2770 } else if (type == 'H') {
2771 wsnprintfW(buf, 5, argarr[count],
2772 xtime->wHour);
2773 } else if (type == 'm' ) {
2774 wsnprintfW(buf, 5, argarr[count],
2775 xtime->wMinute);
2776 } else if (type == 's' ) {
2777 wsnprintfW(buf, 5, argarr[count],
2778 xtime->wSecond);
2779 } else if (type == 't') {
2780 GetLocaleInfoW(locale, (xtime->wHour < 12) ?
2781 LOCALE_S1159 : LOCALE_S2359,
2782 buf, sizeof(buf) );
2783 if (count == 1) {
2784 buf[1] = 0;
2788 /* no matter what happened, we need to check this next
2789 character the next time we loop through */
2790 inpos--;
2792 /* cat buf onto the output */
2793 outlen = lstrlenW(buf);
2794 if (outpos + buflen < outlen) {
2795 output[outpos] = 0; /* a "hook" for strcat */
2796 lstrcatW(output, buf);
2797 outpos += buflen;
2798 } else {
2799 output[outpos] = 0;
2800 lstrcatnW(output, buf, outlen - outpos);
2801 output[outlen - 1] = 0;
2802 Overflow = 1;
2803 break; /* Abnormal exit */
2806 /* reset the variables we used this time */
2807 count = 0;
2808 type = '\0';
2809 } else if (format[inpos] == 0) {
2810 /* we can't check for this at the beginning, because that
2811 would keep us from printing a format spec that ended the
2812 string */
2813 output[outpos] = 0;
2814 break; /* NORMAL EXIT */
2815 } else if (count) {
2816 /* how we keep track of the middle of a format spec */
2817 count++;
2818 continue;
2819 } else if ( (datevars && (format[inpos]=='d' ||
2820 format[inpos]=='M' ||
2821 format[inpos]=='y' ||
2822 format[inpos]=='g') ) ||
2823 (timevars && (format[inpos]=='H' ||
2824 format[inpos]=='h' ||
2825 format[inpos]=='m' ||
2826 format[inpos]=='s' ||
2827 format[inpos]=='t') ) ) {
2828 type = format[inpos];
2829 count = 1;
2830 continue;
2831 } else if (format[inpos] == '\'') {
2832 inquote = 1;
2833 continue;
2834 } else {
2835 /* unquoted literals */
2836 output[outpos++] = format[inpos];
2840 if (Overflow) {
2841 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2842 WARN(ole, " buffer overflow\n");
2845 /* final string terminator and sanity check */
2846 outpos++;
2847 if (outpos > outlen-1) outpos = outlen-1;
2848 output[outpos] = '0';
2850 TRACE(ole, " returning %s\n", debugstr_w(output));
2852 return (!Overflow) ? outlen : 0;
2857 /******************************************************************************
2858 * GetDateFormat32A [KERNEL32.310]
2859 * Makes an ASCII string of the date
2861 * This function uses format to format the date, or, if format
2862 * is NULL, uses the default for the locale. format is a string
2863 * of literal fields and characters as follows:
2865 * - d single-digit (no leading zero) day (of month)
2866 * - dd two-digit day (of month)
2867 * - ddd short day-of-week name
2868 * - dddd long day-of-week name
2869 * - M single-digit month
2870 * - MM two-digit month
2871 * - MMM short month name
2872 * - MMMM full month name
2873 * - y two-digit year, no leading 0
2874 * - yy two-digit year
2875 * - yyyy four-digit year
2876 * - gg era string
2879 INT WINAPI GetDateFormatA(LCID locale,DWORD flags,
2880 LPSYSTEMTIME xtime,
2881 LPCSTR format, LPSTR date,INT datelen)
2884 char format_buf[40];
2885 LPCSTR thisformat;
2886 SYSTEMTIME t;
2887 LPSYSTEMTIME thistime;
2888 LCID thislocale;
2889 INT ret;
2891 TRACE(ole,"(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",
2892 locale,flags,xtime,format,date,datelen);
2894 if (!locale) {
2895 locale = LOCALE_SYSTEM_DEFAULT;
2898 if (locale == LOCALE_SYSTEM_DEFAULT) {
2899 thislocale = GetSystemDefaultLCID();
2900 } else if (locale == LOCALE_USER_DEFAULT) {
2901 thislocale = GetUserDefaultLCID();
2902 } else {
2903 thislocale = locale;
2906 if (xtime == NULL) {
2907 GetSystemTime(&t);
2908 thistime = &t;
2909 } else {
2910 thistime = xtime;
2913 if (format == NULL) {
2914 GetLocaleInfoA(thislocale, ((flags&DATE_LONGDATE)
2915 ? LOCALE_SLONGDATE
2916 : LOCALE_SSHORTDATE),
2917 format_buf, sizeof(format_buf));
2918 thisformat = format_buf;
2919 } else {
2920 thisformat = format;
2924 ret = OLE_GetFormatA(thislocale, flags, 0, thistime, thisformat,
2925 date, datelen);
2928 TRACE(ole,
2929 "GetDateFormat32A() returning %d, with data=%s\n",
2930 ret, date);
2931 return ret;
2934 /******************************************************************************
2935 * GetDateFormat32W [KERNEL32.311]
2936 * Makes a Unicode string of the date
2938 * Acts the same as GetDateFormat32A(), except that it's Unicode.
2939 * Accepts & returns sizes as counts of Unicode characters.
2942 INT WINAPI GetDateFormatW(LCID locale,DWORD flags,
2943 LPSYSTEMTIME xtime,
2944 LPCWSTR format,
2945 LPWSTR date, INT datelen)
2947 unsigned short datearr[] = {'1','9','9','4','-','1','-','1',0};
2949 FIXME(ole, "STUB (should call OLE_GetFormatW)\n");
2950 lstrcpynW(date, datearr, datelen);
2951 return ( datelen < 9) ? datelen : 9;
2956 /**************************************************************************
2957 * EnumDateFormats32A (KERNEL32.198)
2959 BOOL WINAPI EnumDateFormatsA(
2960 DATEFMT_ENUMPROCA lpDateFmtEnumProc, LCID Locale, DWORD dwFlags)
2962 FIXME(ole, "Only US English supported\n");
2964 if(!lpDateFmtEnumProc)
2966 SetLastError(ERROR_INVALID_PARAMETER);
2967 return FALSE;
2970 switch(dwFlags)
2972 case DATE_SHORTDATE:
2973 if(!(*lpDateFmtEnumProc)("M/d/yy")) return TRUE;
2974 if(!(*lpDateFmtEnumProc)("M/d/yyyy")) return TRUE;
2975 if(!(*lpDateFmtEnumProc)("MM/dd/yy")) return TRUE;
2976 if(!(*lpDateFmtEnumProc)("MM/dd/yyyy")) return TRUE;
2977 if(!(*lpDateFmtEnumProc)("yy/MM/dd")) return TRUE;
2978 if(!(*lpDateFmtEnumProc)("dd-MMM-yy")) return TRUE;
2979 return TRUE;
2980 case DATE_LONGDATE:
2981 if(!(*lpDateFmtEnumProc)("dddd, MMMM dd, yyyy")) return TRUE;
2982 if(!(*lpDateFmtEnumProc)("MMMM dd, yyyy")) return TRUE;
2983 if(!(*lpDateFmtEnumProc)("dddd, dd MMMM, yyyy")) return TRUE;
2984 if(!(*lpDateFmtEnumProc)("dd MMMM, yyyy")) return TRUE;
2985 return TRUE;
2986 default:
2987 FIXME(ole, "Unknown date format (%ld)\n", dwFlags);
2988 SetLastError(ERROR_INVALID_PARAMETER);
2989 return FALSE;
2993 /**************************************************************************
2994 * EnumDateFormats32W (KERNEL32.199)
2996 BOOL WINAPI EnumDateFormatsW(
2997 DATEFMT_ENUMPROCW lpDateFmtEnumProc, LCID Locale, DWORD dwFlags)
2999 FIXME(ole, "(%p, %ld, %ld): stub\n", lpDateFmtEnumProc, Locale, dwFlags);
3000 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
3001 return FALSE;
3004 /**************************************************************************
3005 * EnumTimeFormats32A (KERNEL32.210)
3007 BOOL WINAPI EnumTimeFormatsA(
3008 TIMEFMT_ENUMPROCA lpTimeFmtEnumProc, LCID Locale, DWORD dwFlags)
3010 FIXME(ole, "Only US English supported\n");
3012 if(!lpTimeFmtEnumProc)
3014 SetLastError(ERROR_INVALID_PARAMETER);
3015 return FALSE;
3018 if(dwFlags)
3020 FIXME(ole, "Unknown time format (%ld)\n", dwFlags);
3023 if(!(*lpTimeFmtEnumProc)("h:mm:ss tt")) return TRUE;
3024 if(!(*lpTimeFmtEnumProc)("hh:mm:ss tt")) return TRUE;
3025 if(!(*lpTimeFmtEnumProc)("H:mm:ss")) return TRUE;
3026 if(!(*lpTimeFmtEnumProc)("HH:mm:ss")) return TRUE;
3028 return TRUE;
3031 /**************************************************************************
3032 * EnumTimeFormats32W (KERNEL32.211)
3034 BOOL WINAPI EnumTimeFormatsW(
3035 TIMEFMT_ENUMPROCW lpTimeFmtEnumProc, LCID Locale, DWORD dwFlags)
3037 FIXME(ole, "(%p,%ld,%ld): stub\n", lpTimeFmtEnumProc, Locale, dwFlags);
3038 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
3039 return FALSE;
3042 /**************************************************************************
3043 * GetNumberFormat32A (KERNEL32.355)
3045 INT WINAPI GetNumberFormatA(LCID locale, DWORD dwflags,
3046 LPCSTR lpvalue, const NUMBERFMTA * lpFormat,
3047 LPSTR lpNumberStr, int cchNumber)
3049 FIXME(file,"%s: stub, no reformating done\n",lpvalue);
3051 lstrcpynA( lpNumberStr, lpvalue, cchNumber );
3052 return cchNumber? lstrlenA( lpNumberStr ) : 0;
3054 /**************************************************************************
3055 * GetNumberFormat32W (KERNEL32.xxx)
3057 INT WINAPI GetNumberFormatW(LCID locale, DWORD dwflags,
3058 LPCWSTR lpvalue, const NUMBERFMTW * lpFormat,
3059 LPWSTR lpNumberStr, int cchNumber)
3061 FIXME(file,"%s: stub, no reformating done\n",debugstr_w(lpvalue));
3063 lstrcpynW( lpNumberStr, lpvalue, cchNumber );
3064 return cchNumber? lstrlenW( lpNumberStr ) : 0;
3066 /******************************************************************************
3067 * OLE2NLS_CheckLocale [intern]
3069 static LCID OLE2NLS_CheckLocale (LCID locale)
3071 if (!locale)
3072 { locale = LOCALE_SYSTEM_DEFAULT;
3075 if (locale == LOCALE_SYSTEM_DEFAULT)
3076 { return GetSystemDefaultLCID();
3078 else if (locale == LOCALE_USER_DEFAULT)
3079 { return GetUserDefaultLCID();
3081 else
3082 { return locale;
3085 /******************************************************************************
3086 * GetTimeFormat32A [KERNEL32.422]
3087 * Makes an ASCII string of the time
3089 * Formats date according to format, or locale default if format is
3090 * NULL. The format consists of literal characters and fields as follows:
3092 * h hours with no leading zero (12-hour)
3093 * hh hours with full two digits
3094 * H hours with no leading zero (24-hour)
3095 * HH hours with full two digits
3096 * m minutes with no leading zero
3097 * mm minutes with full two digits
3098 * s seconds with no leading zero
3099 * ss seconds with full two digits
3100 * t time marker (A or P)
3101 * tt time marker (AM, PM)
3104 INT WINAPI
3105 GetTimeFormatA(LCID locale, /* in */
3106 DWORD flags, /* in */
3107 LPSYSTEMTIME xtime, /* in */
3108 LPCSTR format, /* in */
3109 LPSTR timestr, /* out */
3110 INT timelen /* in */)
3111 { char format_buf[40];
3112 LPCSTR thisformat;
3113 SYSTEMTIME t;
3114 LPSYSTEMTIME thistime;
3115 LCID thislocale=0;
3116 DWORD thisflags=LOCALE_STIMEFORMAT; /* standart timeformat */
3117 INT ret;
3119 TRACE(ole,"GetTimeFormat(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",locale,flags,xtime,format,timestr,timelen);
3121 thislocale = OLE2NLS_CheckLocale ( locale );
3123 if ( flags & (TIME_NOTIMEMARKER | TIME_FORCE24HOURFORMAT ))
3124 { FIXME(ole,"TIME_NOTIMEMARKER or TIME_FORCE24HOURFORMAT not implemented\n");
3127 flags &= (TIME_NOSECONDS | TIME_NOMINUTESORSECONDS); /* mask for OLE_GetFormatA*/
3129 if (format == NULL)
3130 { if (flags & LOCALE_NOUSEROVERRIDE) /*use system default*/
3131 { thislocale = GetSystemDefaultLCID();
3133 GetLocaleInfoA(thislocale, thisflags, format_buf, sizeof(format_buf));
3134 thisformat = format_buf;
3136 else
3137 { thisformat = format;
3140 if (xtime == NULL) /* NULL means use the current local time*/
3141 { GetSystemTime(&t);
3142 thistime = &t;
3144 else
3145 { thistime = xtime;
3147 ret = OLE_GetFormatA(thislocale, thisflags, flags, thistime, thisformat,
3148 timestr, timelen);
3149 return ret;
3153 /******************************************************************************
3154 * GetTimeFormat32W [KERNEL32.423]
3155 * Makes a Unicode string of the time
3157 INT WINAPI
3158 GetTimeFormatW(LCID locale, /* in */
3159 DWORD flags, /* in */
3160 LPSYSTEMTIME xtime, /* in */
3161 LPCWSTR format, /* in */
3162 LPWSTR timestr, /* out */
3163 INT timelen /* in */)
3164 { WCHAR format_buf[40];
3165 LPCWSTR thisformat;
3166 SYSTEMTIME t;
3167 LPSYSTEMTIME thistime;
3168 LCID thislocale=0;
3169 DWORD thisflags=LOCALE_STIMEFORMAT; /* standart timeformat */
3170 INT ret;
3172 TRACE(ole,"GetTimeFormat(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",locale,flags,
3173 xtime,debugstr_w(format),timestr,timelen);
3175 thislocale = OLE2NLS_CheckLocale ( locale );
3177 if ( flags & (TIME_NOTIMEMARKER | TIME_FORCE24HOURFORMAT ))
3178 { FIXME(ole,"TIME_NOTIMEMARKER or TIME_FORCE24HOURFORMAT not implemented\n");
3181 flags &= (TIME_NOSECONDS | TIME_NOMINUTESORSECONDS); /* mask for OLE_GetFormatA*/
3183 if (format == NULL)
3184 { if (flags & LOCALE_NOUSEROVERRIDE) /*use system default*/
3185 { thislocale = GetSystemDefaultLCID();
3187 GetLocaleInfoW(thislocale, thisflags, format_buf, 40);
3188 thisformat = format_buf;
3190 else
3191 { thisformat = format;
3194 if (xtime == NULL) /* NULL means use the current local time*/
3195 { GetSystemTime(&t);
3196 thistime = &t;
3198 else
3199 { thistime = xtime;
3202 ret = OLE_GetFormatW(thislocale, thisflags, flags, thistime, thisformat,
3203 timestr, timelen);
3204 return ret;
3207 /******************************************************************************
3208 * EnumCalendarInfoA [KERNEL32.196]
3210 BOOL WINAPI EnumCalendarInfoA(
3211 CALINFO_ENUMPROCA calinfoproc,LCID locale,CALID calendar,CALTYPE caltype
3213 FIXME(ole,"(%p,0x%04lx,0x%08lx,0x%08lx),stub!\n",calinfoproc,locale,calendar,caltype);
3214 return FALSE;