Stub for GetNumberFormat32W.
[wine/multimedia.git] / ole / ole2nls.c
blobc5ae96d3e27cef441950659921f1240fccbbe3d7
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 & 0xff) == 0x00) /*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 LANG_BEGIN (LANG_SLOVAK, SUBLANG_DEFAULT) /*0x41b*/
539 #include "nls/sky.nls"
540 LANG_END
542 /*Insert other languages here*/
544 default:
545 found=0;
546 break;
547 } /* switch */
550 /* language not found, try without a sublanguage*/
551 if (i==1) lang=MAKELANGID( PRIMARYLANGID(lang), SUBLANG_DEFAULT);
553 /* mask the LC Value */
554 if (i==2) LCType &= 0xfff;
556 i++;
557 } while (!found && i<3);
559 if(!found)
560 { ERR(ole,"'%s' not supported for your language.\n", retString);
561 SetLastError(ERROR_INVALID_PARAMETER);
562 return 0;
564 /* if len=0 return only the length, don't touch the buffer*/
565 if (len)
566 lstrcpyn32A(buf,retString,len);
568 return strlen(retString)+1;
571 /******************************************************************************
572 * GetLocaleInfo32W [KERNEL32.343]
575 INT32 WINAPI GetLocaleInfo32W(LCID lcid,LCTYPE LCType,LPWSTR wbuf,INT32 len)
576 { WORD wlen;
577 LPSTR abuf;
579 if (len && (! wbuf) )
580 { SetLastError(ERROR_INSUFFICIENT_BUFFER);
581 return 0;
584 abuf = (LPSTR)HeapAlloc(GetProcessHeap(),0,len);
585 wlen = 2 * GetLocaleInfo32A(lcid, LCType, abuf, len);
587 if (wlen && len) /* if len=0 return only the length*/
588 lstrcpynAtoW(wbuf,abuf,len/2);
590 HeapFree(GetProcessHeap(),0,abuf);
591 return wlen;
594 /******************************************************************************
595 * SetLocaleInfoA [KERNEL32.656]
597 BOOL16 WINAPI SetLocaleInfoA(DWORD lcid, DWORD lctype, LPCSTR data)
599 FIXME(ole,"(%ld,%ld,%s): stub\n",lcid,lctype,data);
600 return TRUE;
603 /******************************************************************************
604 * IsValidLocale [KERNEL32.489]
606 BOOL32 WINAPI IsValidLocale(LCID lcid,DWORD flags)
608 /* we support ANY language. Well, at least say that...*/
609 return TRUE;
612 /******************************************************************************
613 * EnumSystemLocales32W [KERNEL32.209]
615 BOOL32 WINAPI EnumSystemLocales32W( LOCALE_ENUMPROC32W lpfnLocaleEnum,
616 DWORD flags )
618 int i;
619 BOOL32 ret;
620 WCHAR buffer[200];
621 HKEY xhkey;
623 TRACE(win32,"(%p,%08lx)\n",lpfnLocaleEnum,flags );
624 /* see if we can reuse the Win95 registry entries.... */
625 if (ERROR_SUCCESS==RegOpenKey32A(HKEY_LOCAL_MACHINE,"\\System\\CurrentControlSet\\control\\Nls\\Locale\\",&xhkey)) {
626 i=0;
627 while (1) {
628 if (ERROR_SUCCESS!=RegEnumKey32W(xhkey,i,buffer,sizeof(buffer)))
629 break;
630 if (!lpfnLocaleEnum(buffer))
631 break;
632 i++;
634 RegCloseKey(xhkey);
635 return TRUE;
638 i=0;
639 while (languages[i].langname!=NULL)
641 LPWSTR cp;
642 char xbuffer[10];
644 sprintf(xbuffer,"%08lx",(DWORD)languages[i].langid);
646 cp = HEAP_strdupAtoW( GetProcessHeap(), 0, xbuffer );
647 ret = lpfnLocaleEnum(cp);
648 HeapFree( GetProcessHeap(), 0, cp );
649 if (!ret) break;
650 i++;
652 return TRUE;
655 /******************************************************************************
656 * EnumSystemLocales32A [KERNEL32.208]
658 BOOL32 WINAPI EnumSystemLocales32A(LOCALE_ENUMPROC32A lpfnLocaleEnum,
659 DWORD flags)
661 int i;
662 CHAR buffer[200];
663 HKEY xhkey;
665 TRACE(win32,"(%p,%08lx)\n",
666 lpfnLocaleEnum,flags
668 if (ERROR_SUCCESS==RegOpenKey32A(HKEY_LOCAL_MACHINE,"\\System\\CurrentControlSet\\control\\Nls\\Locale\\",&xhkey)) {
669 i=0;
670 while (1) {
671 if (ERROR_SUCCESS!=RegEnumKey32A(xhkey,i,buffer,sizeof(buffer)))
672 break;
673 if (!lpfnLocaleEnum(buffer))
674 break;
675 i++;
677 RegCloseKey(xhkey);
678 return TRUE;
680 i=0;
681 while (languages[i].langname!=NULL) {
682 sprintf(buffer,"%08lx",(DWORD)languages[i].langid);
683 if (!lpfnLocaleEnum(buffer))
684 break;
685 i++;
687 return TRUE;
690 static const unsigned char CT_CType2_LUT[] = {
691 C2_NOTAPPLICABLE, /* - 0 */
692 C2_NOTAPPLICABLE, /* - 1 */
693 C2_NOTAPPLICABLE, /* - 2 */
694 C2_NOTAPPLICABLE, /* - 3 */
695 C2_NOTAPPLICABLE, /* - 4 */
696 C2_NOTAPPLICABLE, /* - 5 */
697 C2_NOTAPPLICABLE, /* - 6 */
698 C2_NOTAPPLICABLE, /* - 7 */
699 C2_NOTAPPLICABLE, /* - 8 */
700 C2_SEGMENTSEPARATOR, /* - 9 */
701 C2_NOTAPPLICABLE, /* - 10 */
702 C2_NOTAPPLICABLE, /* - 11 */
703 C2_NOTAPPLICABLE, /* - 12 */
704 C2_NOTAPPLICABLE, /* - 13 */
705 C2_NOTAPPLICABLE, /* - 14 */
706 C2_NOTAPPLICABLE, /* - 15 */
707 C2_NOTAPPLICABLE, /* - 16 */
708 C2_NOTAPPLICABLE, /* - 17 */
709 C2_NOTAPPLICABLE, /* - 18 */
710 C2_NOTAPPLICABLE, /* - 19 */
711 C2_NOTAPPLICABLE, /* - 20 */
712 C2_NOTAPPLICABLE, /* - 21 */
713 C2_NOTAPPLICABLE, /* - 22 */
714 C2_NOTAPPLICABLE, /* - 23 */
715 C2_NOTAPPLICABLE, /* - 24 */
716 C2_NOTAPPLICABLE, /* - 25 */
717 C2_NOTAPPLICABLE, /* - 26 */
718 C2_NOTAPPLICABLE, /* - 27 */
719 C2_NOTAPPLICABLE, /* - 28 */
720 C2_NOTAPPLICABLE, /* - 29 */
721 C2_NOTAPPLICABLE, /* - 30 */
722 C2_NOTAPPLICABLE, /* - 31 */
723 C2_WHITESPACE, /* - 32 */
724 C2_OTHERNEUTRAL, /* ! - 33 */
725 C2_OTHERNEUTRAL, /* " - 34 */ /* " */
726 C2_EUROPETERMINATOR, /* # - 35 */
727 C2_EUROPETERMINATOR, /* $ - 36 */
728 C2_EUROPETERMINATOR, /* % - 37 */
729 C2_LEFTTORIGHT, /* & - 38 */
730 C2_OTHERNEUTRAL, /* ' - 39 */
731 C2_OTHERNEUTRAL, /* ( - 40 */
732 C2_OTHERNEUTRAL, /* ) - 41 */
733 C2_OTHERNEUTRAL, /* * - 42 */
734 C2_EUROPETERMINATOR, /* + - 43 */
735 C2_COMMONSEPARATOR, /* , - 44 */
736 C2_EUROPETERMINATOR, /* - - 45 */
737 C2_EUROPESEPARATOR, /* . - 46 */
738 C2_EUROPESEPARATOR, /* / - 47 */
739 C2_EUROPENUMBER, /* 0 - 48 */
740 C2_EUROPENUMBER, /* 1 - 49 */
741 C2_EUROPENUMBER, /* 2 - 50 */
742 C2_EUROPENUMBER, /* 3 - 51 */
743 C2_EUROPENUMBER, /* 4 - 52 */
744 C2_EUROPENUMBER, /* 5 - 53 */
745 C2_EUROPENUMBER, /* 6 - 54 */
746 C2_EUROPENUMBER, /* 7 - 55 */
747 C2_EUROPENUMBER, /* 8 - 56 */
748 C2_EUROPENUMBER, /* 9 - 57 */
749 C2_COMMONSEPARATOR, /* : - 58 */
750 C2_OTHERNEUTRAL, /* ; - 59 */
751 C2_OTHERNEUTRAL, /* < - 60 */
752 C2_OTHERNEUTRAL, /* = - 61 */
753 C2_OTHERNEUTRAL, /* > - 62 */
754 C2_OTHERNEUTRAL, /* ? - 63 */
755 C2_LEFTTORIGHT, /* @ - 64 */
756 C2_LEFTTORIGHT, /* A - 65 */
757 C2_LEFTTORIGHT, /* B - 66 */
758 C2_LEFTTORIGHT, /* C - 67 */
759 C2_LEFTTORIGHT, /* D - 68 */
760 C2_LEFTTORIGHT, /* E - 69 */
761 C2_LEFTTORIGHT, /* F - 70 */
762 C2_LEFTTORIGHT, /* G - 71 */
763 C2_LEFTTORIGHT, /* H - 72 */
764 C2_LEFTTORIGHT, /* I - 73 */
765 C2_LEFTTORIGHT, /* J - 74 */
766 C2_LEFTTORIGHT, /* K - 75 */
767 C2_LEFTTORIGHT, /* L - 76 */
768 C2_LEFTTORIGHT, /* M - 77 */
769 C2_LEFTTORIGHT, /* N - 78 */
770 C2_LEFTTORIGHT, /* O - 79 */
771 C2_LEFTTORIGHT, /* P - 80 */
772 C2_LEFTTORIGHT, /* Q - 81 */
773 C2_LEFTTORIGHT, /* R - 82 */
774 C2_LEFTTORIGHT, /* S - 83 */
775 C2_LEFTTORIGHT, /* T - 84 */
776 C2_LEFTTORIGHT, /* U - 85 */
777 C2_LEFTTORIGHT, /* V - 86 */
778 C2_LEFTTORIGHT, /* W - 87 */
779 C2_LEFTTORIGHT, /* X - 88 */
780 C2_LEFTTORIGHT, /* Y - 89 */
781 C2_LEFTTORIGHT, /* Z - 90 */
782 C2_OTHERNEUTRAL, /* [ - 91 */
783 C2_OTHERNEUTRAL, /* \ - 92 */
784 C2_OTHERNEUTRAL, /* ] - 93 */
785 C2_OTHERNEUTRAL, /* ^ - 94 */
786 C2_OTHERNEUTRAL, /* _ - 95 */
787 C2_OTHERNEUTRAL, /* ` - 96 */
788 C2_LEFTTORIGHT, /* a - 97 */
789 C2_LEFTTORIGHT, /* b - 98 */
790 C2_LEFTTORIGHT, /* c - 99 */
791 C2_LEFTTORIGHT, /* d - 100 */
792 C2_LEFTTORIGHT, /* e - 101 */
793 C2_LEFTTORIGHT, /* f - 102 */
794 C2_LEFTTORIGHT, /* g - 103 */
795 C2_LEFTTORIGHT, /* h - 104 */
796 C2_LEFTTORIGHT, /* i - 105 */
797 C2_LEFTTORIGHT, /* j - 106 */
798 C2_LEFTTORIGHT, /* k - 107 */
799 C2_LEFTTORIGHT, /* l - 108 */
800 C2_LEFTTORIGHT, /* m - 109 */
801 C2_LEFTTORIGHT, /* n - 110 */
802 C2_LEFTTORIGHT, /* o - 111 */
803 C2_LEFTTORIGHT, /* p - 112 */
804 C2_LEFTTORIGHT, /* q - 113 */
805 C2_LEFTTORIGHT, /* r - 114 */
806 C2_LEFTTORIGHT, /* s - 115 */
807 C2_LEFTTORIGHT, /* t - 116 */
808 C2_LEFTTORIGHT, /* u - 117 */
809 C2_LEFTTORIGHT, /* v - 118 */
810 C2_LEFTTORIGHT, /* w - 119 */
811 C2_LEFTTORIGHT, /* x - 120 */
812 C2_LEFTTORIGHT, /* y - 121 */
813 C2_LEFTTORIGHT, /* z - 122 */
814 C2_OTHERNEUTRAL, /* { - 123 */
815 C2_OTHERNEUTRAL, /* | - 124 */
816 C2_OTHERNEUTRAL, /* } - 125 */
817 C2_OTHERNEUTRAL, /* ~ - 126 */
818 C2_NOTAPPLICABLE, /* \x7f - 127 */
819 C2_NOTAPPLICABLE, /* € - 128 */
820 C2_NOTAPPLICABLE, /* � - 129 */
821 C2_OTHERNEUTRAL, /* ‚ - 130 */
822 C2_LEFTTORIGHT, /* ƒ - 131 */
823 C2_OTHERNEUTRAL, /* „ - 132 */
824 C2_OTHERNEUTRAL, /* … - 133 */
825 C2_OTHERNEUTRAL, /* † - 134 */
826 C2_OTHERNEUTRAL, /* ‡ - 135 */
827 C2_LEFTTORIGHT, /* ˆ - 136 */
828 C2_EUROPETERMINATOR, /* ‰ - 137 */
829 C2_LEFTTORIGHT, /* Š - 138 */
830 C2_OTHERNEUTRAL, /* ‹ - 139 */
831 C2_LEFTTORIGHT, /* Π- 140 */
832 C2_NOTAPPLICABLE, /* � - 141 */
833 C2_NOTAPPLICABLE, /* Ž - 142 */
834 C2_NOTAPPLICABLE, /* � - 143 */
835 C2_NOTAPPLICABLE, /* � - 144 */
836 C2_OTHERNEUTRAL, /* ‘ - 145 */
837 C2_OTHERNEUTRAL, /* ’ - 146 */
838 C2_OTHERNEUTRAL, /* “ - 147 */
839 C2_OTHERNEUTRAL, /* ” - 148 */
840 C2_OTHERNEUTRAL, /* • - 149 */
841 C2_OTHERNEUTRAL, /* – - 150 */
842 C2_OTHERNEUTRAL, /* — - 151 */
843 C2_LEFTTORIGHT, /* ˜ - 152 */
844 C2_OTHERNEUTRAL, /* ™ - 153 */
845 C2_LEFTTORIGHT, /* š - 154 */
846 C2_OTHERNEUTRAL, /* › - 155 */
847 C2_LEFTTORIGHT, /* œ - 156 */
848 C2_NOTAPPLICABLE, /* � - 157 */
849 C2_NOTAPPLICABLE, /* ž - 158 */
850 C2_LEFTTORIGHT, /* Ÿ - 159 */
851 C2_WHITESPACE, /*   - 160 */
852 C2_OTHERNEUTRAL, /* ¡ - 161 */
853 C2_EUROPETERMINATOR, /* ¢ - 162 */
854 C2_EUROPETERMINATOR, /* £ - 163 */
855 C2_EUROPETERMINATOR, /* ¤ - 164 */
856 C2_EUROPETERMINATOR, /* ¥ - 165 */
857 C2_OTHERNEUTRAL, /* ¦ - 166 */
858 C2_OTHERNEUTRAL, /* § - 167 */
859 C2_OTHERNEUTRAL, /* ¨ - 168 */
860 C2_OTHERNEUTRAL, /* © - 169 */
861 C2_OTHERNEUTRAL, /* ª - 170 */
862 C2_OTHERNEUTRAL, /* « - 171 */
863 C2_OTHERNEUTRAL, /* ¬ - 172 */
864 C2_OTHERNEUTRAL, /* ­ - 173 */
865 C2_OTHERNEUTRAL, /* ® - 174 */
866 C2_OTHERNEUTRAL, /* ¯ - 175 */
867 C2_EUROPETERMINATOR, /* ° - 176 */
868 C2_EUROPETERMINATOR, /* ± - 177 */
869 C2_EUROPENUMBER, /* ² - 178 */
870 C2_EUROPENUMBER, /* ³ - 179 */
871 C2_OTHERNEUTRAL, /* ´ - 180 */
872 C2_OTHERNEUTRAL, /* µ - 181 */
873 C2_OTHERNEUTRAL, /* ¶ - 182 */
874 C2_OTHERNEUTRAL, /* · - 183 */
875 C2_OTHERNEUTRAL, /* ¸ - 184 */
876 C2_EUROPENUMBER, /* ¹ - 185 */
877 C2_OTHERNEUTRAL, /* º - 186 */
878 C2_OTHERNEUTRAL, /* » - 187 */
879 C2_OTHERNEUTRAL, /* ¼ - 188 */
880 C2_OTHERNEUTRAL, /* ½ - 189 */
881 C2_OTHERNEUTRAL, /* ¾ - 190 */
882 C2_OTHERNEUTRAL, /* ¿ - 191 */
883 C2_LEFTTORIGHT, /* À - 192 */
884 C2_LEFTTORIGHT, /* Á - 193 */
885 C2_LEFTTORIGHT, /* Â - 194 */
886 C2_LEFTTORIGHT, /* Ã - 195 */
887 C2_LEFTTORIGHT, /* Ä - 196 */
888 C2_LEFTTORIGHT, /* Å - 197 */
889 C2_LEFTTORIGHT, /* Æ - 198 */
890 C2_LEFTTORIGHT, /* Ç - 199 */
891 C2_LEFTTORIGHT, /* È - 200 */
892 C2_LEFTTORIGHT, /* É - 201 */
893 C2_LEFTTORIGHT, /* Ê - 202 */
894 C2_LEFTTORIGHT, /* Ë - 203 */
895 C2_LEFTTORIGHT, /* Ì - 204 */
896 C2_LEFTTORIGHT, /* Í - 205 */
897 C2_LEFTTORIGHT, /* Î - 206 */
898 C2_LEFTTORIGHT, /* Ï - 207 */
899 C2_LEFTTORIGHT, /* Ð - 208 */
900 C2_LEFTTORIGHT, /* Ñ - 209 */
901 C2_LEFTTORIGHT, /* Ò - 210 */
902 C2_LEFTTORIGHT, /* Ó - 211 */
903 C2_LEFTTORIGHT, /* Ô - 212 */
904 C2_LEFTTORIGHT, /* Õ - 213 */
905 C2_LEFTTORIGHT, /* Ö - 214 */
906 C2_OTHERNEUTRAL, /* × - 215 */
907 C2_LEFTTORIGHT, /* Ø - 216 */
908 C2_LEFTTORIGHT, /* Ù - 217 */
909 C2_LEFTTORIGHT, /* Ú - 218 */
910 C2_LEFTTORIGHT, /* Û - 219 */
911 C2_LEFTTORIGHT, /* Ü - 220 */
912 C2_LEFTTORIGHT, /* Ý - 221 */
913 C2_LEFTTORIGHT, /* Þ - 222 */
914 C2_LEFTTORIGHT, /* ß - 223 */
915 C2_LEFTTORIGHT, /* à - 224 */
916 C2_LEFTTORIGHT, /* á - 225 */
917 C2_LEFTTORIGHT, /* â - 226 */
918 C2_LEFTTORIGHT, /* ã - 227 */
919 C2_LEFTTORIGHT, /* ä - 228 */
920 C2_LEFTTORIGHT, /* å - 229 */
921 C2_LEFTTORIGHT, /* æ - 230 */
922 C2_LEFTTORIGHT, /* ç - 231 */
923 C2_LEFTTORIGHT, /* è - 232 */
924 C2_LEFTTORIGHT, /* é - 233 */
925 C2_LEFTTORIGHT, /* ê - 234 */
926 C2_LEFTTORIGHT, /* ë - 235 */
927 C2_LEFTTORIGHT, /* ì - 236 */
928 C2_LEFTTORIGHT, /* í - 237 */
929 C2_LEFTTORIGHT, /* î - 238 */
930 C2_LEFTTORIGHT, /* ï - 239 */
931 C2_LEFTTORIGHT, /* ð - 240 */
932 C2_LEFTTORIGHT, /* ñ - 241 */
933 C2_LEFTTORIGHT, /* ò - 242 */
934 C2_LEFTTORIGHT, /* ó - 243 */
935 C2_LEFTTORIGHT, /* ô - 244 */
936 C2_LEFTTORIGHT, /* õ - 245 */
937 C2_LEFTTORIGHT, /* ö - 246 */
938 C2_OTHERNEUTRAL, /* ÷ - 247 */
939 C2_LEFTTORIGHT, /* ø - 248 */
940 C2_LEFTTORIGHT, /* ù - 249 */
941 C2_LEFTTORIGHT, /* ú - 250 */
942 C2_LEFTTORIGHT, /* û - 251 */
943 C2_LEFTTORIGHT, /* ü - 252 */
944 C2_LEFTTORIGHT, /* ý - 253 */
945 C2_LEFTTORIGHT, /* þ - 254 */
946 C2_LEFTTORIGHT /* ÿ - 255 */
949 static const WORD CT_CType3_LUT[] = {
950 0x0000, /* - 0 */
951 0x0000, /* - 1 */
952 0x0000, /* - 2 */
953 0x0000, /* - 3 */
954 0x0000, /* - 4 */
955 0x0000, /* - 5 */
956 0x0000, /* - 6 */
957 0x0000, /* - 7 */
958 0x0000, /* - 8 */
959 0x0008, /* - 9 */
960 0x0008, /* - 10 */
961 0x0008, /* - 11 */
962 0x0008, /* - 12 */
963 0x0008, /* - 13 */
964 0x0000, /* - 14 */
965 0x0000, /* - 15 */
966 0x0000, /* - 16 */
967 0x0000, /* - 17 */
968 0x0000, /* - 18 */
969 0x0000, /* - 19 */
970 0x0000, /* - 20 */
971 0x0000, /* - 21 */
972 0x0000, /* - 22 */
973 0x0000, /* - 23 */
974 0x0000, /* - 24 */
975 0x0000, /* - 25 */
976 0x0000, /* - 26 */
977 0x0000, /* - 27 */
978 0x0000, /* - 28 */
979 0x0000, /* - 29 */
980 0x0000, /* - 30 */
981 0x0000, /* - 31 */
982 0x0048, /* - 32 */
983 0x0048, /* ! - 33 */
984 0x0448, /* " - 34 */ /* " */
985 0x0048, /* # - 35 */
986 0x0448, /* $ - 36 */
987 0x0048, /* % - 37 */
988 0x0048, /* & - 38 */
989 0x0440, /* ' - 39 */
990 0x0048, /* ( - 40 */
991 0x0048, /* ) - 41 */
992 0x0048, /* * - 42 */
993 0x0048, /* + - 43 */
994 0x0048, /* , - 44 */
995 0x0440, /* - - 45 */
996 0x0048, /* . - 46 */
997 0x0448, /* / - 47 */
998 0x0040, /* 0 - 48 */
999 0x0040, /* 1 - 49 */
1000 0x0040, /* 2 - 50 */
1001 0x0040, /* 3 - 51 */
1002 0x0040, /* 4 - 52 */
1003 0x0040, /* 5 - 53 */
1004 0x0040, /* 6 - 54 */
1005 0x0040, /* 7 - 55 */
1006 0x0040, /* 8 - 56 */
1007 0x0040, /* 9 - 57 */
1008 0x0048, /* : - 58 */
1009 0x0048, /* ; - 59 */
1010 0x0048, /* < - 60 */
1011 0x0448, /* = - 61 */
1012 0x0048, /* > - 62 */
1013 0x0048, /* ? - 63 */
1014 0x0448, /* @ - 64 */
1015 0x8040, /* A - 65 */
1016 0x8040, /* B - 66 */
1017 0x8040, /* C - 67 */
1018 0x8040, /* D - 68 */
1019 0x8040, /* E - 69 */
1020 0x8040, /* F - 70 */
1021 0x8040, /* G - 71 */
1022 0x8040, /* H - 72 */
1023 0x8040, /* I - 73 */
1024 0x8040, /* J - 74 */
1025 0x8040, /* K - 75 */
1026 0x8040, /* L - 76 */
1027 0x8040, /* M - 77 */
1028 0x8040, /* N - 78 */
1029 0x8040, /* O - 79 */
1030 0x8040, /* P - 80 */
1031 0x8040, /* Q - 81 */
1032 0x8040, /* R - 82 */
1033 0x8040, /* S - 83 */
1034 0x8040, /* T - 84 */
1035 0x8040, /* U - 85 */
1036 0x8040, /* V - 86 */
1037 0x8040, /* W - 87 */
1038 0x8040, /* X - 88 */
1039 0x8040, /* Y - 89 */
1040 0x8040, /* Z - 90 */
1041 0x0048, /* [ - 91 */
1042 0x0448, /* \ - 92 */
1043 0x0048, /* ] - 93 */
1044 0x0448, /* ^ - 94 */
1045 0x0448, /* _ - 95 */
1046 0x0448, /* ` - 96 */
1047 0x8040, /* a - 97 */
1048 0x8040, /* b - 98 */
1049 0x8040, /* c - 99 */
1050 0x8040, /* d - 100 */
1051 0x8040, /* e - 101 */
1052 0x8040, /* f - 102 */
1053 0x8040, /* g - 103 */
1054 0x8040, /* h - 104 */
1055 0x8040, /* i - 105 */
1056 0x8040, /* j - 106 */
1057 0x8040, /* k - 107 */
1058 0x8040, /* l - 108 */
1059 0x8040, /* m - 109 */
1060 0x8040, /* n - 110 */
1061 0x8040, /* o - 111 */
1062 0x8040, /* p - 112 */
1063 0x8040, /* q - 113 */
1064 0x8040, /* r - 114 */
1065 0x8040, /* s - 115 */
1066 0x8040, /* t - 116 */
1067 0x8040, /* u - 117 */
1068 0x8040, /* v - 118 */
1069 0x8040, /* w - 119 */
1070 0x8040, /* x - 120 */
1071 0x8040, /* y - 121 */
1072 0x8040, /* z - 122 */
1073 0x0048, /* { - 123 */
1074 0x0048, /* | - 124 */
1075 0x0048, /* } - 125 */
1076 0x0448, /* ~ - 126 */
1077 0x0000, /* \x7f - 127 */
1078 0x0000, /* € - 128 */
1079 0x0000, /* � - 129 */
1080 0x0008, /* ‚ - 130 */
1081 0x8000, /* ƒ - 131 */
1082 0x0008, /* „ - 132 */
1083 0x0008, /* … - 133 */
1084 0x0008, /* † - 134 */
1085 0x0008, /* ‡ - 135 */
1086 0x0001, /* ˆ - 136 */
1087 0x0008, /* ‰ - 137 */
1088 0x8003, /* Š - 138 */
1089 0x0008, /* ‹ - 139 */
1090 0x8000, /* Π- 140 */
1091 0x0000, /* � - 141 */
1092 0x0000, /* Ž - 142 */
1093 0x0000, /* � - 143 */
1094 0x0000, /* � - 144 */
1095 0x0088, /* ‘ - 145 */
1096 0x0088, /* ’ - 146 */
1097 0x0088, /* “ - 147 */
1098 0x0088, /* ” - 148 */
1099 0x0008, /* • - 149 */
1100 0x0400, /* – - 150 */
1101 0x0400, /* — - 151 */
1102 0x0408, /* ˜ - 152 */
1103 0x0000, /* ™ - 153 */
1104 0x8003, /* š - 154 */
1105 0x0008, /* › - 155 */
1106 0x8000, /* œ - 156 */
1107 0x0000, /* � - 157 */
1108 0x0000, /* ž - 158 */
1109 0x8003, /* Ÿ - 159 */
1110 0x0008, /*   - 160 */
1111 0x0008, /* ¡ - 161 */
1112 0x0048, /* ¢ - 162 */
1113 0x0048, /* £ - 163 */
1114 0x0008, /* ¤ - 164 */
1115 0x0048, /* ¥ - 165 */
1116 0x0048, /* ¦ - 166 */
1117 0x0008, /* § - 167 */
1118 0x0408, /* ¨ - 168 */
1119 0x0008, /* © - 169 */
1120 0x0400, /* ª - 170 */
1121 0x0008, /* « - 171 */
1122 0x0048, /* ¬ - 172 */
1123 0x0408, /* ­ - 173 */
1124 0x0008, /* ® - 174 */
1125 0x0448, /* ¯ - 175 */
1126 0x0008, /* ° - 176 */
1127 0x0008, /* ± - 177 */
1128 0x0000, /* ² - 178 */
1129 0x0000, /* ³ - 179 */
1130 0x0408, /* ´ - 180 */
1131 0x0008, /* µ - 181 */
1132 0x0008, /* ¶ - 182 */
1133 0x0008, /* · - 183 */
1134 0x0408, /* ¸ - 184 */
1135 0x0000, /* ¹ - 185 */
1136 0x0400, /* º - 186 */
1137 0x0008, /* » - 187 */
1138 0x0000, /* ¼ - 188 */
1139 0x0000, /* ½ - 189 */
1140 0x0000, /* ¾ - 190 */
1141 0x0008, /* ¿ - 191 */
1142 0x8003, /* À - 192 */
1143 0x8003, /* Á - 193 */
1144 0x8003, /* Â - 194 */
1145 0x8003, /* Ã - 195 */
1146 0x8003, /* Ä - 196 */
1147 0x8003, /* Å - 197 */
1148 0x8000, /* Æ - 198 */
1149 0x8003, /* Ç - 199 */
1150 0x8003, /* È - 200 */
1151 0x8003, /* É - 201 */
1152 0x8003, /* Ê - 202 */
1153 0x8003, /* Ë - 203 */
1154 0x8003, /* Ì - 204 */
1155 0x8003, /* Í - 205 */
1156 0x8003, /* Î - 206 */
1157 0x8003, /* Ï - 207 */
1158 0x8000, /* Ð - 208 */
1159 0x8003, /* Ñ - 209 */
1160 0x8003, /* Ò - 210 */
1161 0x8003, /* Ó - 211 */
1162 0x8003, /* Ô - 212 */
1163 0x8003, /* Õ - 213 */
1164 0x8003, /* Ö - 214 */
1165 0x0008, /* × - 215 */
1166 0x8003, /* Ø - 216 */
1167 0x8003, /* Ù - 217 */
1168 0x8003, /* Ú - 218 */
1169 0x8003, /* Û - 219 */
1170 0x8003, /* Ü - 220 */
1171 0x8003, /* Ý - 221 */
1172 0x8000, /* Þ - 222 */
1173 0x8000, /* ß - 223 */
1174 0x8003, /* à - 224 */
1175 0x8003, /* á - 225 */
1176 0x8003, /* â - 226 */
1177 0x8003, /* ã - 227 */
1178 0x8003, /* ä - 228 */
1179 0x8003, /* å - 229 */
1180 0x8000, /* æ - 230 */
1181 0x8003, /* ç - 231 */
1182 0x8003, /* è - 232 */
1183 0x8003, /* é - 233 */
1184 0x8003, /* ê - 234 */
1185 0x8003, /* ë - 235 */
1186 0x8003, /* ì - 236 */
1187 0x8003, /* í - 237 */
1188 0x8003, /* î - 238 */
1189 0x8003, /* ï - 239 */
1190 0x8000, /* ð - 240 */
1191 0x8003, /* ñ - 241 */
1192 0x8003, /* ò - 242 */
1193 0x8003, /* ó - 243 */
1194 0x8003, /* ô - 244 */
1195 0x8003, /* õ - 245 */
1196 0x8003, /* ö - 246 */
1197 0x0008, /* ÷ - 247 */
1198 0x8003, /* ø - 248 */
1199 0x8003, /* ù - 249 */
1200 0x8003, /* ú - 250 */
1201 0x8003, /* û - 251 */
1202 0x8003, /* ü - 252 */
1203 0x8003, /* ý - 253 */
1204 0x8000, /* þ - 254 */
1205 0x8003 /* ÿ - 255 */
1208 /******************************************************************************
1209 * GetStringType16 [OLE2NLS.7]
1211 BOOL16 WINAPI GetStringType16(LCID locale,DWORD dwInfoType,LPCSTR src,
1212 INT16 cchSrc,LPWORD chartype)
1214 return GetStringTypeEx32A(locale,dwInfoType,src,cchSrc,chartype);
1216 /******************************************************************************
1217 * GetStringType32A [KERNEL32.396]
1219 BOOL32 WINAPI GetStringType32A(LCID locale,DWORD dwInfoType,LPCSTR src,
1220 INT32 cchSrc,LPWORD chartype)
1222 return GetStringTypeEx32A(locale,dwInfoType,src,cchSrc,chartype);
1225 /******************************************************************************
1226 * GetStringTypeEx32A [KERNEL32.397]
1228 * FIXME: Ignores the locale.
1230 BOOL32 WINAPI GetStringTypeEx32A(LCID locale,DWORD dwInfoType,LPCSTR src,
1231 INT32 cchSrc,LPWORD chartype)
1233 int i;
1235 if ((src==NULL) || (chartype==NULL) || (src==(LPSTR)chartype))
1237 SetLastError(ERROR_INVALID_PARAMETER);
1238 return FALSE;
1241 if (cchSrc==-1)
1242 cchSrc=lstrlen32A(src)+1;
1244 switch (dwInfoType) {
1245 case CT_CTYPE1:
1246 for (i=0;i<cchSrc;i++)
1248 chartype[i] = 0;
1249 if (isdigit(src[i])) chartype[i]|=C1_DIGIT;
1250 if (isalpha(src[i])) chartype[i]|=C1_ALPHA;
1251 if (islower(src[i])) chartype[i]|=C1_LOWER;
1252 if (isupper(src[i])) chartype[i]|=C1_UPPER;
1253 if (isspace(src[i])) chartype[i]|=C1_SPACE;
1254 if (ispunct(src[i])) chartype[i]|=C1_PUNCT;
1255 if (iscntrl(src[i])) chartype[i]|=C1_CNTRL;
1256 /* FIXME: isblank() is a GNU extension */
1257 /* if (isblank(src[i])) chartype[i]|=C1_BLANK; */
1258 if ((src[i] == ' ') || (src[i] == '\t')) chartype[i]|=C1_BLANK;
1259 /* C1_XDIGIT */
1261 return TRUE;
1263 case CT_CTYPE2:
1264 for (i=0;i<cchSrc;i++)
1266 chartype[i]=(WORD)CT_CType2_LUT[i];
1268 return TRUE;
1270 case CT_CTYPE3:
1271 for (i=0;i<cchSrc;i++)
1273 chartype[i]=CT_CType3_LUT[i];
1275 return TRUE;
1277 default:
1278 ERR(ole,"Unknown dwInfoType:%ld\n",dwInfoType);
1279 return FALSE;
1283 /******************************************************************************
1284 * GetStringType32W [KERNEL32.399]
1286 * NOTES
1287 * Yes, this is missing LCID locale. MS fault.
1289 BOOL32 WINAPI GetStringType32W(DWORD dwInfoType,LPCWSTR src,INT32 cchSrc,
1290 LPWORD chartype)
1292 return GetStringTypeEx32W(0/*defaultlocale*/,dwInfoType,src,cchSrc,chartype);
1295 /******************************************************************************
1296 * GetStringTypeEx32W [KERNEL32.398]
1298 * FIXME: unicode chars are assumed chars
1300 BOOL32 WINAPI GetStringTypeEx32W(LCID locale,DWORD dwInfoType,LPCWSTR src,
1301 INT32 cchSrc,LPWORD chartype)
1303 int i;
1306 if (cchSrc==-1)
1307 cchSrc=lstrlen32W(src)+1;
1309 switch (dwInfoType) {
1310 case CT_CTYPE2:
1311 FIXME(ole,"CT_CTYPE2 not supported.\n");
1312 return FALSE;
1313 case CT_CTYPE3:
1314 FIXME(ole,"CT_CTYPE3 not supported.\n");
1315 return FALSE;
1316 default:break;
1318 for (i=0;i<cchSrc;i++) {
1319 chartype[i] = 0;
1320 if (isdigit(src[i])) chartype[i]|=C1_DIGIT;
1321 if (isalpha(src[i])) chartype[i]|=C1_ALPHA;
1322 if (islower(src[i])) chartype[i]|=C1_LOWER;
1323 if (isupper(src[i])) chartype[i]|=C1_UPPER;
1324 if (isspace(src[i])) chartype[i]|=C1_SPACE;
1325 if (ispunct(src[i])) chartype[i]|=C1_PUNCT;
1326 if (iscntrl(src[i])) chartype[i]|=C1_CNTRL;
1327 /* FIXME: isblank() is a GNU extension */
1328 /* if (isblank(src[i])) chartype[i]|=C1_BLANK; */
1329 if ((src[i] == ' ') || (src[i] == '\t')) chartype[i]|=C1_BLANK;
1330 /* C1_XDIGIT */
1332 return TRUE;
1335 /*****************************************************************
1336 * VerLanguageName16 [VER.10]
1338 DWORD WINAPI VerLanguageName16(UINT16 langid,LPSTR langname,UINT16 langnamelen)
1340 int i;
1341 DWORD result;
1342 char buffer[80];
1344 TRACE(ver,"(%d,%p,%d)\n",langid,langname,langnamelen);
1345 /* First, check \System\CurrentControlSet\control\Nls\Locale\<langid>
1346 * from the registry.
1348 sprintf(buffer,
1349 "\\System\\CurrentControlSet\\control\\Nls\\Locale\\%08x",
1350 langid);
1351 result = RegQueryValue16(HKEY_LOCAL_MACHINE, buffer, langname,
1352 (LPDWORD)&langnamelen);
1353 if (result == ERROR_SUCCESS) {
1354 langname[langnamelen-1]='\0';
1355 return langnamelen;
1357 /* if that fails, use the internal table */
1358 for (i=0;languages[i].langid!=0;i++)
1359 if (langid==languages[i].langid)
1360 break;
1361 strncpy(langname,languages[i].langname,langnamelen);
1362 langname[langnamelen-1]='\0';
1363 return strlen(languages[i].langname);
1366 /*****************************************************************
1367 * VerLanguageName32A [VERSION.9]
1369 DWORD WINAPI VerLanguageName32A(UINT32 langid,LPSTR langname,
1370 UINT32 langnamelen)
1372 return VerLanguageName16(langid,langname,langnamelen);
1375 /*****************************************************************
1376 * VerLanguageName32W [VERSION.10]
1378 DWORD WINAPI VerLanguageName32W(UINT32 langid,LPWSTR langname,
1379 UINT32 langnamelen)
1381 int i;
1382 LPWSTR keyname;
1383 DWORD result;
1384 char buffer[80];
1386 /* First, check \System\CurrentControlSet\control\Nls\Locale\<langid>
1387 * from the registry.
1389 sprintf(buffer,
1390 "\\System\\CurrentControlSet\\control\\Nls\\Locale\\%08x",
1391 langid);
1392 keyname = HEAP_strdupAtoW( GetProcessHeap(), 0, buffer );
1393 result = RegQueryValue32W(HKEY_LOCAL_MACHINE, keyname, langname,
1394 (LPDWORD)&langnamelen);
1395 HeapFree( GetProcessHeap(), 0, keyname );
1396 if (result != ERROR_SUCCESS) {
1397 /* if that fails, use the internal table */
1398 for (i=0;languages[i].langid!=0;i++)
1399 if (langid==languages[i].langid)
1400 break;
1401 lstrcpyAtoW( langname, languages[i].langname );
1402 langnamelen = strlen(languages[i].langname);
1403 /* same as strlenW(langname); */
1405 return langnamelen;
1408 static const unsigned char LCM_Unicode_LUT[] = {
1409 6 , 3, /* - 1 */
1410 6 , 4, /* - 2 */
1411 6 , 5, /* - 3 */
1412 6 , 6, /* - 4 */
1413 6 , 7, /* - 5 */
1414 6 , 8, /* - 6 */
1415 6 , 9, /* - 7 */
1416 6 , 10, /* - 8 */
1417 7 , 5, /* - 9 */
1418 7 , 6, /* - 10 */
1419 7 , 7, /* - 11 */
1420 7 , 8, /* - 12 */
1421 7 , 9, /* - 13 */
1422 6 , 11, /* - 14 */
1423 6 , 12, /* - 15 */
1424 6 , 13, /* - 16 */
1425 6 , 14, /* - 17 */
1426 6 , 15, /* - 18 */
1427 6 , 16, /* - 19 */
1428 6 , 17, /* - 20 */
1429 6 , 18, /* - 21 */
1430 6 , 19, /* - 22 */
1431 6 , 20, /* - 23 */
1432 6 , 21, /* - 24 */
1433 6 , 22, /* - 25 */
1434 6 , 23, /* - 26 */
1435 6 , 24, /* - 27 */
1436 6 , 25, /* - 28 */
1437 6 , 26, /* - 29 */
1438 6 , 27, /* - 30 */
1439 6 , 28, /* - 31 */
1440 7 , 2, /* - 32 */
1441 7 , 28, /* ! - 33 */
1442 7 , 29, /* " - 34 */ /* " */
1443 7 , 31, /* # - 35 */
1444 7 , 33, /* $ - 36 */
1445 7 , 35, /* % - 37 */
1446 7 , 37, /* & - 38 */
1447 6 , 128, /* ' - 39 */
1448 7 , 39, /* ( - 40 */
1449 7 , 42, /* ) - 41 */
1450 7 , 45, /* * - 42 */
1451 8 , 3, /* + - 43 */
1452 7 , 47, /* , - 44 */
1453 6 , 130, /* - - 45 */
1454 7 , 51, /* . - 46 */
1455 7 , 53, /* / - 47 */
1456 12 , 3, /* 0 - 48 */
1457 12 , 33, /* 1 - 49 */
1458 12 , 51, /* 2 - 50 */
1459 12 , 70, /* 3 - 51 */
1460 12 , 88, /* 4 - 52 */
1461 12 , 106, /* 5 - 53 */
1462 12 , 125, /* 6 - 54 */
1463 12 , 144, /* 7 - 55 */
1464 12 , 162, /* 8 - 56 */
1465 12 , 180, /* 9 - 57 */
1466 7 , 55, /* : - 58 */
1467 7 , 58, /* ; - 59 */
1468 8 , 14, /* < - 60 */
1469 8 , 18, /* = - 61 */
1470 8 , 20, /* > - 62 */
1471 7 , 60, /* ? - 63 */
1472 7 , 62, /* @ - 64 */
1473 14 , 2, /* A - 65 */
1474 14 , 9, /* B - 66 */
1475 14 , 10, /* C - 67 */
1476 14 , 26, /* D - 68 */
1477 14 , 33, /* E - 69 */
1478 14 , 35, /* F - 70 */
1479 14 , 37, /* G - 71 */
1480 14 , 44, /* H - 72 */
1481 14 , 50, /* I - 73 */
1482 14 , 53, /* J - 74 */
1483 14 , 54, /* K - 75 */
1484 14 , 72, /* L - 76 */
1485 14 , 81, /* M - 77 */
1486 14 , 112, /* N - 78 */
1487 14 , 124, /* O - 79 */
1488 14 , 126, /* P - 80 */
1489 14 , 137, /* Q - 81 */
1490 14 , 138, /* R - 82 */
1491 14 , 145, /* S - 83 */
1492 14 , 153, /* T - 84 */
1493 14 , 159, /* U - 85 */
1494 14 , 162, /* V - 86 */
1495 14 , 164, /* W - 87 */
1496 14 , 166, /* X - 88 */
1497 14 , 167, /* Y - 89 */
1498 14 , 169, /* Z - 90 */
1499 7 , 63, /* [ - 91 */
1500 7 , 65, /* \ - 92 */
1501 7 , 66, /* ] - 93 */
1502 7 , 67, /* ^ - 94 */
1503 7 , 68, /* _ - 95 */
1504 7 , 72, /* ` - 96 */
1505 14 , 2, /* a - 97 */
1506 14 , 9, /* b - 98 */
1507 14 , 10, /* c - 99 */
1508 14 , 26, /* d - 100 */
1509 14 , 33, /* e - 101 */
1510 14 , 35, /* f - 102 */
1511 14 , 37, /* g - 103 */
1512 14 , 44, /* h - 104 */
1513 14 , 50, /* i - 105 */
1514 14 , 53, /* j - 106 */
1515 14 , 54, /* k - 107 */
1516 14 , 72, /* l - 108 */
1517 14 , 81, /* m - 109 */
1518 14 , 112, /* n - 110 */
1519 14 , 124, /* o - 111 */
1520 14 , 126, /* p - 112 */
1521 14 , 137, /* q - 113 */
1522 14 , 138, /* r - 114 */
1523 14 , 145, /* s - 115 */
1524 14 , 153, /* t - 116 */
1525 14 , 159, /* u - 117 */
1526 14 , 162, /* v - 118 */
1527 14 , 164, /* w - 119 */
1528 14 , 166, /* x - 120 */
1529 14 , 167, /* y - 121 */
1530 14 , 169, /* z - 122 */
1531 7 , 74, /* { - 123 */
1532 7 , 76, /* | - 124 */
1533 7 , 78, /* } - 125 */
1534 7 , 80, /* ~ - 126 */
1535 6 , 29, /* \x7f - 127 */
1536 6 , 30, /* € - 128 */
1537 6 , 31, /* � - 129 */
1538 7 , 123, /* ‚ - 130 */
1539 14 , 35, /* ƒ - 131 */
1540 7 , 127, /* „ - 132 */
1541 10 , 21, /* … - 133 */
1542 10 , 15, /* † - 134 */
1543 10 , 16, /* ‡ - 135 */
1544 7 , 67, /* ˆ - 136 */
1545 10 , 22, /* ‰ - 137 */
1546 14 , 145, /* Š - 138 */
1547 7 , 136, /* ‹ - 139 */
1548 14 + 16 , 124, /* Π- 140 */
1549 6 , 43, /* � - 141 */
1550 6 , 44, /* Ž - 142 */
1551 6 , 45, /* � - 143 */
1552 6 , 46, /* � - 144 */
1553 7 , 121, /* ‘ - 145 */
1554 7 , 122, /* ’ - 146 */
1555 7 , 125, /* “ - 147 */
1556 7 , 126, /* ” - 148 */
1557 10 , 17, /* • - 149 */
1558 6 , 137, /* – - 150 */
1559 6 , 139, /* — - 151 */
1560 7 , 93, /* ˜ - 152 */
1561 14 , 156, /* ™ - 153 */
1562 14 , 145, /* š - 154 */
1563 7 , 137, /* › - 155 */
1564 14 + 16 , 124, /* œ - 156 */
1565 6 , 59, /* � - 157 */
1566 6 , 60, /* ž - 158 */
1567 14 , 167, /* Ÿ - 159 */
1568 7 , 4, /*   - 160 */
1569 7 , 81, /* ¡ - 161 */
1570 10 , 2, /* ¢ - 162 */
1571 10 , 3, /* £ - 163 */
1572 10 , 4, /* ¤ - 164 */
1573 10 , 5, /* ¥ - 165 */
1574 7 , 82, /* ¦ - 166 */
1575 10 , 6, /* § - 167 */
1576 7 , 83, /* ¨ - 168 */
1577 10 , 7, /* © - 169 */
1578 14 , 2, /* ª - 170 */
1579 8 , 24, /* « - 171 */
1580 10 , 8, /* ¬ - 172 */
1581 6 , 131, /* ­ - 173 */
1582 10 , 9, /* ® - 174 */
1583 7 , 84, /* ¯ - 175 */
1584 10 , 10, /* ° - 176 */
1585 8 , 23, /* ± - 177 */
1586 12 , 51, /* ² - 178 */
1587 12 , 70, /* ³ - 179 */
1588 7 , 85, /* ´ - 180 */
1589 10 , 11, /* µ - 181 */
1590 10 , 12, /* ¶ - 182 */
1591 10 , 13, /* · - 183 */
1592 7 , 86, /* ¸ - 184 */
1593 12 , 33, /* ¹ - 185 */
1594 14 , 124, /* º - 186 */
1595 8 , 26, /* » - 187 */
1596 12 , 21, /* ¼ - 188 */
1597 12 , 25, /* ½ - 189 */
1598 12 , 29, /* ¾ - 190 */
1599 7 , 87, /* ¿ - 191 */
1600 14 , 2, /* À - 192 */
1601 14 , 2, /* Á - 193 */
1602 14 , 2, /* Â - 194 */
1603 14 , 2, /* Ã - 195 */
1604 14 , 2, /* Ä - 196 */
1605 14 , 2, /* Å - 197 */
1606 14 + 16 , 2, /* Æ - 198 */
1607 14 , 10, /* Ç - 199 */
1608 14 , 33, /* È - 200 */
1609 14 , 33, /* É - 201 */
1610 14 , 33, /* Ê - 202 */
1611 14 , 33, /* Ë - 203 */
1612 14 , 50, /* Ì - 204 */
1613 14 , 50, /* Í - 205 */
1614 14 , 50, /* Î - 206 */
1615 14 , 50, /* Ï - 207 */
1616 14 , 26, /* Ð - 208 */
1617 14 , 112, /* Ñ - 209 */
1618 14 , 124, /* Ò - 210 */
1619 14 , 124, /* Ó - 211 */
1620 14 , 124, /* Ô - 212 */
1621 14 , 124, /* Õ - 213 */
1622 14 , 124, /* Ö - 214 */
1623 8 , 28, /* × - 215 */
1624 14 , 124, /* Ø - 216 */
1625 14 , 159, /* Ù - 217 */
1626 14 , 159, /* Ú - 218 */
1627 14 , 159, /* Û - 219 */
1628 14 , 159, /* Ü - 220 */
1629 14 , 167, /* Ý - 221 */
1630 14 + 32 , 153, /* Þ - 222 */
1631 14 + 48 , 145, /* ß - 223 */
1632 14 , 2, /* à - 224 */
1633 14 , 2, /* á - 225 */
1634 14 , 2, /* â - 226 */
1635 14 , 2, /* ã - 227 */
1636 14 , 2, /* ä - 228 */
1637 14 , 2, /* å - 229 */
1638 14 + 16 , 2, /* æ - 230 */
1639 14 , 10, /* ç - 231 */
1640 14 , 33, /* è - 232 */
1641 14 , 33, /* é - 233 */
1642 14 , 33, /* ê - 234 */
1643 14 , 33, /* ë - 235 */
1644 14 , 50, /* ì - 236 */
1645 14 , 50, /* í - 237 */
1646 14 , 50, /* î - 238 */
1647 14 , 50, /* ï - 239 */
1648 14 , 26, /* ð - 240 */
1649 14 , 112, /* ñ - 241 */
1650 14 , 124, /* ò - 242 */
1651 14 , 124, /* ó - 243 */
1652 14 , 124, /* ô - 244 */
1653 14 , 124, /* õ - 245 */
1654 14 , 124, /* ö - 246 */
1655 8 , 29, /* ÷ - 247 */
1656 14 , 124, /* ø - 248 */
1657 14 , 159, /* ù - 249 */
1658 14 , 159, /* ú - 250 */
1659 14 , 159, /* û - 251 */
1660 14 , 159, /* ü - 252 */
1661 14 , 167, /* ý - 253 */
1662 14 + 32 , 153, /* þ - 254 */
1663 14 , 167 /* ÿ - 255 */ };
1665 static const unsigned char LCM_Unicode_LUT_2[] = { 33, 44, 145 };
1667 #define LCM_Diacritic_Start 131
1669 static const unsigned char LCM_Diacritic_LUT[] = {
1670 123, /* ƒ - 131 */
1671 2, /* „ - 132 */
1672 2, /* … - 133 */
1673 2, /* † - 134 */
1674 2, /* ‡ - 135 */
1675 3, /* ˆ - 136 */
1676 2, /* ‰ - 137 */
1677 20, /* Š - 138 */
1678 2, /* ‹ - 139 */
1679 2, /* Π- 140 */
1680 2, /* � - 141 */
1681 2, /* Ž - 142 */
1682 2, /* � - 143 */
1683 2, /* � - 144 */
1684 2, /* ‘ - 145 */
1685 2, /* ’ - 146 */
1686 2, /* “ - 147 */
1687 2, /* ” - 148 */
1688 2, /* • - 149 */
1689 2, /* – - 150 */
1690 2, /* — - 151 */
1691 2, /* ˜ - 152 */
1692 2, /* ™ - 153 */
1693 20, /* š - 154 */
1694 2, /* › - 155 */
1695 2, /* œ - 156 */
1696 2, /* � - 157 */
1697 2, /* ž - 158 */
1698 19, /* Ÿ - 159 */
1699 2, /*   - 160 */
1700 2, /* ¡ - 161 */
1701 2, /* ¢ - 162 */
1702 2, /* £ - 163 */
1703 2, /* ¤ - 164 */
1704 2, /* ¥ - 165 */
1705 2, /* ¦ - 166 */
1706 2, /* § - 167 */
1707 2, /* ¨ - 168 */
1708 2, /* © - 169 */
1709 3, /* ª - 170 */
1710 2, /* « - 171 */
1711 2, /* ¬ - 172 */
1712 2, /* ­ - 173 */
1713 2, /* ® - 174 */
1714 2, /* ¯ - 175 */
1715 2, /* ° - 176 */
1716 2, /* ± - 177 */
1717 2, /* ² - 178 */
1718 2, /* ³ - 179 */
1719 2, /* ´ - 180 */
1720 2, /* µ - 181 */
1721 2, /* ¶ - 182 */
1722 2, /* · - 183 */
1723 2, /* ¸ - 184 */
1724 2, /* ¹ - 185 */
1725 3, /* º - 186 */
1726 2, /* » - 187 */
1727 2, /* ¼ - 188 */
1728 2, /* ½ - 189 */
1729 2, /* ¾ - 190 */
1730 2, /* ¿ - 191 */
1731 15, /* À - 192 */
1732 14, /* Á - 193 */
1733 18, /* Â - 194 */
1734 25, /* Ã - 195 */
1735 19, /* Ä - 196 */
1736 26, /* Å - 197 */
1737 2, /* Æ - 198 */
1738 28, /* Ç - 199 */
1739 15, /* È - 200 */
1740 14, /* É - 201 */
1741 18, /* Ê - 202 */
1742 19, /* Ë - 203 */
1743 15, /* Ì - 204 */
1744 14, /* Í - 205 */
1745 18, /* Î - 206 */
1746 19, /* Ï - 207 */
1747 104, /* Ð - 208 */
1748 25, /* Ñ - 209 */
1749 15, /* Ò - 210 */
1750 14, /* Ó - 211 */
1751 18, /* Ô - 212 */
1752 25, /* Õ - 213 */
1753 19, /* Ö - 214 */
1754 2, /* × - 215 */
1755 33, /* Ø - 216 */
1756 15, /* Ù - 217 */
1757 14, /* Ú - 218 */
1758 18, /* Û - 219 */
1759 19, /* Ü - 220 */
1760 14, /* Ý - 221 */
1761 2, /* Þ - 222 */
1762 2, /* ß - 223 */
1763 15, /* à - 224 */
1764 14, /* á - 225 */
1765 18, /* â - 226 */
1766 25, /* ã - 227 */
1767 19, /* ä - 228 */
1768 26, /* å - 229 */
1769 2, /* æ - 230 */
1770 28, /* ç - 231 */
1771 15, /* è - 232 */
1772 14, /* é - 233 */
1773 18, /* ê - 234 */
1774 19, /* ë - 235 */
1775 15, /* ì - 236 */
1776 14, /* í - 237 */
1777 18, /* î - 238 */
1778 19, /* ï - 239 */
1779 104, /* ð - 240 */
1780 25, /* ñ - 241 */
1781 15, /* ò - 242 */
1782 14, /* ó - 243 */
1783 18, /* ô - 244 */
1784 25, /* õ - 245 */
1785 19, /* ö - 246 */
1786 2, /* ÷ - 247 */
1787 33, /* ø - 248 */
1788 15, /* ù - 249 */
1789 14, /* ú - 250 */
1790 18, /* û - 251 */
1791 19, /* ü - 252 */
1792 14, /* ý - 253 */
1793 2, /* þ - 254 */
1794 19, /* ÿ - 255 */
1797 /******************************************************************************
1798 * OLE2NLS_isPunctuation [INTERNAL]
1800 static int OLE2NLS_isPunctuation(unsigned char c)
1802 /* "punctuation character" in this context is a character which is
1803 considered "less important" during word sort comparison.
1804 See LCMapString implementation for the precise definition
1805 of "less important". */
1807 return (LCM_Unicode_LUT[-2+2*c]==6);
1810 /******************************************************************************
1811 * identity [Internal]
1813 static int identity(int c)
1815 return c;
1818 /*************************************************************************
1819 * LCMapString32A [KERNEL32.492]
1821 * Convert a string, or generate a sort key from it.
1823 * If (mapflags & LCMAP_SORTKEY), the function will generate
1824 * a sort key for the source string. Else, it will convert it
1825 * accordingly to the flags LCMAP_UPPERCASE, LCMAP_LOWERCASE,...
1827 * RETURNS
1828 * Error : 0.
1829 * Success : length of the result string.
1831 * NOTES
1832 * If called with scrlen = -1, the function will compute the length
1833 * of the 0-terminated string strsrc by itself.
1835 * If called with dstlen = 0, returns the buffer length that
1836 * would be required.
1838 * NORM_IGNOREWIDTH means to compare ASCII and Unicode characters
1839 * as if they are equal. Since Wine separates ASCII and Unicode into
1840 * separate functions, we shouldn't have to do anything for this flag.
1841 * I added it to the list of flags that don't need a fixme message
1842 * to make MS Word 95 not print several thousand fixme messages for
1843 * this function.
1845 INT32 WINAPI LCMapString32A(
1846 LCID lcid /* locale identifier created with MAKELCID;
1847 LOCALE_SYSTEM_DEFAULT and LOCALE_USER_DEFAULT are
1848 predefined values. */,
1849 DWORD mapflags /* flags */,
1850 LPCSTR srcstr /* source buffer */,
1851 INT32 srclen /* source length */,
1852 LPSTR dststr /* destination buffer */,
1853 INT32 dstlen /* destination buffer length */)
1855 int i;
1857 TRACE(string,"(0x%04lx,0x%08lx,%s,%d,%p,%d)\n",
1858 lcid,mapflags,srcstr,srclen,dststr,dstlen);
1860 if ( ((dstlen!=0) && (dststr==NULL)) || (srcstr==NULL) )
1862 ERR(ole, "(src=%s,dest=%s): Invalid NULL string\n", srcstr, dststr);
1863 SetLastError(ERROR_INVALID_PARAMETER);
1864 return 0;
1866 if (srclen == -1)
1867 srclen = lstrlen32A(srcstr) + 1 ; /* (include final '\0') */
1869 if (mapflags & ~ ( LCMAP_UPPERCASE | LCMAP_LOWERCASE | LCMAP_SORTKEY |
1870 NORM_IGNORECASE | NORM_IGNORENONSPACE | SORT_STRINGSORT |
1871 NORM_IGNOREWIDTH) )
1873 FIXME(string,"(0x%04lx,0x%08lx,%p,%d,%p,%d): "
1874 "unimplemented flags: 0x%08lx\n",
1875 lcid,mapflags,srcstr,srclen,dststr,dstlen,mapflags);
1878 if ( !(mapflags & LCMAP_SORTKEY) )
1880 int (*f)(int)=identity;
1882 if (dstlen==0)
1883 return srclen; /* dstlen=0 means "do nothing but return required length" */
1884 if (dstlen<srclen)
1885 srclen=dstlen; /* No, this case is not an error under Windows 95.
1886 And no '\0' gets written. */
1887 if (mapflags & LCMAP_UPPERCASE)
1888 f = toupper;
1889 else if (mapflags & LCMAP_LOWERCASE)
1890 f = tolower;
1891 for (i=0; i < srclen; i++)
1892 dststr[i] = (CHAR) f(srcstr[i]);
1893 return srclen;
1896 /* else ... (mapflags & LCMAP_SORTKEY) */
1898 int unicode_len=0;
1899 int case_len=0;
1900 int diacritic_len=0;
1901 int delayed_punctuation_len=0;
1902 char *case_component;
1903 char *diacritic_component;
1904 char *delayed_punctuation_component;
1905 int room,count;
1906 int flag_stringsort = mapflags & SORT_STRINGSORT;
1908 /* compute how much room we will need */
1909 for (i=0;i<srclen;i++)
1911 int ofs;
1912 unsigned char source_char = srcstr[i];
1913 if (source_char!='\0')
1915 if (flag_stringsort || !OLE2NLS_isPunctuation(source_char))
1917 unicode_len++;
1918 if ( LCM_Unicode_LUT[-2+2*source_char] & ~15 )
1919 unicode_len++; /* double letter */
1921 else
1923 delayed_punctuation_len++;
1927 if (isupper(source_char))
1928 case_len=unicode_len;
1930 ofs = source_char - LCM_Diacritic_Start;
1931 if ((ofs>=0) && (LCM_Diacritic_LUT[ofs]!=2))
1932 diacritic_len=unicode_len;
1935 if (mapflags & NORM_IGNORECASE)
1936 case_len=0;
1937 if (mapflags & NORM_IGNORENONSPACE)
1938 diacritic_len=0;
1940 room = 2 * unicode_len /* "unicode" component */
1941 + diacritic_len /* "diacritic" component */
1942 + case_len /* "case" component */
1943 + 4 * delayed_punctuation_len /* punctuation in word sort mode */
1944 + 4 /* four '\1' separators */
1945 + 1 ; /* terminal '\0' */
1946 if (dstlen==0)
1947 return room;
1948 else if (dstlen<room)
1950 SetLastError(ERROR_INSUFFICIENT_BUFFER);
1951 return 0;
1954 /*FIXME the Pointercheck should not be nessesary */
1955 if (IsBadWritePtr32 (dststr,room))
1956 { ERR (string,"bad destination buffer (dststr) : %p,%d\n",dststr,dstlen);
1957 SetLastError(ERROR_INSUFFICIENT_BUFFER);
1958 return 0;
1961 /* locate each component, write separators */
1962 diacritic_component = dststr + 2*unicode_len ;
1963 *diacritic_component++ = '\1';
1964 case_component = diacritic_component + diacritic_len ;
1965 *case_component++ = '\1';
1966 delayed_punctuation_component = case_component + case_len ;
1967 *delayed_punctuation_component++ = '\1';
1968 *delayed_punctuation_component++ = '\1';
1970 /* read source string char by char, write
1971 corresponding weight in each component. */
1972 for (i=0,count=0;i<srclen;i++)
1974 unsigned char source_char=srcstr[i];
1975 if (source_char!='\0')
1977 int type,longcode;
1978 type = LCM_Unicode_LUT[-2+2*source_char];
1979 longcode = type >> 4;
1980 type &= 15;
1981 if (!flag_stringsort && OLE2NLS_isPunctuation(source_char))
1983 UINT16 encrypted_location = (1<<15) + 7 + 4*count;
1984 *delayed_punctuation_component++ = (unsigned char) (encrypted_location>>8);
1985 *delayed_punctuation_component++ = (unsigned char) (encrypted_location&255);
1986 /* big-endian is used here because it lets string comparison be
1987 compatible with numerical comparison */
1989 *delayed_punctuation_component++ = type;
1990 *delayed_punctuation_component++ = LCM_Unicode_LUT[-1+2*source_char];
1991 /* assumption : a punctuation character is never a
1992 double or accented letter */
1994 else
1996 dststr[2*count] = type;
1997 dststr[2*count+1] = LCM_Unicode_LUT[-1+2*source_char];
1998 if (longcode)
2000 if (count<case_len)
2001 case_component[count] = ( isupper(source_char) ? 18 : 2 ) ;
2002 if (count<diacritic_len)
2003 diacritic_component[count] = 2; /* assumption: a double letter
2004 is never accented */
2005 count++;
2007 dststr[2*count] = type;
2008 dststr[2*count+1] = *(LCM_Unicode_LUT_2 - 1 + longcode);
2009 /* 16 in the first column of LCM_Unicode_LUT --> longcode = 1
2010 32 in the first column of LCM_Unicode_LUT --> longcode = 2
2011 48 in the first column of LCM_Unicode_LUT --> longcode = 3 */
2014 if (count<case_len)
2015 case_component[count] = ( isupper(source_char) ? 18 : 2 ) ;
2016 if (count<diacritic_len)
2018 int ofs = source_char - LCM_Diacritic_Start;
2019 diacritic_component[count] = (ofs>=0 ? LCM_Diacritic_LUT[ofs] : 2);
2021 count++;
2025 dststr[room-1] = '\0';
2026 return room;
2030 /*************************************************************************
2031 * LCMapString32W [KERNEL32.493]
2033 * Convert a string, or generate a sort key from it.
2035 * NOTE
2037 * See LCMapString32A for documentation
2039 INT32 WINAPI LCMapString32W(
2040 LCID lcid,DWORD mapflags,LPCWSTR srcstr,INT32 srclen,LPWSTR dststr,
2041 INT32 dstlen)
2043 int i;
2045 TRACE(string,"(0x%04lx,0x%08lx,%p,%d,%p,%d)\n",
2046 lcid,mapflags,srcstr,srclen,dststr,dstlen);
2048 if ( ((dstlen!=0) && (dststr==NULL)) || (srcstr==NULL) )
2050 ERR(ole, "(src=%p,dst=%p): Invalid NULL string\n", srcstr, dststr);
2051 SetLastError(ERROR_INVALID_PARAMETER);
2052 return 0;
2054 if (srclen==-1)
2055 srclen = lstrlen32W(srcstr)+1;
2056 if (mapflags & LCMAP_SORTKEY)
2058 FIXME(string,"(0x%04lx,0x%08lx,%p,%d,%p,%d): "
2059 "unimplemented flags: 0x%08lx\n",
2060 lcid,mapflags,srcstr,srclen,dststr,dstlen,mapflags);
2061 return 0;
2063 else
2065 int (*f)(int)=identity;
2067 if (dstlen==0)
2068 return srclen;
2069 if (dstlen<srclen)
2070 return 0;
2071 if (mapflags & LCMAP_UPPERCASE)
2072 f = toupper;
2073 else if (mapflags & LCMAP_LOWERCASE)
2074 f = tolower;
2075 for (i=0; i < srclen; i++)
2076 dststr[i] = (WCHAR) f(srcstr[i]);
2077 return srclen;
2081 /***********************************************************************
2082 * CompareString16 (OLE2NLS.8)
2084 UINT16 WINAPI CompareString16(DWORD lcid,DWORD fdwStyle,
2085 LPCSTR s1,DWORD l1,LPCSTR s2,DWORD l2)
2087 return (UINT16)CompareString32A(lcid,fdwStyle,s1,l1,s2,l2);
2090 /******************************************************************************
2091 * CompareString32A [KERNEL32.143]
2092 * Compares two strings using locale
2094 * RETURNS
2096 * success: CSTR_LESS_THAN, CSTR_EQUAL, CSTR_GREATER_THAN
2097 * failure: 0
2099 * NOTES
2101 * Defaults to a word sort, but uses a string sort if
2102 * SORT_STRINGSORT is set.
2103 * Calls SetLastError for ERROR_INVALID_FLAGS, ERROR_INVALID_PARAMETER.
2105 * BUGS
2107 * This implementation ignores the locale
2109 * FIXME
2111 * Quite inefficient.
2113 UINT32 WINAPI CompareString32A(
2114 DWORD lcid, /* locale ID */
2115 DWORD fdwStyle, /* comparison-style options */
2116 LPCSTR s1, /* first string */
2117 DWORD l1, /* length of first string */
2118 LPCSTR s2, /* second string */
2119 DWORD l2) /* length of second string */
2121 int mapstring_flags;
2122 int len1,len2;
2123 int result;
2124 LPSTR sk1,sk2;
2125 TRACE(ole,"%s and %s\n",
2126 debugstr_a (s1), debugstr_a (s2));
2128 if ( (s1==NULL) || (s2==NULL) )
2130 ERR(ole, "(s1=%s,s2=%s): Invalid NULL string\n", s1, s2);
2131 SetLastError(ERROR_INVALID_PARAMETER);
2132 return 0;
2135 if(fdwStyle & NORM_IGNORESYMBOLS)
2136 FIXME(ole, "IGNORESYMBOLS not supported\n");
2138 mapstring_flags = LCMAP_SORTKEY | fdwStyle ;
2139 len1 = LCMapString32A(lcid,mapstring_flags,s1,l1,NULL,0);
2140 len2 = LCMapString32A(lcid,mapstring_flags,s2,l2,NULL,0);
2142 if ((len1==0)||(len2==0))
2143 return 0; /* something wrong happened */
2145 sk1 = (LPSTR)HeapAlloc(GetProcessHeap(),0,len1);
2146 sk2 = (LPSTR)HeapAlloc(GetProcessHeap(),0,len2);
2147 if ( (!LCMapString32A(lcid,mapstring_flags,s1,l1,sk1,len1))
2148 || (!LCMapString32A(lcid,mapstring_flags,s2,l2,sk2,len2)) )
2150 ERR(ole,"Bug in LCmapString32A.\n");
2151 result = 0;
2153 else
2155 /* strcmp doesn't necessarily return -1, 0, or 1 */
2156 result = strcmp(sk1,sk2);
2158 HeapFree(GetProcessHeap(),0,sk1);
2159 HeapFree(GetProcessHeap(),0,sk2);
2161 if (result < 0)
2162 return 1;
2163 if (result == 0)
2164 return 2;
2166 /* must be greater, if we reach this point */
2167 return 3;
2170 /******************************************************************************
2171 * CompareString32W [KERNEL32.144]
2172 * This implementation ignores the locale
2173 * FIXME : Does only string sort. Should
2174 * be reimplemented the same way as CompareString32A.
2176 UINT32 WINAPI CompareString32W(DWORD lcid, DWORD fdwStyle,
2177 LPCWSTR s1, DWORD l1, LPCWSTR s2,DWORD l2)
2179 int len,ret;
2180 if(fdwStyle & NORM_IGNORENONSPACE)
2181 FIXME(ole,"IGNORENONSPACE not supprted\n");
2182 if(fdwStyle & NORM_IGNORESYMBOLS)
2183 FIXME(ole,"IGNORESYMBOLS not supported\n");
2185 /* Is strcmp defaulting to string sort or to word sort?? */
2186 /* FIXME: Handle NORM_STRINGSORT */
2187 l1 = (l1==-1)?lstrlen32W(s1):l1;
2188 l2 = (l2==-1)?lstrlen32W(s2):l2;
2189 len = l1<l2 ? l1:l2;
2190 ret = (fdwStyle & NORM_IGNORECASE) ?
2191 lstrncmpi32W(s1,s2,len) : lstrncmp32W(s1,s2,len);
2192 /* not equal, return 1 or 3 */
2193 if(ret!=0) return ret+2;
2194 /* same len, return 2 */
2195 if(l1==l2) return 2;
2196 /* the longer one is lexically greater */
2197 return (l1<l2)? 1 : 3;
2200 /******************************************************************************
2201 * OLE_GetFormatA [Internal]
2203 * FIXME
2204 * Why is it WINAPI if internal?
2206 This function implements stuff for GetDateFormat() and
2207 GetTimeFormat().
2209 d single-digit (no leading zero) day (of month)
2210 dd two-digit day (of month)
2211 ddd short day-of-week name
2212 dddd long day-of-week name
2213 M single-digit month
2214 MM two-digit month
2215 MMM short month name
2216 MMMM full month name
2217 y two-digit year, no leading 0
2218 yy two-digit year
2219 yyyy four-digit year
2220 gg era string
2221 h hours with no leading zero (12-hour)
2222 hh hours with full two digits
2223 H hours with no leading zero (24-hour)
2224 HH hours with full two digits
2225 m minutes with no leading zero
2226 mm minutes with full two digits
2227 s seconds with no leading zero
2228 ss seconds with full two digits
2229 t time marker (A or P)
2230 tt time marker (AM, PM)
2231 '' used to quote literal characters
2232 '' (within a quoted string) indicates a literal '
2234 These functions REQUIRE valid locale, date, and format.
2236 INT32 WINAPI OLE_GetFormatA(LCID locale,
2237 DWORD flags,
2238 DWORD tflags,
2239 LPSYSTEMTIME xtime,
2240 LPCSTR _format, /*in*/
2241 LPSTR date, /*out*/
2242 INT32 datelen)
2244 INT32 inpos, outpos;
2245 int count, type, inquote, Overflow;
2246 char buf[40];
2247 char format[40];
2248 char * pos;
2249 int buflen;
2251 const char * _dgfmt[] = { "%d", "%02d" };
2252 const char ** dgfmt = _dgfmt - 1;
2254 /* report, for debugging */
2255 TRACE(ole, "(0x%lx,0x%lx, 0x%lx, time(d=%d,h=%d,m=%d,s=%d), fmt=%p \'%s\' , %p, len=%d)\n",
2256 locale, flags, tflags,
2257 xtime->wDay, xtime->wHour, xtime->wMinute, xtime->wSecond,
2258 _format, _format, date, datelen);
2260 /* initalize state variables and output buffer */
2261 inpos = outpos = 0;
2262 count = 0; inquote = 0; Overflow = 0;
2263 type = '\0';
2264 date[0] = buf[0] = '\0';
2266 strcpy(format,_format);
2268 /* alter the formatstring, while it works for all languages now in wine
2269 its possible that it fails when the time looks like ss:mm:hh as example*/
2270 if (tflags & (TIME_NOMINUTESORSECONDS))
2271 { if ((pos = strstr ( format, ":mm")))
2272 { memcpy ( pos, pos+3, strlen(format)-(pos-format)-2 );
2275 if (tflags & (TIME_NOSECONDS))
2276 { if ((pos = strstr ( format, ":ss")))
2277 { memcpy ( pos, pos+3, strlen(format)-(pos-format)-2 );
2281 for (inpos = 0;; inpos++) {
2282 /* 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]); */
2283 if (inquote) {
2284 if (format[inpos] == '\'') {
2285 if (format[inpos+1] == '\'') {
2286 inpos += 1;
2287 date[outpos++] = '\'';
2288 } else {
2289 inquote = 0;
2290 continue; /* we did nothing to the output */
2292 } else if (format[inpos] == '\0') {
2293 date[outpos++] = '\0';
2294 if (outpos > datelen) Overflow = 1;
2295 break;
2296 } else {
2297 date[outpos++] = format[inpos];
2298 if (outpos > datelen) {
2299 Overflow = 1;
2300 date[outpos-1] = '\0'; /* this is the last place where
2301 it's safe to write */
2302 break;
2305 } else if ( (count && (format[inpos] != type))
2306 || count == 4
2307 || (count == 2 && strchr("ghHmst", type)) )
2309 if (type == 'd') {
2310 if (count == 4) {
2311 GetLocaleInfo32A(locale,
2312 LOCALE_SDAYNAME1
2313 + xtime->wDayOfWeek - 1,
2314 buf, sizeof(buf));
2315 } else if (count == 3) {
2316 GetLocaleInfo32A(locale,
2317 LOCALE_SABBREVDAYNAME1
2318 + xtime->wDayOfWeek - 1,
2319 buf, sizeof(buf));
2320 } else {
2321 sprintf(buf, dgfmt[count], xtime->wDay);
2323 } else if (type == 'M') {
2324 if (count == 3) {
2325 GetLocaleInfo32A(locale,
2326 LOCALE_SABBREVMONTHNAME1
2327 + xtime->wMonth - 1,
2328 buf, sizeof(buf));
2329 } else if (count == 4) {
2330 GetLocaleInfo32A(locale,
2331 LOCALE_SMONTHNAME1
2332 + xtime->wMonth - 1,
2333 buf, sizeof(buf));
2334 } else {
2335 sprintf(buf, dgfmt[count], xtime->wMonth);
2337 } else if (type == 'y') {
2338 if (count == 4) {
2339 sprintf(buf, "%d", xtime->wYear);
2340 } else if (count == 3) {
2341 strcpy(buf, "yyy");
2342 WARN(ole, "unknown format, c=%c, n=%d\n", type, count);
2343 } else {
2344 sprintf(buf, dgfmt[count], xtime->wYear % 100);
2346 } else if (type == 'g') {
2347 if (count == 2) {
2348 FIXME(ole, "LOCALE_ICALENDARTYPE unimp.\n");
2349 strcpy(buf, "AD");
2350 } else {
2351 strcpy(buf, "g");
2352 WARN(ole, "unknown format, c=%c, n=%d\n", type, count);
2354 } else if (type == 'h') {
2355 /* gives us hours 1:00 -- 12:00 */
2356 sprintf(buf, dgfmt[count], (xtime->wHour-1)%12 +1);
2357 } else if (type == 'H') {
2358 /* 24-hour time */
2359 sprintf(buf, dgfmt[count], xtime->wHour);
2360 } else if ( type == 'm') {
2361 sprintf(buf, dgfmt[count], xtime->wMinute);
2362 } else if ( type == 's') {
2363 sprintf(buf, dgfmt[count], xtime->wSecond);
2364 } else if (type == 't') {
2365 if (count == 1) {
2366 sprintf(buf, "%c", (xtime->wHour < 12) ? 'A' : 'P');
2367 } else if (count == 2) {
2368 /* sprintf(buf, "%s", (xtime->wHour < 12) ? "AM" : "PM"); */
2369 GetLocaleInfo32A(locale,
2370 (xtime->wHour<12)
2371 ? LOCALE_S1159 : LOCALE_S2359,
2372 buf, sizeof(buf));
2376 /* we need to check the next char in the format string
2377 again, no matter what happened */
2378 inpos--;
2380 /* add the contents of buf to the output */
2381 buflen = strlen(buf);
2382 if (outpos + buflen < datelen) {
2383 date[outpos] = '\0'; /* for strcat to hook onto */
2384 strcat(date, buf);
2385 outpos += buflen;
2386 } else {
2387 date[outpos] = '\0';
2388 strncat(date, buf, datelen - outpos);
2389 date[datelen - 1] = '\0';
2390 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2391 WARN(ole, "insufficient buffer\n");
2392 return 0;
2395 /* reset the variables we used to keep track of this item */
2396 count = 0;
2397 type = '\0';
2398 } else if (format[inpos] == '\0') {
2399 /* we can't check for this at the loop-head, because
2400 that breaks the printing of the last format-item */
2401 date[outpos] = '\0';
2402 break;
2403 } else if (count) {
2404 /* continuing a code for an item */
2405 count +=1;
2406 continue;
2407 } else if (strchr("hHmstyMdg", format[inpos])) {
2408 type = format[inpos];
2409 count = 1;
2410 continue;
2411 } else if (format[inpos] == '\'') {
2412 inquote = 1;
2413 continue;
2414 } else {
2415 date[outpos++] = format[inpos];
2417 /* now deal with a possible buffer overflow */
2418 if (outpos >= datelen) {
2419 date[datelen - 1] = '\0';
2420 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2421 return 0;
2425 if (Overflow) {
2426 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2429 /* finish it off with a string terminator */
2430 outpos++;
2431 /* sanity check */
2432 if (outpos > datelen-1) outpos = datelen-1;
2433 date[outpos] = '\0';
2435 TRACE(ole, "OLE_GetFormatA returns string '%s', len %d\n",
2436 date, outpos);
2437 return outpos;
2440 /******************************************************************************
2441 * OLE_GetFormatW [INTERNAL]
2443 INT32 WINAPI OLE_GetFormatW(LCID locale, DWORD flags, DWORD tflags,
2444 LPSYSTEMTIME xtime,
2445 LPCWSTR format,
2446 LPWSTR output, INT32 outlen)
2448 INT32 inpos, outpos;
2449 int count, type=0, inquote;
2450 int Overflow; /* loop check */
2451 WCHAR buf[40];
2452 int buflen=0;
2453 WCHAR arg0[] = {0}, arg1[] = {'%','d',0};
2454 WCHAR arg2[] = {'%','0','2','d',0};
2455 WCHAR *argarr[] = {arg0, arg1, arg2};
2456 int datevars=0, timevars=0;
2458 /* make a debug report */
2459 TRACE(ole, "args: 0x%lx, 0x%lx, 0x%lx, time(d=%d,h=%d,m=%d,s=%d), fmt:%s (at %p),
2460 %p with max len %d\n",
2461 locale, flags, tflags,
2462 xtime->wDay, xtime->wHour, xtime->wMinute, xtime->wSecond,
2463 debugstr_w(format), format, output, outlen);
2466 /* initialize state variables */
2467 inpos = outpos = 0;
2468 count = 0;
2469 inquote = Overflow = 0;
2470 /* this is really just a sanity check */
2471 output[0] = buf[0] = 0;
2473 /* this loop is the core of the function */
2474 for (inpos = 0; /* we have several break points */ ; inpos++) {
2475 if (inquote) {
2476 if (format[inpos] == (WCHAR) '\'') {
2477 if (format[inpos+1] == '\'') {
2478 inpos++;
2479 output[outpos++] = '\'';
2480 } else {
2481 inquote = 0;
2482 continue;
2484 } else if (format[inpos] == 0) {
2485 output[outpos++] = 0;
2486 if (outpos > outlen) Overflow = 1;
2487 break; /* normal exit (within a quote) */
2488 } else {
2489 output[outpos++] = format[inpos]; /* copy input */
2490 if (outpos > outlen) {
2491 Overflow = 1;
2492 output[outpos-1] = 0;
2493 break;
2496 } else if ( (count && (format[inpos] != type))
2497 || ( (count==4 && type =='y') ||
2498 (count==4 && type =='M') ||
2499 (count==4 && type =='d') ||
2500 (count==2 && type =='g') ||
2501 (count==2 && type =='h') ||
2502 (count==2 && type =='H') ||
2503 (count==2 && type =='m') ||
2504 (count==2 && type =='s') ||
2505 (count==2 && type =='t') ) ) {
2506 if (type == 'd') {
2507 if (count == 3) {
2508 GetLocaleInfo32W(locale,
2509 LOCALE_SDAYNAME1 + xtime->wDayOfWeek -1,
2510 buf, sizeof(buf)/sizeof(WCHAR) );
2511 } else if (count == 3) {
2512 GetLocaleInfo32W(locale,
2513 LOCALE_SABBREVDAYNAME1 +
2514 xtime->wDayOfWeek -1,
2515 buf, sizeof(buf)/sizeof(WCHAR) );
2516 } else {
2517 wsnprintf32W(buf, 5, argarr[count], xtime->wDay );
2519 } else if (type == 'M') {
2520 if (count == 4) {
2521 GetLocaleInfo32W(locale, LOCALE_SMONTHNAME1 +
2522 xtime->wMonth -1, buf,
2523 sizeof(buf)/sizeof(WCHAR) );
2524 } else if (count == 3) {
2525 GetLocaleInfo32W(locale, LOCALE_SABBREVMONTHNAME1 +
2526 xtime->wMonth -1, buf,
2527 sizeof(buf)/sizeof(WCHAR) );
2528 } else {
2529 wsnprintf32W(buf, 5, argarr[count], xtime->wMonth);
2531 } else if (type == 'y') {
2532 if (count == 4) {
2533 wsnprintf32W(buf, 6, argarr[1] /* "%d" */,
2534 xtime->wYear);
2535 } else if (count == 3) {
2536 lstrcpynAtoW(buf, "yyy", 5);
2537 } else {
2538 wsnprintf32W(buf, 6, argarr[count],
2539 xtime->wYear % 100);
2541 } else if (type == 'g') {
2542 if (count == 2) {
2543 FIXME(ole, "LOCALE_ICALENDARTYPE unimplemented\n");
2544 lstrcpynAtoW(buf, "AD", 5);
2545 } else {
2546 /* Win API sez we copy it verbatim */
2547 lstrcpynAtoW(buf, "g", 5);
2549 } else if (type == 'h') {
2550 /* hours 1:00-12:00 --- is this right? */
2551 wsnprintf32W(buf, 5, argarr[count],
2552 (xtime->wHour-1)%12 +1);
2553 } else if (type == 'H') {
2554 wsnprintf32W(buf, 5, argarr[count],
2555 xtime->wHour);
2556 } else if (type == 'm' ) {
2557 wsnprintf32W(buf, 5, argarr[count],
2558 xtime->wMinute);
2559 } else if (type == 's' ) {
2560 wsnprintf32W(buf, 5, argarr[count],
2561 xtime->wSecond);
2562 } else if (type == 't') {
2563 GetLocaleInfo32W(locale, (xtime->wHour < 12) ?
2564 LOCALE_S1159 : LOCALE_S2359,
2565 buf, sizeof(buf) );
2566 if (count == 1) {
2567 buf[1] = 0;
2571 /* no matter what happened, we need to check this next
2572 character the next time we loop through */
2573 inpos--;
2575 /* cat buf onto the output */
2576 outlen = lstrlen32W(buf);
2577 if (outpos + buflen < outlen) {
2578 output[outpos] = 0; /* a "hook" for strcat */
2579 lstrcat32W(output, buf);
2580 outpos += buflen;
2581 } else {
2582 output[outpos] = 0;
2583 lstrcatn32W(output, buf, outlen - outpos);
2584 output[outlen - 1] = 0;
2585 Overflow = 1;
2586 break; /* Abnormal exit */
2589 /* reset the variables we used this time */
2590 count = 0;
2591 type = '\0';
2592 } else if (format[inpos] == 0) {
2593 /* we can't check for this at the beginning, because that
2594 would keep us from printing a format spec that ended the
2595 string */
2596 output[outpos] = 0;
2597 break; /* NORMAL EXIT */
2598 } else if (count) {
2599 /* how we keep track of the middle of a format spec */
2600 count++;
2601 continue;
2602 } else if ( (datevars && (format[inpos]=='d' ||
2603 format[inpos]=='M' ||
2604 format[inpos]=='y' ||
2605 format[inpos]=='g') ) ||
2606 (timevars && (format[inpos]=='H' ||
2607 format[inpos]=='h' ||
2608 format[inpos]=='m' ||
2609 format[inpos]=='s' ||
2610 format[inpos]=='t') ) ) {
2611 type = format[inpos];
2612 count = 1;
2613 continue;
2614 } else if (format[inpos] == '\'') {
2615 inquote = 1;
2616 continue;
2617 } else {
2618 /* unquoted literals */
2619 output[outpos++] = format[inpos];
2623 if (Overflow) {
2624 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2625 WARN(ole, " buffer overflow\n");
2628 /* final string terminator and sanity check */
2629 outpos++;
2630 if (outpos > outlen-1) outpos = outlen-1;
2631 output[outpos] = '0';
2633 TRACE(ole, " returning %s\n", debugstr_w(output));
2635 return (!Overflow) ? outlen : 0;
2640 /******************************************************************************
2641 * GetDateFormat32A [KERNEL32.310]
2642 * Makes an ASCII string of the date
2644 * This function uses format to format the date, or, if format
2645 * is NULL, uses the default for the locale. format is a string
2646 * of literal fields and characters as follows:
2648 * - d single-digit (no leading zero) day (of month)
2649 * - dd two-digit day (of month)
2650 * - ddd short day-of-week name
2651 * - dddd long day-of-week name
2652 * - M single-digit month
2653 * - MM two-digit month
2654 * - MMM short month name
2655 * - MMMM full month name
2656 * - y two-digit year, no leading 0
2657 * - yy two-digit year
2658 * - yyyy four-digit year
2659 * - gg era string
2662 INT32 WINAPI GetDateFormat32A(LCID locale,DWORD flags,
2663 LPSYSTEMTIME xtime,
2664 LPCSTR format, LPSTR date,INT32 datelen)
2667 char format_buf[40];
2668 LPCSTR thisformat;
2669 SYSTEMTIME t;
2670 LPSYSTEMTIME thistime;
2671 LCID thislocale;
2672 INT32 ret;
2674 TRACE(ole,"(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",
2675 locale,flags,xtime,format,date,datelen);
2677 if (!locale) {
2678 locale = LOCALE_SYSTEM_DEFAULT;
2681 if (locale == LOCALE_SYSTEM_DEFAULT) {
2682 thislocale = GetSystemDefaultLCID();
2683 } else if (locale == LOCALE_USER_DEFAULT) {
2684 thislocale = GetUserDefaultLCID();
2685 } else {
2686 thislocale = locale;
2689 if (xtime == NULL) {
2690 GetSystemTime(&t);
2691 thistime = &t;
2692 } else {
2693 thistime = xtime;
2696 if (format == NULL) {
2697 GetLocaleInfo32A(thislocale, ((flags&DATE_LONGDATE)
2698 ? LOCALE_SLONGDATE
2699 : LOCALE_SSHORTDATE),
2700 format_buf, sizeof(format_buf));
2701 thisformat = format_buf;
2702 } else {
2703 thisformat = format;
2707 ret = OLE_GetFormatA(thislocale, flags, 0, thistime, thisformat,
2708 date, datelen);
2711 TRACE(ole,
2712 "GetDateFormat32A() returning %d, with data=%s\n",
2713 ret, date);
2714 return ret;
2717 /******************************************************************************
2718 * GetDateFormat32W [KERNEL32.311]
2719 * Makes a Unicode string of the date
2721 * Acts the same as GetDateFormat32A(), except that it's Unicode.
2722 * Accepts & returns sizes as counts of Unicode characters.
2725 INT32 WINAPI GetDateFormat32W(LCID locale,DWORD flags,
2726 LPSYSTEMTIME xtime,
2727 LPCWSTR format,
2728 LPWSTR date, INT32 datelen)
2730 short datearr[] = {'1','9','9','4','-','1','-','1',0};
2732 FIXME(ole, "STUB (should call OLE_GetFormatW)\n");
2733 lstrcpyn32W(date, datearr, datelen);
2734 return ( datelen < 9) ? datelen : 9;
2739 /**************************************************************************
2740 * EnumDateFormats32A (KERNEL32.198)
2742 BOOL32 WINAPI EnumDateFormats32A(
2743 DATEFMT_ENUMPROC32A lpDateFmtEnumProc, LCID Locale, DWORD dwFlags)
2745 FIXME(ole, "Only US English supported\n");
2747 if(!lpDateFmtEnumProc)
2749 SetLastError(ERROR_INVALID_PARAMETER);
2750 return FALSE;
2753 switch(dwFlags)
2755 case DATE_SHORTDATE:
2756 if(!(*lpDateFmtEnumProc)("M/d/yy")) return TRUE;
2757 if(!(*lpDateFmtEnumProc)("M/d/yyyy")) return TRUE;
2758 if(!(*lpDateFmtEnumProc)("MM/dd/yy")) return TRUE;
2759 if(!(*lpDateFmtEnumProc)("MM/dd/yyyy")) return TRUE;
2760 if(!(*lpDateFmtEnumProc)("yy/MM/dd")) return TRUE;
2761 if(!(*lpDateFmtEnumProc)("dd-MMM-yy")) return TRUE;
2762 return TRUE;
2763 case DATE_LONGDATE:
2764 if(!(*lpDateFmtEnumProc)("dddd, MMMM dd, yyyy")) return TRUE;
2765 if(!(*lpDateFmtEnumProc)("MMMM dd, yyyy")) return TRUE;
2766 if(!(*lpDateFmtEnumProc)("dddd, dd MMMM, yyyy")) return TRUE;
2767 if(!(*lpDateFmtEnumProc)("dd MMMM, yyyy")) return TRUE;
2768 return TRUE;
2769 default:
2770 FIXME(ole, "Unknown date format (%ld)\n", dwFlags);
2771 SetLastError(ERROR_INVALID_PARAMETER);
2772 return FALSE;
2776 /**************************************************************************
2777 * EnumDateFormats32W (KERNEL32.199)
2779 BOOL32 WINAPI EnumDateFormats32W(
2780 DATEFMT_ENUMPROC32W lpDateFmtEnumProc, LCID Locale, DWORD dwFlags)
2782 FIXME(ole, "(%p, %ld, %ld): stub\n", lpDateFmtEnumProc, Locale, dwFlags);
2783 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
2784 return FALSE;
2787 /**************************************************************************
2788 * EnumTimeFormats32A (KERNEL32.210)
2790 BOOL32 WINAPI EnumTimeFormats32A(
2791 TIMEFMT_ENUMPROC32A lpTimeFmtEnumProc, LCID Locale, DWORD dwFlags)
2793 FIXME(ole, "Only US English supported\n");
2795 if(!lpTimeFmtEnumProc)
2797 SetLastError(ERROR_INVALID_PARAMETER);
2798 return FALSE;
2801 if(dwFlags)
2803 FIXME(ole, "Unknown time format (%ld)\n", dwFlags);
2806 if(!(*lpTimeFmtEnumProc)("h:mm:ss tt")) return TRUE;
2807 if(!(*lpTimeFmtEnumProc)("hh:mm:ss tt")) return TRUE;
2808 if(!(*lpTimeFmtEnumProc)("H:mm:ss")) return TRUE;
2809 if(!(*lpTimeFmtEnumProc)("HH:mm:ss")) return TRUE;
2811 return TRUE;
2814 /**************************************************************************
2815 * EnumTimeFormats32W (KERNEL32.211)
2817 BOOL32 WINAPI EnumTimeFormats32W(
2818 TIMEFMT_ENUMPROC32W lpTimeFmtEnumProc, LCID Locale, DWORD dwFlags)
2820 FIXME(ole, "(%p,%ld,%ld): stub", lpTimeFmtEnumProc, Locale, dwFlags);
2821 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
2822 return FALSE;
2825 /**************************************************************************
2826 * GetNumberFormat32A (KERNEL32.355)
2828 INT32 WINAPI GetNumberFormat32A(LCID locale, DWORD dwflags,
2829 LPCSTR lpvalue, const NUMBERFMT32A * lpFormat,
2830 LPSTR lpNumberStr, int cchNumber)
2832 int n;
2834 FIXME(file,"%s: stub, no reformating done\n",lpvalue);
2836 n = strlen(lpvalue);
2837 if (cchNumber) {
2838 strncpy(lpNumberStr,lpvalue,cchNumber);
2839 if (cchNumber <= n) {
2840 lpNumberStr[cchNumber-1] = 0;
2841 n = cchNumber-1;
2844 return n;
2846 /**************************************************************************
2847 * GetNumberFormat32W (KERNEL32.xxx)
2849 INT32 WINAPI GetNumberFormat32W(LCID locale, DWORD dwflags,
2850 LPCWSTR lpvalue, const NUMBERFMT32W * lpFormat,
2851 LPWSTR lpNumberStr, int cchNumber)
2853 int n;
2855 FIXME(file,"%s: stub, no reformating done\n",debugstr_w(lpvalue));
2857 n = lstrlen32W(lpvalue);
2858 if (cchNumber) {
2859 lstrcpyn32W(lpNumberStr,lpvalue,cchNumber);
2860 if (cchNumber <= n) {
2861 lpNumberStr[cchNumber-1] = 0;
2862 n = cchNumber-1;
2865 return n;
2867 /******************************************************************************
2868 * OLE2NLS_CheckLocale [intern]
2870 static LCID OLE2NLS_CheckLocale (LCID locale)
2872 if (!locale)
2873 { locale = LOCALE_SYSTEM_DEFAULT;
2876 if (locale == LOCALE_SYSTEM_DEFAULT)
2877 { return GetSystemDefaultLCID();
2879 else if (locale == LOCALE_USER_DEFAULT)
2880 { return GetUserDefaultLCID();
2882 else
2883 { return locale;
2886 /******************************************************************************
2887 * GetTimeFormat32A [KERNEL32.422]
2888 * Makes an ASCII string of the time
2890 * Formats date according to format, or locale default if format is
2891 * NULL. The format consists of literal characters and fields as follows:
2893 * h hours with no leading zero (12-hour)
2894 * hh hours with full two digits
2895 * H hours with no leading zero (24-hour)
2896 * HH hours with full two digits
2897 * m minutes with no leading zero
2898 * mm minutes with full two digits
2899 * s seconds with no leading zero
2900 * ss seconds with full two digits
2901 * t time marker (A or P)
2902 * tt time marker (AM, PM)
2905 INT32 WINAPI
2906 GetTimeFormat32A(LCID locale, /* in */
2907 DWORD flags, /* in */
2908 LPSYSTEMTIME xtime, /* in */
2909 LPCSTR format, /* in */
2910 LPSTR timestr, /* out */
2911 INT32 timelen /* in */)
2912 { char format_buf[40];
2913 LPCSTR thisformat;
2914 SYSTEMTIME t;
2915 LPSYSTEMTIME thistime;
2916 LCID thislocale=0;
2917 DWORD thisflags=LOCALE_STIMEFORMAT; /* standart timeformat */
2918 INT32 ret;
2920 TRACE(ole,"GetTimeFormat(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",locale,flags,xtime,format,timestr,timelen);
2922 thislocale = OLE2NLS_CheckLocale ( locale );
2924 if ( flags & (TIME_NOTIMEMARKER | TIME_FORCE24HOURFORMAT ))
2925 { FIXME(ole,"TIME_NOTIMEMARKER or TIME_FORCE24HOURFORMAT not implemented\n");
2928 flags &= (TIME_NOSECONDS | TIME_NOMINUTESORSECONDS); /* mask for OLE_GetFormatA*/
2930 if (format == NULL)
2931 { if (flags & LOCALE_NOUSEROVERRIDE) /*use system default*/
2932 { thislocale = GetSystemDefaultLCID();
2934 GetLocaleInfo32A(thislocale, thisflags, format_buf, sizeof(format_buf));
2935 thisformat = format_buf;
2937 else
2938 { thisformat = format;
2941 if (xtime == NULL) /* NULL means use the current local time*/
2942 { GetSystemTime(&t);
2943 thistime = &t;
2945 else
2946 { thistime = xtime;
2948 ret = OLE_GetFormatA(thislocale, thisflags, flags, thistime, thisformat,
2949 timestr, timelen);
2950 SetLastError(ret);
2951 return ret;
2955 /******************************************************************************
2956 * GetTimeFormat32W [KERNEL32.423]
2957 * Makes a Unicode string of the time
2959 INT32 WINAPI
2960 GetTimeFormat32W(LCID locale, /* in */
2961 DWORD flags, /* in */
2962 LPSYSTEMTIME xtime, /* in */
2963 LPCWSTR format, /* in */
2964 LPWSTR timestr, /* out */
2965 INT32 timelen /* in */)
2966 { WCHAR format_buf[40];
2967 LPCWSTR thisformat;
2968 SYSTEMTIME t;
2969 LPSYSTEMTIME thistime;
2970 LCID thislocale=0;
2971 DWORD thisflags=LOCALE_STIMEFORMAT; /* standart timeformat */
2972 INT32 ret;
2974 TRACE(ole,"GetTimeFormat(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",locale,flags,
2975 xtime,debugstr_w(format),timestr,timelen);
2977 thislocale = OLE2NLS_CheckLocale ( locale );
2979 if ( flags & (TIME_NOTIMEMARKER | TIME_FORCE24HOURFORMAT ))
2980 { FIXME(ole,"TIME_NOTIMEMARKER or TIME_FORCE24HOURFORMAT not implemented\n");
2983 flags &= (TIME_NOSECONDS | TIME_NOMINUTESORSECONDS); /* mask for OLE_GetFormatA*/
2985 if (format == NULL)
2986 { if (flags & LOCALE_NOUSEROVERRIDE) /*use system default*/
2987 { thislocale = GetSystemDefaultLCID();
2989 GetLocaleInfo32W(thislocale, thisflags, format_buf, 40);
2990 thisformat = format_buf;
2992 else
2993 { thisformat = format;
2996 if (xtime == NULL) /* NULL means use the current local time*/
2997 { GetSystemTime(&t);
2998 thistime = &t;
3000 else
3001 { thistime = xtime;
3004 ret = OLE_GetFormatW(thislocale, thisflags, flags, thistime, thisformat,
3005 timestr, timelen);
3006 SetLastError(ret);
3007 return ret;