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