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