Some programs (quake2 et al) do check for DSCAPS_EMULDRIVER and stop
[wine/wine64.git] / ole / ole2nls.c
blob8cb23b3891465d2dc17e234fa4ea1f8195751d08
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;
366 if (Options.language) {
367 return Languages[Options.language].langid;
370 if (userLCID == 0) {
371 char *buf=NULL;
372 char *lang,*country,*charset,*dialect,*next;
373 int ret=0;
375 buf=getenv("LANGUAGE");
376 if (!buf) buf=getenv("LANG");
377 if (!buf) buf=getenv("LC_ALL");
378 if (!buf) buf=getenv("LC_MESSAGES");
379 if (!buf) return userLCID = MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT );
381 if (!strcmp(buf,"POSIX") || !strcmp(buf,"C")) {
382 return MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT );
385 lang=buf;
387 do {
388 next=strchr(lang,':'); if (next) *next++='\0';
389 dialect=strchr(lang,'@'); if (dialect) *dialect++='\0';
390 charset=strchr(lang,'.'); if (charset) *charset++='\0';
391 country=strchr(lang,'_'); if (country) *country++='\0';
393 ret=MAIN_GetLanguageID(lang, country, charset, dialect);
395 lang=next;
397 } while (lang && !ret);
399 /* FIXME : are strings returned by getenv() to be free()'ed ? */
400 userLCID = (LANGID)ret;
402 return userLCID;
405 /***********************************************************************
406 * GetSystemDefaultLangID (OLE2NLS.4)
408 LANGID WINAPI GetSystemDefaultLangID()
410 return GetUserDefaultLangID();
413 /******************************************************************************
414 * GetLocaleInfo16 [OLE2NLS.5]
415 * Is the last parameter really WORD for Win16?
417 INT16 WINAPI GetLocaleInfo16(LCID lcid,LCTYPE LCType,LPSTR buf,INT16 len)
419 return GetLocaleInfo32A(lcid,LCType,buf,len);
422 /******************************************************************************
423 * GetLocaleInfo32A [KERNEL32.342]
425 INT32 WINAPI GetLocaleInfo32A(LCID lcid,LCTYPE LCType,LPSTR buf,INT32 len)
427 char *retString;
428 int found,i;
429 int lang=0;
431 TRACE(ole,"(lcid=0x%lx,lctype=0x%lx,%p,%x)\n",
432 lcid,LCType,buf,len);
434 if (len && (! buf) )
435 { SetLastError(ERROR_INSUFFICIENT_BUFFER);
436 return 0;
439 if (lcid == LOCALE_SYSTEM_DEFAULT || (LCType & LOCALE_NOUSEROVERRIDE) )
440 { lcid = GetSystemDefaultLCID();
442 else if (lcid == LOCALE_USER_DEFAULT)
443 { lcid = GetUserDefaultLCID();
446 LCType &= ~(LOCALE_NOUSEROVERRIDE|LOCALE_USE_CP_ACP);
448 /* As an option, we could obtain the value from win.ini.
449 This would not match the Wine compile-time option.
450 Also, not all identifiers are available from win.ini */
451 retString=0;
452 /* If we are through all of this, retLen should not be zero anymore.
453 If it is, the value is not supported */
454 i=0;
455 while (locale_name2id[i].name!=NULL) {
456 if (LCType == locale_name2id[i].id) {
457 retString = locale_name2id[i].name;
458 break;
460 i++;
462 if (!retString) {
463 WARN(ole,"Unkown LC type %lX\n",LCType);
464 return 0;
467 #define LOCVAL(type,value) case type:retString=value;found=1;break;
468 #define LANG_BEGIN(l,s) case MAKELANGID(l,s): switch (LCType) {
469 #define LANG_END default: found=0; break; } break;
471 /* Now, the language specific definitions. They don't have to be
472 complete */
474 found=0; i=0; lang=lcid;
476 if (lang ==0x400) /*LANG_NEUTRAL ==> US English*/
477 { lang = 0x409;
478 WARN(ole,"no language set, assume LANG_ENGLISH_US \n");
483 { switch(lang)
486 LANG_BEGIN (LANG_GERMAN, SUBLANG_GERMAN) /*0x407*/
487 #include "nls/deu.nls"
488 LANG_END
490 LANG_BEGIN (LANG_DANISH, SUBLANG_DEFAULT) /*0x406*/
491 #include "nls/dan.nls"
492 LANG_END
494 LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_US) /*0x409*/
495 #include "nls/enu.nls"
496 LANG_END
498 LANG_BEGIN (LANG_ESPERANTO, SUBLANG_DEFAULT) /*0x48f*/
499 #include "nls/esperanto.nls"
500 LANG_END
502 LANG_BEGIN (LANG_FINNISH, SUBLANG_DEFAULT) /*0x040B*/
503 #include "nls/fin.nls"
504 LANG_END
506 LANG_BEGIN (LANG_FRENCH, SUBLANG_DEFAULT) /*0x040C*/
507 #include "nls/fra.nls"
508 LANG_END
510 LANG_BEGIN (LANG_ITALIAN, SUBLANG_ITALIAN) /*0x410*/
511 #include "nls/ita.nls"
512 LANG_END
514 LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_UK) /*0x809*/
515 #include "nls/eng.nls"
516 LANG_END
518 LANG_BEGIN (LANG_KOREAN, SUBLANG_KOREAN) /*0x412*/
519 #include "nls/kor.nls"
520 LANG_END
522 LANG_BEGIN (LANG_HUNGARIAN, SUBLANG_DEFAULT) /*0x40e*/
523 #include "nls/hun.nls"
524 LANG_END
526 LANG_BEGIN (LANG_POLISH, SUBLANG_DEFAULT) /*0x415*/
527 #include "nls/plk.nls"
528 LANG_END
530 LANG_BEGIN (LANG_PORTUGUESE ,SUBLANG_PORTUGUESE_BRAZILIAN) /*0x416*/
531 #include "nls/ptb.nls"
532 LANG_END
534 LANG_BEGIN (LANG_SWEDISH, SUBLANG_DEFAULT) /*0x41d*/
535 #include "nls/sve.nls"
536 LANG_END
538 /*Insert other languages here*/
540 default:
541 found=0;
542 break;
543 } /* switch */
546 /* language not found, try without a sublanguage*/
547 if (i==1) lang=MAKELANGID( PRIMARYLANGID(lang), SUBLANG_DEFAULT);
549 /* mask the LC Value */
550 if (i==2) LCType &= 0xfff;
552 i++;
553 } while (!found && i<3);
555 if(!found)
556 { ERR(ole,"'%s' not supported for your language.\n", retString);
557 SetLastError(ERROR_INVALID_PARAMETER);
558 return 0;
560 /* if len=0 return only the length, don't touch the buffer*/
561 if (len)
562 lstrcpyn32A(buf,retString,len);
564 return strlen(retString)+1;
567 /******************************************************************************
568 * GetLocaleInfo32W [KERNEL32.343]
571 INT32 WINAPI GetLocaleInfo32W(LCID lcid,LCTYPE LCType,LPWSTR wbuf,INT32 len)
572 { WORD wlen;
573 LPSTR abuf;
575 if (len && (! wbuf) )
576 { SetLastError(ERROR_INSUFFICIENT_BUFFER);
577 return 0;
580 abuf = (LPSTR)HeapAlloc(GetProcessHeap(),0,len);
581 wlen = 2 * GetLocaleInfo32A(lcid, LCType, abuf, len);
583 if (wlen && len) /* if len=0 return only the length*/
584 lstrcpynAtoW(wbuf,abuf,len/2);
586 HeapFree(GetProcessHeap(),0,abuf);
587 return wlen;
590 /******************************************************************************
591 * SetLocaleInfoA [KERNEL32.656]
593 BOOL16 WINAPI SetLocaleInfoA(DWORD lcid, DWORD lctype, LPCSTR data)
595 FIXME(ole,"(%ld,%ld,%s): stub\n",lcid,lctype,data);
596 return TRUE;
599 /******************************************************************************
600 * IsValidLocale [KERNEL32.489]
602 BOOL32 WINAPI IsValidLocale(LCID lcid,DWORD flags)
604 /* we support ANY language. Well, at least say that...*/
605 return TRUE;
608 /******************************************************************************
609 * EnumSystemLocales32W [KERNEL32.209]
611 BOOL32 WINAPI EnumSystemLocales32W( LOCALE_ENUMPROC32W lpfnLocaleEnum,
612 DWORD flags )
614 int i;
615 BOOL32 ret;
616 WCHAR buffer[200];
617 HKEY xhkey;
619 TRACE(win32,"(%p,%08lx)\n",lpfnLocaleEnum,flags );
620 /* see if we can reuse the Win95 registry entries.... */
621 if (ERROR_SUCCESS==RegOpenKey32A(HKEY_LOCAL_MACHINE,"\\System\\CurrentControlSet\\control\\Nls\\Locale\\",&xhkey)) {
622 i=0;
623 while (1) {
624 if (ERROR_SUCCESS!=RegEnumKey32W(xhkey,i,buffer,sizeof(buffer)))
625 break;
626 if (!lpfnLocaleEnum(buffer))
627 break;
628 i++;
630 RegCloseKey(xhkey);
631 return TRUE;
634 i=0;
635 while (languages[i].langname!=NULL)
637 LPWSTR cp;
638 char xbuffer[10];
640 sprintf(xbuffer,"%08lx",(DWORD)languages[i].langid);
642 cp = HEAP_strdupAtoW( GetProcessHeap(), 0, xbuffer );
643 ret = lpfnLocaleEnum(cp);
644 HeapFree( GetProcessHeap(), 0, cp );
645 if (!ret) break;
646 i++;
648 return TRUE;
651 /******************************************************************************
652 * EnumSystemLocales32A [KERNEL32.208]
654 BOOL32 WINAPI EnumSystemLocales32A(LOCALE_ENUMPROC32A lpfnLocaleEnum,
655 DWORD flags)
657 int i;
658 CHAR buffer[200];
659 HKEY xhkey;
661 TRACE(win32,"(%p,%08lx)\n",
662 lpfnLocaleEnum,flags
664 if (ERROR_SUCCESS==RegOpenKey32A(HKEY_LOCAL_MACHINE,"\\System\\CurrentControlSet\\control\\Nls\\Locale\\",&xhkey)) {
665 i=0;
666 while (1) {
667 if (ERROR_SUCCESS!=RegEnumKey32A(xhkey,i,buffer,sizeof(buffer)))
668 break;
669 if (!lpfnLocaleEnum(buffer))
670 break;
671 i++;
673 RegCloseKey(xhkey);
674 return TRUE;
676 i=0;
677 while (languages[i].langname!=NULL) {
678 sprintf(buffer,"%08lx",(DWORD)languages[i].langid);
679 if (!lpfnLocaleEnum(buffer))
680 break;
681 i++;
683 return TRUE;
686 static const unsigned char CT_CType2_LUT[] = {
687 C2_NOTAPPLICABLE, /* - 0 */
688 C2_NOTAPPLICABLE, /* - 1 */
689 C2_NOTAPPLICABLE, /* - 2 */
690 C2_NOTAPPLICABLE, /* - 3 */
691 C2_NOTAPPLICABLE, /* - 4 */
692 C2_NOTAPPLICABLE, /* - 5 */
693 C2_NOTAPPLICABLE, /* - 6 */
694 C2_NOTAPPLICABLE, /* - 7 */
695 C2_NOTAPPLICABLE, /* - 8 */
696 C2_SEGMENTSEPARATOR, /* - 9 */
697 C2_NOTAPPLICABLE, /* - 10 */
698 C2_NOTAPPLICABLE, /* - 11 */
699 C2_NOTAPPLICABLE, /* - 12 */
700 C2_NOTAPPLICABLE, /* - 13 */
701 C2_NOTAPPLICABLE, /* - 14 */
702 C2_NOTAPPLICABLE, /* - 15 */
703 C2_NOTAPPLICABLE, /* - 16 */
704 C2_NOTAPPLICABLE, /* - 17 */
705 C2_NOTAPPLICABLE, /* - 18 */
706 C2_NOTAPPLICABLE, /* - 19 */
707 C2_NOTAPPLICABLE, /* - 20 */
708 C2_NOTAPPLICABLE, /* - 21 */
709 C2_NOTAPPLICABLE, /* - 22 */
710 C2_NOTAPPLICABLE, /* - 23 */
711 C2_NOTAPPLICABLE, /* - 24 */
712 C2_NOTAPPLICABLE, /* - 25 */
713 C2_NOTAPPLICABLE, /* - 26 */
714 C2_NOTAPPLICABLE, /* - 27 */
715 C2_NOTAPPLICABLE, /* - 28 */
716 C2_NOTAPPLICABLE, /* - 29 */
717 C2_NOTAPPLICABLE, /* - 30 */
718 C2_NOTAPPLICABLE, /* - 31 */
719 C2_WHITESPACE, /* - 32 */
720 C2_OTHERNEUTRAL, /* ! - 33 */
721 C2_OTHERNEUTRAL, /* " - 34 */ /* " */
722 C2_EUROPETERMINATOR, /* # - 35 */
723 C2_EUROPETERMINATOR, /* $ - 36 */
724 C2_EUROPETERMINATOR, /* % - 37 */
725 C2_LEFTTORIGHT, /* & - 38 */
726 C2_OTHERNEUTRAL, /* ' - 39 */
727 C2_OTHERNEUTRAL, /* ( - 40 */
728 C2_OTHERNEUTRAL, /* ) - 41 */
729 C2_OTHERNEUTRAL, /* * - 42 */
730 C2_EUROPETERMINATOR, /* + - 43 */
731 C2_COMMONSEPARATOR, /* , - 44 */
732 C2_EUROPETERMINATOR, /* - - 45 */
733 C2_EUROPESEPARATOR, /* . - 46 */
734 C2_EUROPESEPARATOR, /* / - 47 */
735 C2_EUROPENUMBER, /* 0 - 48 */
736 C2_EUROPENUMBER, /* 1 - 49 */
737 C2_EUROPENUMBER, /* 2 - 50 */
738 C2_EUROPENUMBER, /* 3 - 51 */
739 C2_EUROPENUMBER, /* 4 - 52 */
740 C2_EUROPENUMBER, /* 5 - 53 */
741 C2_EUROPENUMBER, /* 6 - 54 */
742 C2_EUROPENUMBER, /* 7 - 55 */
743 C2_EUROPENUMBER, /* 8 - 56 */
744 C2_EUROPENUMBER, /* 9 - 57 */
745 C2_COMMONSEPARATOR, /* : - 58 */
746 C2_OTHERNEUTRAL, /* ; - 59 */
747 C2_OTHERNEUTRAL, /* < - 60 */
748 C2_OTHERNEUTRAL, /* = - 61 */
749 C2_OTHERNEUTRAL, /* > - 62 */
750 C2_OTHERNEUTRAL, /* ? - 63 */
751 C2_LEFTTORIGHT, /* @ - 64 */
752 C2_LEFTTORIGHT, /* A - 65 */
753 C2_LEFTTORIGHT, /* B - 66 */
754 C2_LEFTTORIGHT, /* C - 67 */
755 C2_LEFTTORIGHT, /* D - 68 */
756 C2_LEFTTORIGHT, /* E - 69 */
757 C2_LEFTTORIGHT, /* F - 70 */
758 C2_LEFTTORIGHT, /* G - 71 */
759 C2_LEFTTORIGHT, /* H - 72 */
760 C2_LEFTTORIGHT, /* I - 73 */
761 C2_LEFTTORIGHT, /* J - 74 */
762 C2_LEFTTORIGHT, /* K - 75 */
763 C2_LEFTTORIGHT, /* L - 76 */
764 C2_LEFTTORIGHT, /* M - 77 */
765 C2_LEFTTORIGHT, /* N - 78 */
766 C2_LEFTTORIGHT, /* O - 79 */
767 C2_LEFTTORIGHT, /* P - 80 */
768 C2_LEFTTORIGHT, /* Q - 81 */
769 C2_LEFTTORIGHT, /* R - 82 */
770 C2_LEFTTORIGHT, /* S - 83 */
771 C2_LEFTTORIGHT, /* T - 84 */
772 C2_LEFTTORIGHT, /* U - 85 */
773 C2_LEFTTORIGHT, /* V - 86 */
774 C2_LEFTTORIGHT, /* W - 87 */
775 C2_LEFTTORIGHT, /* X - 88 */
776 C2_LEFTTORIGHT, /* Y - 89 */
777 C2_LEFTTORIGHT, /* Z - 90 */
778 C2_OTHERNEUTRAL, /* [ - 91 */
779 C2_OTHERNEUTRAL, /* \ - 92 */
780 C2_OTHERNEUTRAL, /* ] - 93 */
781 C2_OTHERNEUTRAL, /* ^ - 94 */
782 C2_OTHERNEUTRAL, /* _ - 95 */
783 C2_OTHERNEUTRAL, /* ` - 96 */
784 C2_LEFTTORIGHT, /* a - 97 */
785 C2_LEFTTORIGHT, /* b - 98 */
786 C2_LEFTTORIGHT, /* c - 99 */
787 C2_LEFTTORIGHT, /* d - 100 */
788 C2_LEFTTORIGHT, /* e - 101 */
789 C2_LEFTTORIGHT, /* f - 102 */
790 C2_LEFTTORIGHT, /* g - 103 */
791 C2_LEFTTORIGHT, /* h - 104 */
792 C2_LEFTTORIGHT, /* i - 105 */
793 C2_LEFTTORIGHT, /* j - 106 */
794 C2_LEFTTORIGHT, /* k - 107 */
795 C2_LEFTTORIGHT, /* l - 108 */
796 C2_LEFTTORIGHT, /* m - 109 */
797 C2_LEFTTORIGHT, /* n - 110 */
798 C2_LEFTTORIGHT, /* o - 111 */
799 C2_LEFTTORIGHT, /* p - 112 */
800 C2_LEFTTORIGHT, /* q - 113 */
801 C2_LEFTTORIGHT, /* r - 114 */
802 C2_LEFTTORIGHT, /* s - 115 */
803 C2_LEFTTORIGHT, /* t - 116 */
804 C2_LEFTTORIGHT, /* u - 117 */
805 C2_LEFTTORIGHT, /* v - 118 */
806 C2_LEFTTORIGHT, /* w - 119 */
807 C2_LEFTTORIGHT, /* x - 120 */
808 C2_LEFTTORIGHT, /* y - 121 */
809 C2_LEFTTORIGHT, /* z - 122 */
810 C2_OTHERNEUTRAL, /* { - 123 */
811 C2_OTHERNEUTRAL, /* | - 124 */
812 C2_OTHERNEUTRAL, /* } - 125 */
813 C2_OTHERNEUTRAL, /* ~ - 126 */
814 C2_NOTAPPLICABLE, /* \x7f - 127 */
815 C2_NOTAPPLICABLE, /* € - 128 */
816 C2_NOTAPPLICABLE, /* � - 129 */
817 C2_OTHERNEUTRAL, /* ‚ - 130 */
818 C2_LEFTTORIGHT, /* ƒ - 131 */
819 C2_OTHERNEUTRAL, /* „ - 132 */
820 C2_OTHERNEUTRAL, /* … - 133 */
821 C2_OTHERNEUTRAL, /* † - 134 */
822 C2_OTHERNEUTRAL, /* ‡ - 135 */
823 C2_LEFTTORIGHT, /* ˆ - 136 */
824 C2_EUROPETERMINATOR, /* ‰ - 137 */
825 C2_LEFTTORIGHT, /* Š - 138 */
826 C2_OTHERNEUTRAL, /* ‹ - 139 */
827 C2_LEFTTORIGHT, /* Π- 140 */
828 C2_NOTAPPLICABLE, /* � - 141 */
829 C2_NOTAPPLICABLE, /* Ž - 142 */
830 C2_NOTAPPLICABLE, /* � - 143 */
831 C2_NOTAPPLICABLE, /* � - 144 */
832 C2_OTHERNEUTRAL, /* ‘ - 145 */
833 C2_OTHERNEUTRAL, /* ’ - 146 */
834 C2_OTHERNEUTRAL, /* “ - 147 */
835 C2_OTHERNEUTRAL, /* ” - 148 */
836 C2_OTHERNEUTRAL, /* • - 149 */
837 C2_OTHERNEUTRAL, /* – - 150 */
838 C2_OTHERNEUTRAL, /* — - 151 */
839 C2_LEFTTORIGHT, /* ˜ - 152 */
840 C2_OTHERNEUTRAL, /* ™ - 153 */
841 C2_LEFTTORIGHT, /* š - 154 */
842 C2_OTHERNEUTRAL, /* › - 155 */
843 C2_LEFTTORIGHT, /* œ - 156 */
844 C2_NOTAPPLICABLE, /* � - 157 */
845 C2_NOTAPPLICABLE, /* ž - 158 */
846 C2_LEFTTORIGHT, /* Ÿ - 159 */
847 C2_WHITESPACE, /*   - 160 */
848 C2_OTHERNEUTRAL, /* ¡ - 161 */
849 C2_EUROPETERMINATOR, /* ¢ - 162 */
850 C2_EUROPETERMINATOR, /* £ - 163 */
851 C2_EUROPETERMINATOR, /* ¤ - 164 */
852 C2_EUROPETERMINATOR, /* ¥ - 165 */
853 C2_OTHERNEUTRAL, /* ¦ - 166 */
854 C2_OTHERNEUTRAL, /* § - 167 */
855 C2_OTHERNEUTRAL, /* ¨ - 168 */
856 C2_OTHERNEUTRAL, /* © - 169 */
857 C2_OTHERNEUTRAL, /* ª - 170 */
858 C2_OTHERNEUTRAL, /* « - 171 */
859 C2_OTHERNEUTRAL, /* ¬ - 172 */
860 C2_OTHERNEUTRAL, /* ­ - 173 */
861 C2_OTHERNEUTRAL, /* ® - 174 */
862 C2_OTHERNEUTRAL, /* ¯ - 175 */
863 C2_EUROPETERMINATOR, /* ° - 176 */
864 C2_EUROPETERMINATOR, /* ± - 177 */
865 C2_EUROPENUMBER, /* ² - 178 */
866 C2_EUROPENUMBER, /* ³ - 179 */
867 C2_OTHERNEUTRAL, /* ´ - 180 */
868 C2_OTHERNEUTRAL, /* µ - 181 */
869 C2_OTHERNEUTRAL, /* ¶ - 182 */
870 C2_OTHERNEUTRAL, /* · - 183 */
871 C2_OTHERNEUTRAL, /* ¸ - 184 */
872 C2_EUROPENUMBER, /* ¹ - 185 */
873 C2_OTHERNEUTRAL, /* º - 186 */
874 C2_OTHERNEUTRAL, /* » - 187 */
875 C2_OTHERNEUTRAL, /* ¼ - 188 */
876 C2_OTHERNEUTRAL, /* ½ - 189 */
877 C2_OTHERNEUTRAL, /* ¾ - 190 */
878 C2_OTHERNEUTRAL, /* ¿ - 191 */
879 C2_LEFTTORIGHT, /* À - 192 */
880 C2_LEFTTORIGHT, /* Á - 193 */
881 C2_LEFTTORIGHT, /* Â - 194 */
882 C2_LEFTTORIGHT, /* Ã - 195 */
883 C2_LEFTTORIGHT, /* Ä - 196 */
884 C2_LEFTTORIGHT, /* Å - 197 */
885 C2_LEFTTORIGHT, /* Æ - 198 */
886 C2_LEFTTORIGHT, /* Ç - 199 */
887 C2_LEFTTORIGHT, /* È - 200 */
888 C2_LEFTTORIGHT, /* É - 201 */
889 C2_LEFTTORIGHT, /* Ê - 202 */
890 C2_LEFTTORIGHT, /* Ë - 203 */
891 C2_LEFTTORIGHT, /* Ì - 204 */
892 C2_LEFTTORIGHT, /* Í - 205 */
893 C2_LEFTTORIGHT, /* Î - 206 */
894 C2_LEFTTORIGHT, /* Ï - 207 */
895 C2_LEFTTORIGHT, /* Ð - 208 */
896 C2_LEFTTORIGHT, /* Ñ - 209 */
897 C2_LEFTTORIGHT, /* Ò - 210 */
898 C2_LEFTTORIGHT, /* Ó - 211 */
899 C2_LEFTTORIGHT, /* Ô - 212 */
900 C2_LEFTTORIGHT, /* Õ - 213 */
901 C2_LEFTTORIGHT, /* Ö - 214 */
902 C2_OTHERNEUTRAL, /* × - 215 */
903 C2_LEFTTORIGHT, /* Ø - 216 */
904 C2_LEFTTORIGHT, /* Ù - 217 */
905 C2_LEFTTORIGHT, /* Ú - 218 */
906 C2_LEFTTORIGHT, /* Û - 219 */
907 C2_LEFTTORIGHT, /* Ü - 220 */
908 C2_LEFTTORIGHT, /* Ý - 221 */
909 C2_LEFTTORIGHT, /* Þ - 222 */
910 C2_LEFTTORIGHT, /* ß - 223 */
911 C2_LEFTTORIGHT, /* à - 224 */
912 C2_LEFTTORIGHT, /* á - 225 */
913 C2_LEFTTORIGHT, /* â - 226 */
914 C2_LEFTTORIGHT, /* ã - 227 */
915 C2_LEFTTORIGHT, /* ä - 228 */
916 C2_LEFTTORIGHT, /* å - 229 */
917 C2_LEFTTORIGHT, /* æ - 230 */
918 C2_LEFTTORIGHT, /* ç - 231 */
919 C2_LEFTTORIGHT, /* è - 232 */
920 C2_LEFTTORIGHT, /* é - 233 */
921 C2_LEFTTORIGHT, /* ê - 234 */
922 C2_LEFTTORIGHT, /* ë - 235 */
923 C2_LEFTTORIGHT, /* ì - 236 */
924 C2_LEFTTORIGHT, /* í - 237 */
925 C2_LEFTTORIGHT, /* î - 238 */
926 C2_LEFTTORIGHT, /* ï - 239 */
927 C2_LEFTTORIGHT, /* ð - 240 */
928 C2_LEFTTORIGHT, /* ñ - 241 */
929 C2_LEFTTORIGHT, /* ò - 242 */
930 C2_LEFTTORIGHT, /* ó - 243 */
931 C2_LEFTTORIGHT, /* ô - 244 */
932 C2_LEFTTORIGHT, /* õ - 245 */
933 C2_LEFTTORIGHT, /* ö - 246 */
934 C2_OTHERNEUTRAL, /* ÷ - 247 */
935 C2_LEFTTORIGHT, /* ø - 248 */
936 C2_LEFTTORIGHT, /* ù - 249 */
937 C2_LEFTTORIGHT, /* ú - 250 */
938 C2_LEFTTORIGHT, /* û - 251 */
939 C2_LEFTTORIGHT, /* ü - 252 */
940 C2_LEFTTORIGHT, /* ý - 253 */
941 C2_LEFTTORIGHT, /* þ - 254 */
942 C2_LEFTTORIGHT /* ÿ - 255 */
945 static const WORD CT_CType3_LUT[] = {
946 0x0000, /* - 0 */
947 0x0000, /* - 1 */
948 0x0000, /* - 2 */
949 0x0000, /* - 3 */
950 0x0000, /* - 4 */
951 0x0000, /* - 5 */
952 0x0000, /* - 6 */
953 0x0000, /* - 7 */
954 0x0000, /* - 8 */
955 0x0008, /* - 9 */
956 0x0008, /* - 10 */
957 0x0008, /* - 11 */
958 0x0008, /* - 12 */
959 0x0008, /* - 13 */
960 0x0000, /* - 14 */
961 0x0000, /* - 15 */
962 0x0000, /* - 16 */
963 0x0000, /* - 17 */
964 0x0000, /* - 18 */
965 0x0000, /* - 19 */
966 0x0000, /* - 20 */
967 0x0000, /* - 21 */
968 0x0000, /* - 22 */
969 0x0000, /* - 23 */
970 0x0000, /* - 24 */
971 0x0000, /* - 25 */
972 0x0000, /* - 26 */
973 0x0000, /* - 27 */
974 0x0000, /* - 28 */
975 0x0000, /* - 29 */
976 0x0000, /* - 30 */
977 0x0000, /* - 31 */
978 0x0048, /* - 32 */
979 0x0048, /* ! - 33 */
980 0x0448, /* " - 34 */ /* " */
981 0x0048, /* # - 35 */
982 0x0448, /* $ - 36 */
983 0x0048, /* % - 37 */
984 0x0048, /* & - 38 */
985 0x0440, /* ' - 39 */
986 0x0048, /* ( - 40 */
987 0x0048, /* ) - 41 */
988 0x0048, /* * - 42 */
989 0x0048, /* + - 43 */
990 0x0048, /* , - 44 */
991 0x0440, /* - - 45 */
992 0x0048, /* . - 46 */
993 0x0448, /* / - 47 */
994 0x0040, /* 0 - 48 */
995 0x0040, /* 1 - 49 */
996 0x0040, /* 2 - 50 */
997 0x0040, /* 3 - 51 */
998 0x0040, /* 4 - 52 */
999 0x0040, /* 5 - 53 */
1000 0x0040, /* 6 - 54 */
1001 0x0040, /* 7 - 55 */
1002 0x0040, /* 8 - 56 */
1003 0x0040, /* 9 - 57 */
1004 0x0048, /* : - 58 */
1005 0x0048, /* ; - 59 */
1006 0x0048, /* < - 60 */
1007 0x0448, /* = - 61 */
1008 0x0048, /* > - 62 */
1009 0x0048, /* ? - 63 */
1010 0x0448, /* @ - 64 */
1011 0x8040, /* A - 65 */
1012 0x8040, /* B - 66 */
1013 0x8040, /* C - 67 */
1014 0x8040, /* D - 68 */
1015 0x8040, /* E - 69 */
1016 0x8040, /* F - 70 */
1017 0x8040, /* G - 71 */
1018 0x8040, /* H - 72 */
1019 0x8040, /* I - 73 */
1020 0x8040, /* J - 74 */
1021 0x8040, /* K - 75 */
1022 0x8040, /* L - 76 */
1023 0x8040, /* M - 77 */
1024 0x8040, /* N - 78 */
1025 0x8040, /* O - 79 */
1026 0x8040, /* P - 80 */
1027 0x8040, /* Q - 81 */
1028 0x8040, /* R - 82 */
1029 0x8040, /* S - 83 */
1030 0x8040, /* T - 84 */
1031 0x8040, /* U - 85 */
1032 0x8040, /* V - 86 */
1033 0x8040, /* W - 87 */
1034 0x8040, /* X - 88 */
1035 0x8040, /* Y - 89 */
1036 0x8040, /* Z - 90 */
1037 0x0048, /* [ - 91 */
1038 0x0448, /* \ - 92 */
1039 0x0048, /* ] - 93 */
1040 0x0448, /* ^ - 94 */
1041 0x0448, /* _ - 95 */
1042 0x0448, /* ` - 96 */
1043 0x8040, /* a - 97 */
1044 0x8040, /* b - 98 */
1045 0x8040, /* c - 99 */
1046 0x8040, /* d - 100 */
1047 0x8040, /* e - 101 */
1048 0x8040, /* f - 102 */
1049 0x8040, /* g - 103 */
1050 0x8040, /* h - 104 */
1051 0x8040, /* i - 105 */
1052 0x8040, /* j - 106 */
1053 0x8040, /* k - 107 */
1054 0x8040, /* l - 108 */
1055 0x8040, /* m - 109 */
1056 0x8040, /* n - 110 */
1057 0x8040, /* o - 111 */
1058 0x8040, /* p - 112 */
1059 0x8040, /* q - 113 */
1060 0x8040, /* r - 114 */
1061 0x8040, /* s - 115 */
1062 0x8040, /* t - 116 */
1063 0x8040, /* u - 117 */
1064 0x8040, /* v - 118 */
1065 0x8040, /* w - 119 */
1066 0x8040, /* x - 120 */
1067 0x8040, /* y - 121 */
1068 0x8040, /* z - 122 */
1069 0x0048, /* { - 123 */
1070 0x0048, /* | - 124 */
1071 0x0048, /* } - 125 */
1072 0x0448, /* ~ - 126 */
1073 0x0000, /* \x7f - 127 */
1074 0x0000, /* € - 128 */
1075 0x0000, /* � - 129 */
1076 0x0008, /* ‚ - 130 */
1077 0x8000, /* ƒ - 131 */
1078 0x0008, /* „ - 132 */
1079 0x0008, /* … - 133 */
1080 0x0008, /* † - 134 */
1081 0x0008, /* ‡ - 135 */
1082 0x0001, /* ˆ - 136 */
1083 0x0008, /* ‰ - 137 */
1084 0x8003, /* Š - 138 */
1085 0x0008, /* ‹ - 139 */
1086 0x8000, /* Π- 140 */
1087 0x0000, /* � - 141 */
1088 0x0000, /* Ž - 142 */
1089 0x0000, /* � - 143 */
1090 0x0000, /* � - 144 */
1091 0x0088, /* ‘ - 145 */
1092 0x0088, /* ’ - 146 */
1093 0x0088, /* “ - 147 */
1094 0x0088, /* ” - 148 */
1095 0x0008, /* • - 149 */
1096 0x0400, /* – - 150 */
1097 0x0400, /* — - 151 */
1098 0x0408, /* ˜ - 152 */
1099 0x0000, /* ™ - 153 */
1100 0x8003, /* š - 154 */
1101 0x0008, /* › - 155 */
1102 0x8000, /* œ - 156 */
1103 0x0000, /* � - 157 */
1104 0x0000, /* ž - 158 */
1105 0x8003, /* Ÿ - 159 */
1106 0x0008, /*   - 160 */
1107 0x0008, /* ¡ - 161 */
1108 0x0048, /* ¢ - 162 */
1109 0x0048, /* £ - 163 */
1110 0x0008, /* ¤ - 164 */
1111 0x0048, /* ¥ - 165 */
1112 0x0048, /* ¦ - 166 */
1113 0x0008, /* § - 167 */
1114 0x0408, /* ¨ - 168 */
1115 0x0008, /* © - 169 */
1116 0x0400, /* ª - 170 */
1117 0x0008, /* « - 171 */
1118 0x0048, /* ¬ - 172 */
1119 0x0408, /* ­ - 173 */
1120 0x0008, /* ® - 174 */
1121 0x0448, /* ¯ - 175 */
1122 0x0008, /* ° - 176 */
1123 0x0008, /* ± - 177 */
1124 0x0000, /* ² - 178 */
1125 0x0000, /* ³ - 179 */
1126 0x0408, /* ´ - 180 */
1127 0x0008, /* µ - 181 */
1128 0x0008, /* ¶ - 182 */
1129 0x0008, /* · - 183 */
1130 0x0408, /* ¸ - 184 */
1131 0x0000, /* ¹ - 185 */
1132 0x0400, /* º - 186 */
1133 0x0008, /* » - 187 */
1134 0x0000, /* ¼ - 188 */
1135 0x0000, /* ½ - 189 */
1136 0x0000, /* ¾ - 190 */
1137 0x0008, /* ¿ - 191 */
1138 0x8003, /* À - 192 */
1139 0x8003, /* Á - 193 */
1140 0x8003, /* Â - 194 */
1141 0x8003, /* Ã - 195 */
1142 0x8003, /* Ä - 196 */
1143 0x8003, /* Å - 197 */
1144 0x8000, /* Æ - 198 */
1145 0x8003, /* Ç - 199 */
1146 0x8003, /* È - 200 */
1147 0x8003, /* É - 201 */
1148 0x8003, /* Ê - 202 */
1149 0x8003, /* Ë - 203 */
1150 0x8003, /* Ì - 204 */
1151 0x8003, /* Í - 205 */
1152 0x8003, /* Î - 206 */
1153 0x8003, /* Ï - 207 */
1154 0x8000, /* Ð - 208 */
1155 0x8003, /* Ñ - 209 */
1156 0x8003, /* Ò - 210 */
1157 0x8003, /* Ó - 211 */
1158 0x8003, /* Ô - 212 */
1159 0x8003, /* Õ - 213 */
1160 0x8003, /* Ö - 214 */
1161 0x0008, /* × - 215 */
1162 0x8003, /* Ø - 216 */
1163 0x8003, /* Ù - 217 */
1164 0x8003, /* Ú - 218 */
1165 0x8003, /* Û - 219 */
1166 0x8003, /* Ü - 220 */
1167 0x8003, /* Ý - 221 */
1168 0x8000, /* Þ - 222 */
1169 0x8000, /* ß - 223 */
1170 0x8003, /* à - 224 */
1171 0x8003, /* á - 225 */
1172 0x8003, /* â - 226 */
1173 0x8003, /* ã - 227 */
1174 0x8003, /* ä - 228 */
1175 0x8003, /* å - 229 */
1176 0x8000, /* æ - 230 */
1177 0x8003, /* ç - 231 */
1178 0x8003, /* è - 232 */
1179 0x8003, /* é - 233 */
1180 0x8003, /* ê - 234 */
1181 0x8003, /* ë - 235 */
1182 0x8003, /* ì - 236 */
1183 0x8003, /* í - 237 */
1184 0x8003, /* î - 238 */
1185 0x8003, /* ï - 239 */
1186 0x8000, /* ð - 240 */
1187 0x8003, /* ñ - 241 */
1188 0x8003, /* ò - 242 */
1189 0x8003, /* ó - 243 */
1190 0x8003, /* ô - 244 */
1191 0x8003, /* õ - 245 */
1192 0x8003, /* ö - 246 */
1193 0x0008, /* ÷ - 247 */
1194 0x8003, /* ø - 248 */
1195 0x8003, /* ù - 249 */
1196 0x8003, /* ú - 250 */
1197 0x8003, /* û - 251 */
1198 0x8003, /* ü - 252 */
1199 0x8003, /* ý - 253 */
1200 0x8000, /* þ - 254 */
1201 0x8003 /* ÿ - 255 */
1204 /******************************************************************************
1205 * GetStringType16 [OLE2NLS.7]
1207 BOOL16 WINAPI GetStringType16(LCID locale,DWORD dwInfoType,LPCSTR src,
1208 INT16 cchSrc,LPWORD chartype)
1210 return GetStringTypeEx32A(locale,dwInfoType,src,cchSrc,chartype);
1212 /******************************************************************************
1213 * GetStringType32A [KERNEL32.396]
1215 BOOL32 WINAPI GetStringType32A(LCID locale,DWORD dwInfoType,LPCSTR src,
1216 INT32 cchSrc,LPWORD chartype)
1218 return GetStringTypeEx32A(locale,dwInfoType,src,cchSrc,chartype);
1221 /******************************************************************************
1222 * GetStringTypeEx32A [KERNEL32.397]
1224 * FIXME: Ignores the locale.
1226 BOOL32 WINAPI GetStringTypeEx32A(LCID locale,DWORD dwInfoType,LPCSTR src,
1227 INT32 cchSrc,LPWORD chartype)
1229 int i;
1231 if ((src==NULL) || (chartype==NULL) || (src==(LPSTR)chartype))
1233 SetLastError(ERROR_INVALID_PARAMETER);
1234 return FALSE;
1237 if (cchSrc==-1)
1238 cchSrc=lstrlen32A(src)+1;
1240 switch (dwInfoType) {
1241 case CT_CTYPE1:
1242 for (i=0;i<cchSrc;i++)
1244 chartype[i] = 0;
1245 if (isdigit(src[i])) chartype[i]|=C1_DIGIT;
1246 if (isalpha(src[i])) chartype[i]|=C1_ALPHA;
1247 if (islower(src[i])) chartype[i]|=C1_LOWER;
1248 if (isupper(src[i])) chartype[i]|=C1_UPPER;
1249 if (isspace(src[i])) chartype[i]|=C1_SPACE;
1250 if (ispunct(src[i])) chartype[i]|=C1_PUNCT;
1251 if (iscntrl(src[i])) chartype[i]|=C1_CNTRL;
1252 /* FIXME: isblank() is a GNU extension */
1253 /* if (isblank(src[i])) chartype[i]|=C1_BLANK; */
1254 if ((src[i] == ' ') || (src[i] == '\t')) chartype[i]|=C1_BLANK;
1255 /* C1_XDIGIT */
1257 return TRUE;
1259 case CT_CTYPE2:
1260 for (i=0;i<cchSrc;i++)
1262 chartype[i]=(WORD)CT_CType2_LUT[i];
1264 return TRUE;
1266 case CT_CTYPE3:
1267 for (i=0;i<cchSrc;i++)
1269 chartype[i]=CT_CType3_LUT[i];
1271 return TRUE;
1273 default:
1274 ERR(ole,"Unknown dwInfoType:%ld\n",dwInfoType);
1275 return FALSE;
1279 /******************************************************************************
1280 * GetStringType32W [KERNEL32.399]
1282 * NOTES
1283 * Yes, this is missing LCID locale. MS fault.
1285 BOOL32 WINAPI GetStringType32W(DWORD dwInfoType,LPCWSTR src,INT32 cchSrc,
1286 LPWORD chartype)
1288 return GetStringTypeEx32W(0/*defaultlocale*/,dwInfoType,src,cchSrc,chartype);
1291 /******************************************************************************
1292 * GetStringTypeEx32W [KERNEL32.398]
1294 * FIXME: unicode chars are assumed chars
1296 BOOL32 WINAPI GetStringTypeEx32W(LCID locale,DWORD dwInfoType,LPCWSTR src,
1297 INT32 cchSrc,LPWORD chartype)
1299 int i;
1302 if (cchSrc==-1)
1303 cchSrc=lstrlen32W(src)+1;
1305 switch (dwInfoType) {
1306 case CT_CTYPE2:
1307 FIXME(ole,"CT_CTYPE2 not supported.\n");
1308 return FALSE;
1309 case CT_CTYPE3:
1310 FIXME(ole,"CT_CTYPE3 not supported.\n");
1311 return FALSE;
1312 default:break;
1314 for (i=0;i<cchSrc;i++) {
1315 chartype[i] = 0;
1316 if (isdigit(src[i])) chartype[i]|=C1_DIGIT;
1317 if (isalpha(src[i])) chartype[i]|=C1_ALPHA;
1318 if (islower(src[i])) chartype[i]|=C1_LOWER;
1319 if (isupper(src[i])) chartype[i]|=C1_UPPER;
1320 if (isspace(src[i])) chartype[i]|=C1_SPACE;
1321 if (ispunct(src[i])) chartype[i]|=C1_PUNCT;
1322 if (iscntrl(src[i])) chartype[i]|=C1_CNTRL;
1323 /* FIXME: isblank() is a GNU extension */
1324 /* if (isblank(src[i])) chartype[i]|=C1_BLANK; */
1325 if ((src[i] == ' ') || (src[i] == '\t')) chartype[i]|=C1_BLANK;
1326 /* C1_XDIGIT */
1328 return TRUE;
1331 /*****************************************************************
1332 * VerLanguageName16 [VER.10]
1334 DWORD WINAPI VerLanguageName16(UINT16 langid,LPSTR langname,UINT16 langnamelen)
1336 int i;
1337 DWORD result;
1338 char buffer[80];
1340 TRACE(ver,"(%d,%p,%d)\n",langid,langname,langnamelen);
1341 /* First, check \System\CurrentControlSet\control\Nls\Locale\<langid>
1342 * from the registry.
1344 sprintf(buffer,
1345 "\\System\\CurrentControlSet\\control\\Nls\\Locale\\%08x",
1346 langid);
1347 result = RegQueryValue16(HKEY_LOCAL_MACHINE, buffer, langname,
1348 (LPDWORD)&langnamelen);
1349 if (result == ERROR_SUCCESS) {
1350 langname[langnamelen-1]='\0';
1351 return langnamelen;
1353 /* if that fails, use the internal table */
1354 for (i=0;languages[i].langid!=0;i++)
1355 if (langid==languages[i].langid)
1356 break;
1357 strncpy(langname,languages[i].langname,langnamelen);
1358 langname[langnamelen-1]='\0';
1359 return strlen(languages[i].langname);
1362 /*****************************************************************
1363 * VerLanguageName32A [VERSION.9]
1365 DWORD WINAPI VerLanguageName32A(UINT32 langid,LPSTR langname,
1366 UINT32 langnamelen)
1368 return VerLanguageName16(langid,langname,langnamelen);
1371 /*****************************************************************
1372 * VerLanguageName32W [VERSION.10]
1374 DWORD WINAPI VerLanguageName32W(UINT32 langid,LPWSTR langname,
1375 UINT32 langnamelen)
1377 int i;
1378 LPWSTR keyname;
1379 DWORD result;
1380 char buffer[80];
1382 /* First, check \System\CurrentControlSet\control\Nls\Locale\<langid>
1383 * from the registry.
1385 sprintf(buffer,
1386 "\\System\\CurrentControlSet\\control\\Nls\\Locale\\%08x",
1387 langid);
1388 keyname = HEAP_strdupAtoW( GetProcessHeap(), 0, buffer );
1389 result = RegQueryValue32W(HKEY_LOCAL_MACHINE, keyname, langname,
1390 (LPDWORD)&langnamelen);
1391 HeapFree( GetProcessHeap(), 0, keyname );
1392 if (result != ERROR_SUCCESS) {
1393 /* if that fails, use the internal table */
1394 for (i=0;languages[i].langid!=0;i++)
1395 if (langid==languages[i].langid)
1396 break;
1397 lstrcpyAtoW( langname, languages[i].langname );
1398 langnamelen = strlen(languages[i].langname);
1399 /* same as strlenW(langname); */
1401 return langnamelen;
1404 static const unsigned char LCM_Unicode_LUT[] = {
1405 6 , 3, /* - 1 */
1406 6 , 4, /* - 2 */
1407 6 , 5, /* - 3 */
1408 6 , 6, /* - 4 */
1409 6 , 7, /* - 5 */
1410 6 , 8, /* - 6 */
1411 6 , 9, /* - 7 */
1412 6 , 10, /* - 8 */
1413 7 , 5, /* - 9 */
1414 7 , 6, /* - 10 */
1415 7 , 7, /* - 11 */
1416 7 , 8, /* - 12 */
1417 7 , 9, /* - 13 */
1418 6 , 11, /* - 14 */
1419 6 , 12, /* - 15 */
1420 6 , 13, /* - 16 */
1421 6 , 14, /* - 17 */
1422 6 , 15, /* - 18 */
1423 6 , 16, /* - 19 */
1424 6 , 17, /* - 20 */
1425 6 , 18, /* - 21 */
1426 6 , 19, /* - 22 */
1427 6 , 20, /* - 23 */
1428 6 , 21, /* - 24 */
1429 6 , 22, /* - 25 */
1430 6 , 23, /* - 26 */
1431 6 , 24, /* - 27 */
1432 6 , 25, /* - 28 */
1433 6 , 26, /* - 29 */
1434 6 , 27, /* - 30 */
1435 6 , 28, /* - 31 */
1436 7 , 2, /* - 32 */
1437 7 , 28, /* ! - 33 */
1438 7 , 29, /* " - 34 */ /* " */
1439 7 , 31, /* # - 35 */
1440 7 , 33, /* $ - 36 */
1441 7 , 35, /* % - 37 */
1442 7 , 37, /* & - 38 */
1443 6 , 128, /* ' - 39 */
1444 7 , 39, /* ( - 40 */
1445 7 , 42, /* ) - 41 */
1446 7 , 45, /* * - 42 */
1447 8 , 3, /* + - 43 */
1448 7 , 47, /* , - 44 */
1449 6 , 130, /* - - 45 */
1450 7 , 51, /* . - 46 */
1451 7 , 53, /* / - 47 */
1452 12 , 3, /* 0 - 48 */
1453 12 , 33, /* 1 - 49 */
1454 12 , 51, /* 2 - 50 */
1455 12 , 70, /* 3 - 51 */
1456 12 , 88, /* 4 - 52 */
1457 12 , 106, /* 5 - 53 */
1458 12 , 125, /* 6 - 54 */
1459 12 , 144, /* 7 - 55 */
1460 12 , 162, /* 8 - 56 */
1461 12 , 180, /* 9 - 57 */
1462 7 , 55, /* : - 58 */
1463 7 , 58, /* ; - 59 */
1464 8 , 14, /* < - 60 */
1465 8 , 18, /* = - 61 */
1466 8 , 20, /* > - 62 */
1467 7 , 60, /* ? - 63 */
1468 7 , 62, /* @ - 64 */
1469 14 , 2, /* A - 65 */
1470 14 , 9, /* B - 66 */
1471 14 , 10, /* C - 67 */
1472 14 , 26, /* D - 68 */
1473 14 , 33, /* E - 69 */
1474 14 , 35, /* F - 70 */
1475 14 , 37, /* G - 71 */
1476 14 , 44, /* H - 72 */
1477 14 , 50, /* I - 73 */
1478 14 , 53, /* J - 74 */
1479 14 , 54, /* K - 75 */
1480 14 , 72, /* L - 76 */
1481 14 , 81, /* M - 77 */
1482 14 , 112, /* N - 78 */
1483 14 , 124, /* O - 79 */
1484 14 , 126, /* P - 80 */
1485 14 , 137, /* Q - 81 */
1486 14 , 138, /* R - 82 */
1487 14 , 145, /* S - 83 */
1488 14 , 153, /* T - 84 */
1489 14 , 159, /* U - 85 */
1490 14 , 162, /* V - 86 */
1491 14 , 164, /* W - 87 */
1492 14 , 166, /* X - 88 */
1493 14 , 167, /* Y - 89 */
1494 14 , 169, /* Z - 90 */
1495 7 , 63, /* [ - 91 */
1496 7 , 65, /* \ - 92 */
1497 7 , 66, /* ] - 93 */
1498 7 , 67, /* ^ - 94 */
1499 7 , 68, /* _ - 95 */
1500 7 , 72, /* ` - 96 */
1501 14 , 2, /* a - 97 */
1502 14 , 9, /* b - 98 */
1503 14 , 10, /* c - 99 */
1504 14 , 26, /* d - 100 */
1505 14 , 33, /* e - 101 */
1506 14 , 35, /* f - 102 */
1507 14 , 37, /* g - 103 */
1508 14 , 44, /* h - 104 */
1509 14 , 50, /* i - 105 */
1510 14 , 53, /* j - 106 */
1511 14 , 54, /* k - 107 */
1512 14 , 72, /* l - 108 */
1513 14 , 81, /* m - 109 */
1514 14 , 112, /* n - 110 */
1515 14 , 124, /* o - 111 */
1516 14 , 126, /* p - 112 */
1517 14 , 137, /* q - 113 */
1518 14 , 138, /* r - 114 */
1519 14 , 145, /* s - 115 */
1520 14 , 153, /* t - 116 */
1521 14 , 159, /* u - 117 */
1522 14 , 162, /* v - 118 */
1523 14 , 164, /* w - 119 */
1524 14 , 166, /* x - 120 */
1525 14 , 167, /* y - 121 */
1526 14 , 169, /* z - 122 */
1527 7 , 74, /* { - 123 */
1528 7 , 76, /* | - 124 */
1529 7 , 78, /* } - 125 */
1530 7 , 80, /* ~ - 126 */
1531 6 , 29, /* \x7f - 127 */
1532 6 , 30, /* € - 128 */
1533 6 , 31, /* � - 129 */
1534 7 , 123, /* ‚ - 130 */
1535 14 , 35, /* ƒ - 131 */
1536 7 , 127, /* „ - 132 */
1537 10 , 21, /* … - 133 */
1538 10 , 15, /* † - 134 */
1539 10 , 16, /* ‡ - 135 */
1540 7 , 67, /* ˆ - 136 */
1541 10 , 22, /* ‰ - 137 */
1542 14 , 145, /* Š - 138 */
1543 7 , 136, /* ‹ - 139 */
1544 14 + 16 , 124, /* Π- 140 */
1545 6 , 43, /* � - 141 */
1546 6 , 44, /* Ž - 142 */
1547 6 , 45, /* � - 143 */
1548 6 , 46, /* � - 144 */
1549 7 , 121, /* ‘ - 145 */
1550 7 , 122, /* ’ - 146 */
1551 7 , 125, /* “ - 147 */
1552 7 , 126, /* ” - 148 */
1553 10 , 17, /* • - 149 */
1554 6 , 137, /* – - 150 */
1555 6 , 139, /* — - 151 */
1556 7 , 93, /* ˜ - 152 */
1557 14 , 156, /* ™ - 153 */
1558 14 , 145, /* š - 154 */
1559 7 , 137, /* › - 155 */
1560 14 + 16 , 124, /* œ - 156 */
1561 6 , 59, /* � - 157 */
1562 6 , 60, /* ž - 158 */
1563 14 , 167, /* Ÿ - 159 */
1564 7 , 4, /*   - 160 */
1565 7 , 81, /* ¡ - 161 */
1566 10 , 2, /* ¢ - 162 */
1567 10 , 3, /* £ - 163 */
1568 10 , 4, /* ¤ - 164 */
1569 10 , 5, /* ¥ - 165 */
1570 7 , 82, /* ¦ - 166 */
1571 10 , 6, /* § - 167 */
1572 7 , 83, /* ¨ - 168 */
1573 10 , 7, /* © - 169 */
1574 14 , 2, /* ª - 170 */
1575 8 , 24, /* « - 171 */
1576 10 , 8, /* ¬ - 172 */
1577 6 , 131, /* ­ - 173 */
1578 10 , 9, /* ® - 174 */
1579 7 , 84, /* ¯ - 175 */
1580 10 , 10, /* ° - 176 */
1581 8 , 23, /* ± - 177 */
1582 12 , 51, /* ² - 178 */
1583 12 , 70, /* ³ - 179 */
1584 7 , 85, /* ´ - 180 */
1585 10 , 11, /* µ - 181 */
1586 10 , 12, /* ¶ - 182 */
1587 10 , 13, /* · - 183 */
1588 7 , 86, /* ¸ - 184 */
1589 12 , 33, /* ¹ - 185 */
1590 14 , 124, /* º - 186 */
1591 8 , 26, /* » - 187 */
1592 12 , 21, /* ¼ - 188 */
1593 12 , 25, /* ½ - 189 */
1594 12 , 29, /* ¾ - 190 */
1595 7 , 87, /* ¿ - 191 */
1596 14 , 2, /* À - 192 */
1597 14 , 2, /* Á - 193 */
1598 14 , 2, /* Â - 194 */
1599 14 , 2, /* Ã - 195 */
1600 14 , 2, /* Ä - 196 */
1601 14 , 2, /* Å - 197 */
1602 14 + 16 , 2, /* Æ - 198 */
1603 14 , 10, /* Ç - 199 */
1604 14 , 33, /* È - 200 */
1605 14 , 33, /* É - 201 */
1606 14 , 33, /* Ê - 202 */
1607 14 , 33, /* Ë - 203 */
1608 14 , 50, /* Ì - 204 */
1609 14 , 50, /* Í - 205 */
1610 14 , 50, /* Î - 206 */
1611 14 , 50, /* Ï - 207 */
1612 14 , 26, /* Ð - 208 */
1613 14 , 112, /* Ñ - 209 */
1614 14 , 124, /* Ò - 210 */
1615 14 , 124, /* Ó - 211 */
1616 14 , 124, /* Ô - 212 */
1617 14 , 124, /* Õ - 213 */
1618 14 , 124, /* Ö - 214 */
1619 8 , 28, /* × - 215 */
1620 14 , 124, /* Ø - 216 */
1621 14 , 159, /* Ù - 217 */
1622 14 , 159, /* Ú - 218 */
1623 14 , 159, /* Û - 219 */
1624 14 , 159, /* Ü - 220 */
1625 14 , 167, /* Ý - 221 */
1626 14 + 32 , 153, /* Þ - 222 */
1627 14 + 48 , 145, /* ß - 223 */
1628 14 , 2, /* à - 224 */
1629 14 , 2, /* á - 225 */
1630 14 , 2, /* â - 226 */
1631 14 , 2, /* ã - 227 */
1632 14 , 2, /* ä - 228 */
1633 14 , 2, /* å - 229 */
1634 14 + 16 , 2, /* æ - 230 */
1635 14 , 10, /* ç - 231 */
1636 14 , 33, /* è - 232 */
1637 14 , 33, /* é - 233 */
1638 14 , 33, /* ê - 234 */
1639 14 , 33, /* ë - 235 */
1640 14 , 50, /* ì - 236 */
1641 14 , 50, /* í - 237 */
1642 14 , 50, /* î - 238 */
1643 14 , 50, /* ï - 239 */
1644 14 , 26, /* ð - 240 */
1645 14 , 112, /* ñ - 241 */
1646 14 , 124, /* ò - 242 */
1647 14 , 124, /* ó - 243 */
1648 14 , 124, /* ô - 244 */
1649 14 , 124, /* õ - 245 */
1650 14 , 124, /* ö - 246 */
1651 8 , 29, /* ÷ - 247 */
1652 14 , 124, /* ø - 248 */
1653 14 , 159, /* ù - 249 */
1654 14 , 159, /* ú - 250 */
1655 14 , 159, /* û - 251 */
1656 14 , 159, /* ü - 252 */
1657 14 , 167, /* ý - 253 */
1658 14 + 32 , 153, /* þ - 254 */
1659 14 , 167 /* ÿ - 255 */ };
1661 static const unsigned char LCM_Unicode_LUT_2[] = { 33, 44, 145 };
1663 #define LCM_Diacritic_Start 131
1665 static const unsigned char LCM_Diacritic_LUT[] = {
1666 123, /* ƒ - 131 */
1667 2, /* „ - 132 */
1668 2, /* … - 133 */
1669 2, /* † - 134 */
1670 2, /* ‡ - 135 */
1671 3, /* ˆ - 136 */
1672 2, /* ‰ - 137 */
1673 20, /* Š - 138 */
1674 2, /* ‹ - 139 */
1675 2, /* Π- 140 */
1676 2, /* � - 141 */
1677 2, /* Ž - 142 */
1678 2, /* � - 143 */
1679 2, /* � - 144 */
1680 2, /* ‘ - 145 */
1681 2, /* ’ - 146 */
1682 2, /* “ - 147 */
1683 2, /* ” - 148 */
1684 2, /* • - 149 */
1685 2, /* – - 150 */
1686 2, /* — - 151 */
1687 2, /* ˜ - 152 */
1688 2, /* ™ - 153 */
1689 20, /* š - 154 */
1690 2, /* › - 155 */
1691 2, /* œ - 156 */
1692 2, /* � - 157 */
1693 2, /* ž - 158 */
1694 19, /* Ÿ - 159 */
1695 2, /*   - 160 */
1696 2, /* ¡ - 161 */
1697 2, /* ¢ - 162 */
1698 2, /* £ - 163 */
1699 2, /* ¤ - 164 */
1700 2, /* ¥ - 165 */
1701 2, /* ¦ - 166 */
1702 2, /* § - 167 */
1703 2, /* ¨ - 168 */
1704 2, /* © - 169 */
1705 3, /* ª - 170 */
1706 2, /* « - 171 */
1707 2, /* ¬ - 172 */
1708 2, /* ­ - 173 */
1709 2, /* ® - 174 */
1710 2, /* ¯ - 175 */
1711 2, /* ° - 176 */
1712 2, /* ± - 177 */
1713 2, /* ² - 178 */
1714 2, /* ³ - 179 */
1715 2, /* ´ - 180 */
1716 2, /* µ - 181 */
1717 2, /* ¶ - 182 */
1718 2, /* · - 183 */
1719 2, /* ¸ - 184 */
1720 2, /* ¹ - 185 */
1721 3, /* º - 186 */
1722 2, /* » - 187 */
1723 2, /* ¼ - 188 */
1724 2, /* ½ - 189 */
1725 2, /* ¾ - 190 */
1726 2, /* ¿ - 191 */
1727 15, /* À - 192 */
1728 14, /* Á - 193 */
1729 18, /* Â - 194 */
1730 25, /* Ã - 195 */
1731 19, /* Ä - 196 */
1732 26, /* Å - 197 */
1733 2, /* Æ - 198 */
1734 28, /* Ç - 199 */
1735 15, /* È - 200 */
1736 14, /* É - 201 */
1737 18, /* Ê - 202 */
1738 19, /* Ë - 203 */
1739 15, /* Ì - 204 */
1740 14, /* Í - 205 */
1741 18, /* Î - 206 */
1742 19, /* Ï - 207 */
1743 104, /* Ð - 208 */
1744 25, /* Ñ - 209 */
1745 15, /* Ò - 210 */
1746 14, /* Ó - 211 */
1747 18, /* Ô - 212 */
1748 25, /* Õ - 213 */
1749 19, /* Ö - 214 */
1750 2, /* × - 215 */
1751 33, /* Ø - 216 */
1752 15, /* Ù - 217 */
1753 14, /* Ú - 218 */
1754 18, /* Û - 219 */
1755 19, /* Ü - 220 */
1756 14, /* Ý - 221 */
1757 2, /* Þ - 222 */
1758 2, /* ß - 223 */
1759 15, /* à - 224 */
1760 14, /* á - 225 */
1761 18, /* â - 226 */
1762 25, /* ã - 227 */
1763 19, /* ä - 228 */
1764 26, /* å - 229 */
1765 2, /* æ - 230 */
1766 28, /* ç - 231 */
1767 15, /* è - 232 */
1768 14, /* é - 233 */
1769 18, /* ê - 234 */
1770 19, /* ë - 235 */
1771 15, /* ì - 236 */
1772 14, /* í - 237 */
1773 18, /* î - 238 */
1774 19, /* ï - 239 */
1775 104, /* ð - 240 */
1776 25, /* ñ - 241 */
1777 15, /* ò - 242 */
1778 14, /* ó - 243 */
1779 18, /* ô - 244 */
1780 25, /* õ - 245 */
1781 19, /* ö - 246 */
1782 2, /* ÷ - 247 */
1783 33, /* ø - 248 */
1784 15, /* ù - 249 */
1785 14, /* ú - 250 */
1786 18, /* û - 251 */
1787 19, /* ü - 252 */
1788 14, /* ý - 253 */
1789 2, /* þ - 254 */
1790 19, /* ÿ - 255 */
1793 /******************************************************************************
1794 * OLE2NLS_isPunctuation [INTERNAL]
1796 static int OLE2NLS_isPunctuation(unsigned char c)
1798 /* "punctuation character" in this context is a character which is
1799 considered "less important" during word sort comparison.
1800 See LCMapString implementation for the precise definition
1801 of "less important". */
1803 return (LCM_Unicode_LUT[-2+2*c]==6);
1806 /******************************************************************************
1807 * identity [Internal]
1809 static int identity(int c)
1811 return c;
1814 /*************************************************************************
1815 * LCMapString32A [KERNEL32.492]
1817 * Convert a string, or generate a sort key from it.
1819 * If (mapflags & LCMAP_SORTKEY), the function will generate
1820 * a sort key for the source string. Else, it will convert it
1821 * accordingly to the flags LCMAP_UPPERCASE, LCMAP_LOWERCASE,...
1823 * RETURNS
1824 * Error : 0.
1825 * Success : length of the result string.
1827 * NOTES
1828 * If called with scrlen = -1, the function will compute the length
1829 * of the 0-terminated string strsrc by itself.
1831 * If called with dstlen = 0, returns the buffer length that
1832 * would be required.
1834 * NORM_IGNOREWIDTH means to compare ASCII and Unicode characters
1835 * as if they are equal. Since Wine separates ASCII and Unicode into
1836 * separate functions, we shouldn't have to do anything for this flag.
1837 * I added it to the list of flags that don't need a fixme message
1838 * to make MS Word 95 not print several thousand fixme messages for
1839 * this function.
1841 INT32 WINAPI LCMapString32A(
1842 LCID lcid /* locale identifier created with MAKELCID;
1843 LOCALE_SYSTEM_DEFAULT and LOCALE_USER_DEFAULT are
1844 predefined values. */,
1845 DWORD mapflags /* flags */,
1846 LPCSTR srcstr /* source buffer */,
1847 INT32 srclen /* source length */,
1848 LPSTR dststr /* destination buffer */,
1849 INT32 dstlen /* destination buffer length */)
1851 int i;
1853 TRACE(string,"(0x%04lx,0x%08lx,%s,%d,%p,%d)\n",
1854 lcid,mapflags,srcstr,srclen,dststr,dstlen);
1856 if ( ((dstlen!=0) && (dststr==NULL)) || (srcstr==NULL) )
1858 ERR(ole, "(src=%s,dest=%s): Invalid NULL string\n", srcstr, dststr);
1859 SetLastError(ERROR_INVALID_PARAMETER);
1860 return 0;
1862 if (srclen == -1)
1863 srclen = lstrlen32A(srcstr) + 1 ; /* (include final '\0') */
1865 if (mapflags & ~ ( LCMAP_UPPERCASE | LCMAP_LOWERCASE | LCMAP_SORTKEY |
1866 NORM_IGNORECASE | NORM_IGNORENONSPACE | SORT_STRINGSORT |
1867 NORM_IGNOREWIDTH) )
1869 FIXME(string,"(0x%04lx,0x%08lx,%p,%d,%p,%d): "
1870 "unimplemented flags: 0x%08lx\n",
1871 lcid,mapflags,srcstr,srclen,dststr,dstlen,mapflags);
1874 if ( !(mapflags & LCMAP_SORTKEY) )
1876 int (*f)(int)=identity;
1878 if (dstlen==0)
1879 return srclen; /* dstlen=0 means "do nothing but return required length" */
1880 if (dstlen<srclen)
1881 srclen=dstlen; /* No, this case is not an error under Windows 95.
1882 And no '\0' gets written. */
1883 if (mapflags & LCMAP_UPPERCASE)
1884 f = toupper;
1885 else if (mapflags & LCMAP_LOWERCASE)
1886 f = tolower;
1887 for (i=0; i < srclen; i++)
1888 dststr[i] = (CHAR) f(srcstr[i]);
1889 return srclen;
1892 /* else ... (mapflags & LCMAP_SORTKEY) */
1894 int unicode_len=0;
1895 int case_len=0;
1896 int diacritic_len=0;
1897 int delayed_punctuation_len=0;
1898 char *case_component;
1899 char *diacritic_component;
1900 char *delayed_punctuation_component;
1901 int room,count;
1902 int flag_stringsort = mapflags & SORT_STRINGSORT;
1904 /* compute how much room we will need */
1905 for (i=0;i<srclen;i++)
1907 int ofs;
1908 unsigned char source_char = srcstr[i];
1909 if (source_char!='\0')
1911 if (flag_stringsort || !OLE2NLS_isPunctuation(source_char))
1913 unicode_len++;
1914 if ( LCM_Unicode_LUT[-2+2*source_char] & ~15 )
1915 unicode_len++; /* double letter */
1917 else
1919 delayed_punctuation_len++;
1923 if (isupper(source_char))
1924 case_len=unicode_len;
1926 ofs = source_char - LCM_Diacritic_Start;
1927 if ((ofs>=0) && (LCM_Diacritic_LUT[ofs]!=2))
1928 diacritic_len=unicode_len;
1931 if (mapflags & NORM_IGNORECASE)
1932 case_len=0;
1933 if (mapflags & NORM_IGNORENONSPACE)
1934 diacritic_len=0;
1936 room = 2 * unicode_len /* "unicode" component */
1937 + diacritic_len /* "diacritic" component */
1938 + case_len /* "case" component */
1939 + 4 * delayed_punctuation_len /* punctuation in word sort mode */
1940 + 4 /* four '\1' separators */
1941 + 1 ; /* terminal '\0' */
1942 if (dstlen==0)
1943 return room;
1944 else if (dstlen<room)
1946 SetLastError(ERROR_INSUFFICIENT_BUFFER);
1947 return 0;
1950 /*FIXME the Pointercheck should not be nessesary */
1951 if (IsBadWritePtr32 (dststr,room))
1952 { ERR (string,"bad destination buffer (dststr) : %p,%d\n",dststr,dstlen);
1953 SetLastError(ERROR_INSUFFICIENT_BUFFER);
1954 return 0;
1957 /* locate each component, write separators */
1958 diacritic_component = dststr + 2*unicode_len ;
1959 *diacritic_component++ = '\1';
1960 case_component = diacritic_component + diacritic_len ;
1961 *case_component++ = '\1';
1962 delayed_punctuation_component = case_component + case_len ;
1963 *delayed_punctuation_component++ = '\1';
1964 *delayed_punctuation_component++ = '\1';
1966 /* read source string char by char, write
1967 corresponding weight in each component. */
1968 for (i=0,count=0;i<srclen;i++)
1970 unsigned char source_char=srcstr[i];
1971 if (source_char!='\0')
1973 int type,longcode;
1974 type = LCM_Unicode_LUT[-2+2*source_char];
1975 longcode = type >> 4;
1976 type &= 15;
1977 if (!flag_stringsort && OLE2NLS_isPunctuation(source_char))
1979 UINT16 encrypted_location = (1<<15) + 7 + 4*count;
1980 *delayed_punctuation_component++ = (unsigned char) (encrypted_location>>8);
1981 *delayed_punctuation_component++ = (unsigned char) (encrypted_location&255);
1982 /* big-endian is used here because it lets string comparison be
1983 compatible with numerical comparison */
1985 *delayed_punctuation_component++ = type;
1986 *delayed_punctuation_component++ = LCM_Unicode_LUT[-1+2*source_char];
1987 /* assumption : a punctuation character is never a
1988 double or accented letter */
1990 else
1992 dststr[2*count] = type;
1993 dststr[2*count+1] = LCM_Unicode_LUT[-1+2*source_char];
1994 if (longcode)
1996 if (count<case_len)
1997 case_component[count] = ( isupper(source_char) ? 18 : 2 ) ;
1998 if (count<diacritic_len)
1999 diacritic_component[count] = 2; /* assumption: a double letter
2000 is never accented */
2001 count++;
2003 dststr[2*count] = type;
2004 dststr[2*count+1] = *(LCM_Unicode_LUT_2 - 1 + longcode);
2005 /* 16 in the first column of LCM_Unicode_LUT --> longcode = 1
2006 32 in the first column of LCM_Unicode_LUT --> longcode = 2
2007 48 in the first column of LCM_Unicode_LUT --> longcode = 3 */
2010 if (count<case_len)
2011 case_component[count] = ( isupper(source_char) ? 18 : 2 ) ;
2012 if (count<diacritic_len)
2014 int ofs = source_char - LCM_Diacritic_Start;
2015 diacritic_component[count] = (ofs>=0 ? LCM_Diacritic_LUT[ofs] : 2);
2017 count++;
2021 dststr[room-1] = '\0';
2022 return room;
2026 /*************************************************************************
2027 * LCMapString32W [KERNEL32.493]
2029 * Convert a string, or generate a sort key from it.
2031 * NOTE
2033 * See LCMapString32A for documentation
2035 INT32 WINAPI LCMapString32W(
2036 LCID lcid,DWORD mapflags,LPCWSTR srcstr,INT32 srclen,LPWSTR dststr,
2037 INT32 dstlen)
2039 int i;
2041 TRACE(string,"(0x%04lx,0x%08lx,%p,%d,%p,%d)\n",
2042 lcid,mapflags,srcstr,srclen,dststr,dstlen);
2044 if ( ((dstlen!=0) && (dststr==NULL)) || (srcstr==NULL) )
2046 ERR(ole, "(src=%p,dst=%p): Invalid NULL string\n", srcstr, dststr);
2047 SetLastError(ERROR_INVALID_PARAMETER);
2048 return 0;
2050 if (srclen==-1)
2051 srclen = lstrlen32W(srcstr)+1;
2052 if (mapflags & LCMAP_SORTKEY)
2054 FIXME(string,"(0x%04lx,0x%08lx,%p,%d,%p,%d): "
2055 "unimplemented flags: 0x%08lx\n",
2056 lcid,mapflags,srcstr,srclen,dststr,dstlen,mapflags);
2057 return 0;
2059 else
2061 int (*f)(int)=identity;
2063 if (dstlen==0)
2064 return srclen;
2065 if (dstlen<srclen)
2066 return 0;
2067 if (mapflags & LCMAP_UPPERCASE)
2068 f = toupper;
2069 else if (mapflags & LCMAP_LOWERCASE)
2070 f = tolower;
2071 for (i=0; i < srclen; i++)
2072 dststr[i] = (WCHAR) f(srcstr[i]);
2073 return srclen;
2077 /***********************************************************************
2078 * CompareString16 (OLE2NLS.8)
2080 UINT16 WINAPI CompareString16(DWORD lcid,DWORD fdwStyle,
2081 LPCSTR s1,DWORD l1,LPCSTR s2,DWORD l2)
2083 return (UINT16)CompareString32A(lcid,fdwStyle,s1,l1,s2,l2);
2086 /******************************************************************************
2087 * CompareString32A [KERNEL32.143]
2088 * Compares two strings using locale
2090 * RETURNS
2092 * success: CSTR_LESS_THAN, CSTR_EQUAL, CSTR_GREATER_THAN
2093 * failure: 0
2095 * NOTES
2097 * Defaults to a word sort, but uses a string sort if
2098 * SORT_STRINGSORT is set.
2099 * Calls SetLastError for ERROR_INVALID_FLAGS, ERROR_INVALID_PARAMETER.
2101 * BUGS
2103 * This implementation ignores the locale
2105 * FIXME
2107 * Quite inefficient.
2109 UINT32 WINAPI CompareString32A(
2110 DWORD lcid, /* locale ID */
2111 DWORD fdwStyle, /* comparison-style options */
2112 LPCSTR s1, /* first string */
2113 DWORD l1, /* length of first string */
2114 LPCSTR s2, /* second string */
2115 DWORD l2) /* length of second string */
2117 int mapstring_flags;
2118 int len1,len2;
2119 int result;
2120 LPSTR sk1,sk2;
2121 TRACE(ole,"%s and %s\n",
2122 debugstr_a (s1), debugstr_a (s2));
2124 if ( (s1==NULL) || (s2==NULL) )
2126 ERR(ole, "(s1=%s,s2=%s): Invalid NULL string\n", s1, s2);
2127 SetLastError(ERROR_INVALID_PARAMETER);
2128 return 0;
2131 if(fdwStyle & NORM_IGNORESYMBOLS)
2132 FIXME(ole, "IGNORESYMBOLS not supported\n");
2134 mapstring_flags = LCMAP_SORTKEY | fdwStyle ;
2135 len1 = LCMapString32A(lcid,mapstring_flags,s1,l1,NULL,0);
2136 len2 = LCMapString32A(lcid,mapstring_flags,s2,l2,NULL,0);
2138 if ((len1==0)||(len2==0))
2139 return 0; /* something wrong happened */
2141 sk1 = (LPSTR)HeapAlloc(GetProcessHeap(),0,len1);
2142 sk2 = (LPSTR)HeapAlloc(GetProcessHeap(),0,len2);
2143 if ( (!LCMapString32A(lcid,mapstring_flags,s1,l1,sk1,len1))
2144 || (!LCMapString32A(lcid,mapstring_flags,s2,l2,sk2,len2)) )
2146 ERR(ole,"Bug in LCmapString32A.\n");
2147 result = 0;
2149 else
2151 /* strcmp doesn't necessarily return -1, 0, or 1 */
2152 result = strcmp(sk1,sk2);
2154 HeapFree(GetProcessHeap(),0,sk1);
2155 HeapFree(GetProcessHeap(),0,sk2);
2157 if (result < 0)
2158 return 1;
2159 if (result == 0)
2160 return 2;
2162 /* must be greater, if we reach this point */
2163 return 3;
2166 /******************************************************************************
2167 * CompareString32W [KERNEL32.144]
2168 * This implementation ignores the locale
2169 * FIXME : Does only string sort. Should
2170 * be reimplemented the same way as CompareString32A.
2172 UINT32 WINAPI CompareString32W(DWORD lcid, DWORD fdwStyle,
2173 LPCWSTR s1, DWORD l1, LPCWSTR s2,DWORD l2)
2175 int len,ret;
2176 if(fdwStyle & NORM_IGNORENONSPACE)
2177 FIXME(ole,"IGNORENONSPACE not supprted\n");
2178 if(fdwStyle & NORM_IGNORESYMBOLS)
2179 FIXME(ole,"IGNORESYMBOLS not supported\n");
2181 /* Is strcmp defaulting to string sort or to word sort?? */
2182 /* FIXME: Handle NORM_STRINGSORT */
2183 l1 = (l1==-1)?lstrlen32W(s1):l1;
2184 l2 = (l2==-1)?lstrlen32W(s2):l2;
2185 len = l1<l2 ? l1:l2;
2186 ret = (fdwStyle & NORM_IGNORECASE) ?
2187 lstrncmpi32W(s1,s2,len) : lstrncmp32W(s1,s2,len);
2188 /* not equal, return 1 or 3 */
2189 if(ret!=0) return ret+2;
2190 /* same len, return 2 */
2191 if(l1==l2) return 2;
2192 /* the longer one is lexically greater */
2193 return (l1<l2)? 1 : 3;
2196 /******************************************************************************
2197 * OLE_GetFormatA [Internal]
2199 * FIXME
2200 * Why is it WINAPI if internal?
2202 This function implements stuff for GetDateFormat() and
2203 GetTimeFormat().
2205 d single-digit (no leading zero) day (of month)
2206 dd two-digit day (of month)
2207 ddd short day-of-week name
2208 dddd long day-of-week name
2209 M single-digit month
2210 MM two-digit month
2211 MMM short month name
2212 MMMM full month name
2213 y two-digit year, no leading 0
2214 yy two-digit year
2215 yyyy four-digit year
2216 gg era string
2217 h hours with no leading zero (12-hour)
2218 hh hours with full two digits
2219 H hours with no leading zero (24-hour)
2220 HH hours with full two digits
2221 m minutes with no leading zero
2222 mm minutes with full two digits
2223 s seconds with no leading zero
2224 ss seconds with full two digits
2225 t time marker (A or P)
2226 tt time marker (AM, PM)
2227 '' used to quote literal characters
2228 '' (within a quoted string) indicates a literal '
2230 These functions REQUIRE valid locale, date, and format.
2232 INT32 WINAPI OLE_GetFormatA(LCID locale,
2233 DWORD flags,
2234 DWORD tflags,
2235 LPSYSTEMTIME xtime,
2236 LPCSTR _format,
2237 LPSTR date, INT32 datelen)
2239 INT32 inpos, outpos;
2240 int count, type, inquote, Overflow;
2241 char buf[40];
2242 char format[40];
2243 char * pos;
2244 int buflen;
2246 const char * _dgfmt[] = { "%d", "%02d" };
2247 const char ** dgfmt = _dgfmt - 1;
2249 /* report, for debugging */
2250 TRACE(ole, "(0x%lx,0x%lx, 0x%lx, time(d=%d,h=%d,m=%d,s=%d), fmt:\'%s\' (at %p), %p (%s), len=%d)\n",
2251 locale, flags, tflags,
2252 xtime->wDay, xtime->wHour, xtime->wMinute, xtime->wSecond,
2253 format, format, date, date, datelen);
2255 /* initalize state variables and output buffer */
2256 inpos = outpos = 0;
2257 count = 0; inquote = 0; Overflow = 0;
2258 type = '\0';
2259 date[0] = buf[0] = '\0';
2261 strcpy(format,_format);
2263 /* alter the formatstring, while it works for all languages now in wine
2264 its possible that it fails when the time looks like ss:mm:hh as example*/
2265 if (tflags & (TIME_NOMINUTESORSECONDS))
2266 { if ((pos = strstr ( format, ":mm")))
2267 { memcpy ( pos, pos+3, strlen(format)-(pos-format)-2 );
2270 if (tflags & (TIME_NOSECONDS))
2271 { if ((pos = strstr ( format, ":ss")))
2272 { memcpy ( pos, pos+3, strlen(format)-(pos-format)-2 );
2276 for (inpos = 0;; inpos++) {
2277 /* 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]); */
2278 if (inquote) {
2279 if (format[inpos] == '\'') {
2280 if (format[inpos+1] == '\'') {
2281 inpos += 1;
2282 date[outpos++] = '\'';
2283 } else {
2284 inquote = 0;
2285 continue; /* we did nothing to the output */
2287 } else if (format[inpos] == '\0') {
2288 date[outpos++] = '\0';
2289 if (outpos > datelen) Overflow = 1;
2290 break;
2291 } else {
2292 date[outpos++] = format[inpos];
2293 if (outpos > datelen) {
2294 Overflow = 1;
2295 date[outpos-1] = '\0'; /* this is the last place where
2296 it's safe to write */
2297 break;
2300 } else if ( (count && (format[inpos] != type))
2301 || count == 4
2302 || (count == 2 && strchr("ghHmst", type)) )
2304 if (type == 'd') {
2305 if (count == 4) {
2306 GetLocaleInfo32A(locale,
2307 LOCALE_SDAYNAME1
2308 + xtime->wDayOfWeek - 1,
2309 buf, sizeof(buf));
2310 } else if (count == 3) {
2311 GetLocaleInfo32A(locale,
2312 LOCALE_SABBREVDAYNAME1
2313 + xtime->wDayOfWeek - 1,
2314 buf, sizeof(buf));
2315 } else {
2316 sprintf(buf, dgfmt[count], xtime->wDay);
2318 } else if (type == 'M') {
2319 if (count == 3) {
2320 GetLocaleInfo32A(locale,
2321 LOCALE_SABBREVMONTHNAME1
2322 + xtime->wMonth - 1,
2323 buf, sizeof(buf));
2324 } else if (count == 4) {
2325 GetLocaleInfo32A(locale,
2326 LOCALE_SMONTHNAME1
2327 + xtime->wMonth - 1,
2328 buf, sizeof(buf));
2329 } else {
2330 sprintf(buf, dgfmt[count], xtime->wMonth);
2332 } else if (type == 'y') {
2333 if (count == 4) {
2334 sprintf(buf, "%d", xtime->wYear);
2335 } else if (count == 3) {
2336 strcpy(buf, "yyy");
2337 WARN(ole, "unknown format, c=%c, n=%d\n", type, count);
2338 } else {
2339 sprintf(buf, dgfmt[count], xtime->wYear % 100);
2341 } else if (type == 'g') {
2342 if (count == 2) {
2343 FIXME(ole, "LOCALE_ICALENDARTYPE unimp.\n");
2344 strcpy(buf, "AD");
2345 } else {
2346 strcpy(buf, "g");
2347 WARN(ole, "unknown format, c=%c, n=%d\n", type, count);
2349 } else if (type == 'h') {
2350 /* gives us hours 1:00 -- 12:00 */
2351 sprintf(buf, dgfmt[count], (xtime->wHour-1)%12 +1);
2352 } else if (type == 'H') {
2353 /* 24-hour time */
2354 sprintf(buf, dgfmt[count], xtime->wHour);
2355 } else if ( type == 'm') {
2356 sprintf(buf, dgfmt[count], xtime->wMinute);
2357 } else if ( type == 's') {
2358 sprintf(buf, dgfmt[count], xtime->wSecond);
2359 } else if (type == 't') {
2360 if (count == 1) {
2361 sprintf(buf, "%c", (xtime->wHour < 12) ? 'A' : 'P');
2362 } else if (count == 2) {
2363 /* sprintf(buf, "%s", (xtime->wHour < 12) ? "AM" : "PM"); */
2364 GetLocaleInfo32A(locale,
2365 (xtime->wHour<12)
2366 ? LOCALE_S1159 : LOCALE_S2359,
2367 buf, sizeof(buf));
2371 /* we need to check the next char in the format string
2372 again, no matter what happened */
2373 inpos--;
2375 /* add the contents of buf to the output */
2376 buflen = strlen(buf);
2377 if (outpos + buflen < datelen) {
2378 date[outpos] = '\0'; /* for strcat to hook onto */
2379 strcat(date, buf);
2380 outpos += buflen;
2381 } else {
2382 date[outpos] = '\0';
2383 strncat(date, buf, datelen - outpos);
2384 date[datelen - 1] = '\0';
2385 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2386 WARN(ole, "insufficient buffer\n");
2387 return 0;
2390 /* reset the variables we used to keep track of this item */
2391 count = 0;
2392 type = '\0';
2393 } else if (format[inpos] == '\0') {
2394 /* we can't check for this at the loop-head, because
2395 that breaks the printing of the last format-item */
2396 date[outpos] = '\0';
2397 break;
2398 } else if (count) {
2399 /* continuing a code for an item */
2400 count +=1;
2401 continue;
2402 } else if (strchr("hHmstyMdg", format[inpos])) {
2403 type = format[inpos];
2404 count = 1;
2405 continue;
2406 } else if (format[inpos] == '\'') {
2407 inquote = 1;
2408 continue;
2409 } else {
2410 date[outpos++] = format[inpos];
2412 /* now deal with a possible buffer overflow */
2413 if (outpos >= datelen) {
2414 date[datelen - 1] = '\0';
2415 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2416 return 0;
2420 if (Overflow) {
2421 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2424 /* finish it off with a string terminator */
2425 outpos++;
2426 /* sanity check */
2427 if (outpos > datelen-1) outpos = datelen-1;
2428 date[outpos] = '\0';
2430 TRACE(ole, "OLE_GetFormatA returns string '%s', len %d\n",
2431 date, outpos);
2432 return outpos;
2435 /******************************************************************************
2436 * OLE_GetFormatW [INTERNAL]
2438 INT32 WINAPI OLE_GetFormatW(LCID locale, DWORD flags, DWORD tflags,
2439 LPSYSTEMTIME xtime,
2440 LPCWSTR format,
2441 LPWSTR output, INT32 outlen)
2443 INT32 inpos, outpos;
2444 int count, type=0, inquote;
2445 int Overflow; /* loop check */
2446 int usedate, usetime;
2447 WCHAR buf[40];
2448 int buflen=0;
2449 char abuf[40];
2450 WCHAR arg0[] = {0}, arg1[] = {'%','d',0};
2451 WCHAR arg2[] = {'%','0','2','d',0};
2452 WCHAR *argarr[] = {arg0, arg1, arg2};
2453 int datevars=0, timevars=0;
2455 /* make a debug report */
2456 lstrcpynWtoA(abuf, format, sizeof(format));
2457 TRACE(ole, "args: 0x%lx, 0x%lx, 0x%lx, time(d=%d,h=%d,m=%d,s=%d), fmt:\'%s\' (at %p), %p with max len %d\n",
2458 locale, flags, tflags,
2459 xtime->wDay, xtime->wHour, xtime->wMinute, xtime->wSecond,
2460 abuf, format, output, outlen);
2463 /* initialize state variables */
2464 inpos = outpos = 0;
2465 count = 0;
2466 inquote = Overflow = 0;
2467 /* this is really just a sanity check */
2468 output[0] = buf[0] = 0;
2469 abuf[0] = '\0';
2470 /* for compatibility with official Windows behavior */
2471 usedate = flags & DATE_DATEVARSONLY;
2472 usetime = flags & TIME_TIMEVARSONLY;
2474 /* this loop is the core of the function */
2475 for (inpos = 0; /* we have several break points */ ; inpos++) {
2476 if (inquote) {
2477 if (format[inpos] == (WCHAR) '\'') {
2478 if (format[inpos+1] == '\'') {
2479 inpos++;
2480 output[outpos++] = '\'';
2481 } else {
2482 inquote = 0;
2483 continue;
2485 } else if (format[inpos] == 0) {
2486 output[outpos++] = 0;
2487 if (outpos > outlen) Overflow = 1;
2488 break; /* normal exit (within a quote) */
2489 } else {
2490 output[outpos++] = format[inpos]; /* copy input */
2491 if (outpos > outlen) {
2492 Overflow = 1;
2493 output[outpos-1] = 0;
2494 break;
2497 } else if ( (count && (format[inpos] != type))
2498 || ( (count==4 && type =='y') ||
2499 (count==4 && type =='M') ||
2500 (count==4 && type =='d') ||
2501 (count==2 && type =='g') ||
2502 (count==2 && type =='h') ||
2503 (count==2 && type =='H') ||
2504 (count==2 && type =='m') ||
2505 (count==2 && type =='s') ||
2506 (count==2 && type =='t') ) ) {
2507 if (type == 'd') {
2508 if (count == 3) {
2509 GetLocaleInfo32W(locale,
2510 LOCALE_SDAYNAME1 + xtime->wDayOfWeek -1,
2511 buf, sizeof(buf)/sizeof(WCHAR) );
2512 } else if (count == 3) {
2513 GetLocaleInfo32W(locale,
2514 LOCALE_SABBREVDAYNAME1 +
2515 xtime->wDayOfWeek -1,
2516 buf, sizeof(buf)/sizeof(WCHAR) );
2517 } else {
2518 wsnprintf32W(buf, 5, argarr[count], xtime->wDay );
2520 } else if (type == 'M') {
2521 if (count == 4) {
2522 GetLocaleInfo32W(locale, LOCALE_SMONTHNAME1 +
2523 xtime->wMonth -1, buf,
2524 sizeof(buf)/sizeof(WCHAR) );
2525 } else if (count == 3) {
2526 GetLocaleInfo32W(locale, LOCALE_SABBREVMONTHNAME1 +
2527 xtime->wMonth -1, buf,
2528 sizeof(buf)/sizeof(WCHAR) );
2529 } else {
2530 wsnprintf32W(buf, 5, argarr[count], xtime->wMonth);
2532 } else if (type == 'y') {
2533 if (count == 4) {
2534 wsnprintf32W(buf, 6, argarr[1] /* "%d" */,
2535 xtime->wYear);
2536 } else if (count == 3) {
2537 lstrcpynAtoW(buf, "yyy", 5);
2538 } else {
2539 wsnprintf32W(buf, 6, argarr[count],
2540 xtime->wYear % 100);
2542 } else if (type == 'g') {
2543 if (count == 2) {
2544 FIXME(ole, "LOCALE_ICALENDARTYPE unimplemented\n");
2545 lstrcpynAtoW(buf, "AD", 5);
2546 } else {
2547 /* Win API sez we copy it verbatim */
2548 lstrcpynAtoW(buf, "g", 5);
2550 } else if (type == 'h') {
2551 /* hours 1:00-12:00 --- is this right? */
2552 wsnprintf32W(buf, 5, argarr[count],
2553 (xtime->wHour-1)%12 +1);
2554 } else if (type == 'H') {
2555 wsnprintf32W(buf, 5, argarr[count],
2556 xtime->wHour);
2557 } else if (type == 'm' ) {
2558 wsnprintf32W(buf, 5, argarr[count],
2559 xtime->wMinute);
2560 } else if (type == 's' ) {
2561 wsnprintf32W(buf, 5, argarr[count],
2562 xtime->wSecond);
2563 } else if (type == 't') {
2564 GetLocaleInfo32W(locale, (xtime->wHour < 12) ?
2565 LOCALE_S1159 : LOCALE_S2359,
2566 buf, sizeof(buf) );
2567 if (count == 1) {
2568 buf[1] = 0;
2572 /* no matter what happened, we need to check this next
2573 character the next time we loop through */
2574 inpos--;
2576 /* cat buf onto the output */
2577 outlen = lstrlen32W(buf);
2578 if (outpos + buflen < outlen) {
2579 output[outpos] = 0; /* a "hook" for strcat */
2580 lstrcat32W(output, buf);
2581 outpos += buflen;
2582 } else {
2583 output[outpos] = 0;
2584 lstrcatn32W(output, buf, outlen - outpos);
2585 output[outlen - 1] = 0;
2586 Overflow = 1;
2587 break; /* Abnormal exit */
2590 /* reset the variables we used this time */
2591 count = 0;
2592 type = '\0';
2593 } else if (format[inpos] == 0) {
2594 /* we can't check for this at the beginning, because that
2595 would keep us from printing a format spec that ended the
2596 string */
2597 output[outpos] = 0;
2598 break; /* NORMAL EXIT */
2599 } else if (count) {
2600 /* how we keep track of the middle of a format spec */
2601 count++;
2602 continue;
2603 } else if ( (datevars && (format[inpos]=='d' ||
2604 format[inpos]=='M' ||
2605 format[inpos]=='y' ||
2606 format[inpos]=='g') ) ||
2607 (timevars && (format[inpos]=='H' ||
2608 format[inpos]=='h' ||
2609 format[inpos]=='m' ||
2610 format[inpos]=='s' ||
2611 format[inpos]=='t') ) ) {
2612 type = format[inpos];
2613 count = 1;
2614 continue;
2615 } else if (format[inpos] == '\'') {
2616 inquote = 1;
2617 continue;
2618 } else {
2619 /* unquoted literals */
2620 output[outpos++] = format[inpos];
2624 if (Overflow) {
2625 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2626 WARN(ole, " buffer overflow\n");
2629 /* final string terminator and sanity check */
2630 outpos++;
2631 if (outpos > outlen-1) outpos = outlen-1;
2632 output[outpos] = '0';
2634 lstrcpynWtoA(abuf, output, sizeof(abuf) );
2635 TRACE(ole, " returning string \'%s\'\n", abuf);
2637 return (!Overflow) ? outlen : 0;
2642 /******************************************************************************
2643 * GetDateFormat32A [KERNEL32.310]
2644 * Makes an ASCII string of the date
2646 * This function uses format to format the date, or, if format
2647 * is NULL, uses the default for the locale. format is a string
2648 * of literal fields and characters as follows:
2650 * - d single-digit (no leading zero) day (of month)
2651 * - dd two-digit day (of month)
2652 * - ddd short day-of-week name
2653 * - dddd long day-of-week name
2654 * - M single-digit month
2655 * - MM two-digit month
2656 * - MMM short month name
2657 * - MMMM full month name
2658 * - y two-digit year, no leading 0
2659 * - yy two-digit year
2660 * - yyyy four-digit year
2661 * - gg era string
2664 INT32 WINAPI GetDateFormat32A(LCID locale,DWORD flags,
2665 LPSYSTEMTIME xtime,
2666 LPCSTR format, LPSTR date,INT32 datelen)
2669 char format_buf[40];
2670 LPCSTR thisformat;
2671 SYSTEMTIME t;
2672 LPSYSTEMTIME thistime;
2673 LCID thislocale;
2675 INT32 ret;
2677 TRACE(ole,"(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",
2678 locale,flags,xtime,format,date,datelen);
2680 if (!locale) {
2681 locale = LOCALE_SYSTEM_DEFAULT;
2684 if (locale == LOCALE_SYSTEM_DEFAULT) {
2685 thislocale = GetSystemDefaultLCID();
2686 } else if (locale == LOCALE_USER_DEFAULT) {
2687 thislocale = GetUserDefaultLCID();
2688 } else {
2689 thislocale = locale;
2692 if (xtime == NULL) {
2693 GetSystemTime(&t);
2694 thistime = &t;
2695 } else {
2696 thistime = xtime;
2699 if (format == NULL) {
2700 GetLocaleInfo32A(thislocale, ((flags&DATE_LONGDATE)
2701 ? LOCALE_SLONGDATE
2702 : LOCALE_SSHORTDATE),
2703 format_buf, sizeof(format_buf));
2704 thisformat = format_buf;
2705 } else {
2706 thisformat = format;
2710 ret = OLE_GetFormatA(thislocale, flags, 0, thistime, thisformat,
2711 date, datelen);
2714 TRACE(ole,
2715 "GetDateFormat32A() returning %d, with data=%s\n",
2716 ret, date);
2717 return ret;
2720 /******************************************************************************
2721 * GetDateFormat32W [KERNEL32.311]
2722 * Makes a Unicode string of the date
2724 * Acts the same as GetDateFormat32A(), except that it's Unicode.
2725 * Accepts & returns sizes as counts of Unicode characters.
2728 INT32 WINAPI GetDateFormat32W(LCID locale,DWORD flags,
2729 LPSYSTEMTIME xtime,
2730 LPCWSTR format,
2731 LPWSTR date, INT32 datelen)
2733 short datearr[] = {'1','9','9','4','-','1','-','1',0};
2735 FIXME(ole, "STUB (should call OLE_GetFormatW)\n");
2736 lstrcpyn32W(date, datearr, datelen);
2737 return ( datelen < 9) ? datelen : 9;
2742 /**************************************************************************
2743 * EnumDateFormats32A (KERNEL32.198)
2745 BOOL32 WINAPI EnumDateFormats32A(
2746 DATEFMT_ENUMPROC32A lpDateFmtEnumProc, LCID Locale, DWORD dwFlags)
2748 FIXME(ole, "Only US English supported\n");
2750 if(!lpDateFmtEnumProc)
2752 SetLastError(ERROR_INVALID_PARAMETER);
2753 return FALSE;
2756 switch(dwFlags)
2758 case DATE_SHORTDATE:
2759 if(!(*lpDateFmtEnumProc)("M/d/yy")) return TRUE;
2760 if(!(*lpDateFmtEnumProc)("M/d/yyyy")) return TRUE;
2761 if(!(*lpDateFmtEnumProc)("MM/dd/yy")) return TRUE;
2762 if(!(*lpDateFmtEnumProc)("MM/dd/yyyy")) return TRUE;
2763 if(!(*lpDateFmtEnumProc)("yy/MM/dd")) return TRUE;
2764 if(!(*lpDateFmtEnumProc)("dd-MMM-yy")) return TRUE;
2765 return TRUE;
2766 case DATE_LONGDATE:
2767 if(!(*lpDateFmtEnumProc)("dddd, MMMM dd, yyyy")) return TRUE;
2768 if(!(*lpDateFmtEnumProc)("MMMM dd, yyyy")) return TRUE;
2769 if(!(*lpDateFmtEnumProc)("dddd, dd MMMM, yyyy")) return TRUE;
2770 if(!(*lpDateFmtEnumProc)("dd MMMM, yyyy")) return TRUE;
2771 return TRUE;
2772 default:
2773 FIXME(ole, "Unknown date format (%ld)\n", dwFlags);
2774 SetLastError(ERROR_INVALID_PARAMETER);
2775 return FALSE;
2779 /**************************************************************************
2780 * EnumDateFormats32W (KERNEL32.199)
2782 BOOL32 WINAPI EnumDateFormats32W(
2783 DATEFMT_ENUMPROC32W lpDateFmtEnumProc, LCID Locale, DWORD dwFlags)
2785 FIXME(ole, "(%p, %ld, %ld): stub\n", lpDateFmtEnumProc, Locale, dwFlags);
2786 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
2787 return FALSE;
2790 /**************************************************************************
2791 * EnumTimeFormats32A (KERNEL32.210)
2793 BOOL32 WINAPI EnumTimeFormats32A(
2794 TIMEFMT_ENUMPROC32A lpTimeFmtEnumProc, LCID Locale, DWORD dwFlags)
2796 FIXME(ole, "Only US English supported\n");
2798 if(!lpTimeFmtEnumProc)
2800 SetLastError(ERROR_INVALID_PARAMETER);
2801 return FALSE;
2804 if(dwFlags)
2806 FIXME(ole, "Unknown time format (%ld)\n", dwFlags);
2809 if(!(*lpTimeFmtEnumProc)("h:mm:ss tt")) return TRUE;
2810 if(!(*lpTimeFmtEnumProc)("hh:mm:ss tt")) return TRUE;
2811 if(!(*lpTimeFmtEnumProc)("H:mm:ss")) return TRUE;
2812 if(!(*lpTimeFmtEnumProc)("HH:mm:ss")) return TRUE;
2814 return TRUE;
2817 /**************************************************************************
2818 * EnumTimeFormats32W (KERNEL32.211)
2820 BOOL32 WINAPI EnumTimeFormats32W(
2821 TIMEFMT_ENUMPROC32W lpTimeFmtEnumProc, LCID Locale, DWORD dwFlags)
2823 FIXME(ole, "(%p,%ld,%ld): stub", lpTimeFmtEnumProc, Locale, dwFlags);
2824 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
2825 return FALSE;
2828 /**************************************************************************
2829 * GetNumberFormat32A (KERNEL32.355)
2830 * NOTE: type of lpFormat should be CONST NUMBERFORMAT
2832 INT32 WINAPI GetNumberFormat32A(LCID locale, DWORD dwflags,
2833 LPCSTR lpvalue, char *lpFormat,
2834 LPSTR lpNumberStr, int cchNumber)
2836 int n;
2838 FIXME(file,"%s: stub, no reformating done\n",lpvalue);
2840 n = strlen(lpvalue);
2841 if (cchNumber) {
2842 strncpy(lpNumberStr,lpvalue,cchNumber);
2843 if (cchNumber <= n) {
2844 lpNumberStr[cchNumber-1] = 0;
2845 n = cchNumber-1;
2848 return n;
2853 /******************************************************************************
2854 * GetTimeFormat32A [KERNEL32.422]
2855 * Makes an ASCII string of the time
2857 * Formats date according to format, or locale default if format is
2858 * NULL. The format consists of literal characters and fields as follows:
2860 * h hours with no leading zero (12-hour)
2861 * hh hours with full two digits
2862 * H hours with no leading zero (24-hour)
2863 * HH hours with full two digits
2864 * m minutes with no leading zero
2865 * mm minutes with full two digits
2866 * s seconds with no leading zero
2867 * ss seconds with full two digits
2868 * t time marker (A or P)
2869 * tt time marker (AM, PM)
2872 INT32 WINAPI
2873 GetTimeFormat32A(LCID locale, /* in */
2874 DWORD flags, /* in */
2875 LPSYSTEMTIME xtime, /* in */
2876 LPCSTR format, /* in */
2877 LPSTR timestr, /* out */
2878 INT32 timelen /* in */)
2879 { char format_buf[40];
2880 LPCSTR thisformat;
2881 SYSTEMTIME t;
2882 LPSYSTEMTIME thistime;
2883 LCID thislocale=0;
2884 DWORD thisflags=LOCALE_STIMEFORMAT; /* standart timeformat */;
2886 TRACE(ole,"GetTimeFormat(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",locale,flags,xtime,format,timestr,timelen);
2888 if (!locale)
2889 { locale = LOCALE_SYSTEM_DEFAULT;
2892 if (locale == LOCALE_SYSTEM_DEFAULT)
2893 { thislocale = GetSystemDefaultLCID();
2895 else if (locale == LOCALE_USER_DEFAULT)
2896 { thislocale = GetUserDefaultLCID();
2898 else
2899 { thislocale = locale;
2902 if ( flags & (TIME_NOTIMEMARKER | TIME_FORCE24HOURFORMAT ))
2903 { FIXME(ole,"TIME_NOTIMEMARKER or TIME_FORCE24HOURFORMAT not implemented\n");
2905 flags &= (TIME_NOSECONDS | TIME_NOMINUTESORSECONDS); /* mask for OLE_GetFormatA*/
2907 if (format == NULL)
2908 { if (flags & LOCALE_NOUSEROVERRIDE) /*use system default*/
2909 { thislocale = GetSystemDefaultLCID();
2911 GetLocaleInfo32A(thislocale, thisflags, format_buf, sizeof(format_buf));
2912 thisformat = format_buf;
2914 else
2915 { thisformat = format;
2918 if (xtime == NULL) /* NULL means use the current local time*/
2919 { GetSystemTime(&t);
2920 thistime = &t;
2922 else
2923 { thistime = xtime;
2925 return OLE_GetFormatA(thislocale, thisflags, flags, thistime, thisformat, timestr, timelen);
2929 /******************************************************************************
2930 * GetTimeFormat32W [KERNEL32.423]
2931 * Makes a Unicode string of the time
2933 INT32 WINAPI
2934 GetTimeFormat32W(LCID locale,DWORD flags,
2935 LPSYSTEMTIME xtime,
2936 LPCWSTR format,
2937 LPWSTR timestr,INT32 timelen)
2939 char debugbuf[40];
2940 WCHAR buf[20];
2941 LPCWSTR realformat=0;
2942 SYSTEMTIME t;
2943 LPSYSTEMTIME realtime;
2944 WCHAR * fmt_buf = NULL;
2945 int fmt_buf_size = 0; /* units of WCHARs */
2946 INT32 retval;
2948 lstrcpynWtoA(debugbuf, format, (sizeof(buf))/2);
2949 TRACE(ole, "GetTimeFormatW len %d flags 0x%lX format >%s<\n",
2950 timelen, flags, debugbuf);
2952 /* Enforce the Windows behavior */
2953 flags |= ~LOCALE_TIMEDATEBOTH;
2954 flags |= TIME_TIMEVARSONLY;
2956 /* take care of the format or locale not being given */
2957 if (format) {
2958 realformat = format;
2959 } else if (locale) {
2960 /* allocate memory */
2961 retval = ERROR_INSUFFICIENT_BUFFER;
2962 fmt_buf = malloc((fmt_buf_size+=7) * sizeof(WCHAR));
2963 if (!fmt_buf)
2964 goto out_nomem;
2966 while(!GetLocaleInfo32W(locale, LOCALE_STIMEFORMAT,
2967 fmt_buf, fmt_buf_size)) {
2968 retval = ERROR_OUTOFMEMORY;
2969 fmt_buf = realloc(fmt_buf,
2970 (fmt_buf_size += 10) * sizeof(WCHAR));
2971 if (!fmt_buf)
2972 goto out_nomem;
2974 realformat = fmt_buf;
2975 } else {
2976 FIXME(ole, "caller gave no locale, no format; what should we do?\n");
2977 SetLastError(ERROR_BAD_FORMAT);
2979 if (!locale)
2980 locale = GetSystemDefaultLCID();
2982 realtime = xtime;
2983 if (!realtime) {
2984 realtime = &t;
2985 GetSystemTime(realtime);
2988 retval = OLE_GetFormatW(locale, flags, 0, realtime, realformat, timestr, timelen);
2989 if (fmt_buf)
2990 free(fmt_buf);
2991 return retval;
2993 out_nomem:
2994 SetLastError(retval);
2995 WARN(ole, "could not allocate %d chars of memory\n", fmt_buf_size);
2996 return 0;