4 * Copyright 1995 Martin von Loewis
5 * Copyright 1998 David Lee Lambert
20 int MAIN_GetLanguageID(char*lang, char*country, char*charset, char*dialect);
22 /* Locale name to id map. used by EnumSystemLocales, GetLocalInfoA
23 * MUST contain all #defines from winnls.h
24 * last entry has NULL name, 0 id.
26 #define LOCALE_ENTRY(x) {#x,LOCALE_##x}
27 static struct tagLOCALE_NAME2ID {
31 LOCALE_ENTRY(ILANGUAGE),
32 LOCALE_ENTRY(SLANGUAGE),
33 LOCALE_ENTRY(SENGLANGUAGE),
34 LOCALE_ENTRY(SABBREVLANGNAME),
35 LOCALE_ENTRY(SNATIVELANGNAME),
36 LOCALE_ENTRY(ICOUNTRY),
37 LOCALE_ENTRY(SCOUNTRY),
38 LOCALE_ENTRY(SENGCOUNTRY),
39 LOCALE_ENTRY(SABBREVCTRYNAME),
40 LOCALE_ENTRY(SNATIVECTRYNAME),
41 LOCALE_ENTRY(IDEFAULTLANGUAGE),
42 LOCALE_ENTRY(IDEFAULTCOUNTRY),
43 LOCALE_ENTRY(IDEFAULTCODEPAGE),
44 LOCALE_ENTRY(IDEFAULTANSICODEPAGE),
46 LOCALE_ENTRY(IMEASURE),
47 LOCALE_ENTRY(SDECIMAL),
48 LOCALE_ENTRY(STHOUSAND),
49 LOCALE_ENTRY(SGROUPING),
50 LOCALE_ENTRY(IDIGITS),
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),
65 LOCALE_ENTRY(SSHORTDATE),
66 LOCALE_ENTRY(SLONGDATE),
67 LOCALE_ENTRY(STIMEFORMAT),
71 LOCALE_ENTRY(ITIMEMARKPOSN),
72 LOCALE_ENTRY(ICENTURY),
73 LOCALE_ENTRY(ITLZERO),
74 LOCALE_ENTRY(IDAYLZERO),
75 LOCALE_ENTRY(IMONLZERO),
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),*/
134 const struct map_lcid2str {
136 const char *langname;
138 {0x0401,"Arabic (Saudi Arabia)"},
139 {0x0801,"Arabic (Iraq)"},
140 {0x0c01,"Arabic (Egypt)"},
141 {0x1001,"Arabic (Libya)"},
142 {0x1401,"Arabic (Algeria)"},
143 {0x1801,"Arabic (Morocco)"},
144 {0x1c01,"Arabic (Tunisia)"},
145 {0x2001,"Arabic (Oman)"},
146 {0x2401,"Arabic (Yemen)"},
147 {0x2801,"Arabic (Syria)"},
148 {0x2c01,"Arabic (Jordan)"},
149 {0x3001,"Arabic (Lebanon)"},
150 {0x3401,"Arabic (Kuwait)"},
151 {0x3801,"Arabic (United Arab Emirates)"},
152 {0x3c01,"Arabic (Bahrain)"},
153 {0x4001,"Arabic (Qatar)"},
154 {0x0402,"Bulgarian"},
156 {0x0404,"Chinese (Taiwan)"},
157 {0x0804,"Chinese (People's Republic of China)"},
158 {0x0c04,"Chinese (Hong Kong)"},
159 {0x1004,"Chinese (Singapore)"},
160 {0x1404,"Chinese (Macau)"},
163 {0x0407,"German (Germany)"},
164 {0x0807,"German (Switzerland)"},
165 {0x0c07,"German (Austria)"},
166 {0x1007,"German (Luxembourg)"},
167 {0x1407,"German (Liechtenstein)"},
169 {0x0409,"English (United States)"},
170 {0x0809,"English (United Kingdom)"},
171 {0x0c09,"English (Australia)"},
172 {0x1009,"English (Canada)"},
173 {0x1409,"English (New Zealand)"},
174 {0x1809,"English (Ireland)"},
175 {0x1c09,"English (South Africa)"},
176 {0x2009,"English (Jamaica)"},
177 {0x2409,"English (Caribbean)"},
178 {0x2809,"English (Belize)"},
179 {0x2c09,"English (Trinidad)"},
180 {0x3009,"English (Zimbabwe)"},
181 {0x3409,"English (Philippines)"},
182 {0x040a,"Spanish (Spain, traditional sorting)"},
183 {0x080a,"Spanish (Mexico)"},
184 {0x0c0a,"Spanish (Spain, international sorting)"},
185 {0x100a,"Spanish (Guatemala)"},
186 {0x140a,"Spanish (Costa Rica)"},
187 {0x180a,"Spanish (Panama)"},
188 {0x1c0a,"Spanish (Dominican Republic)"},
189 {0x200a,"Spanish (Venezuela)"},
190 {0x240a,"Spanish (Colombia)"},
191 {0x280a,"Spanish (Peru)"},
192 {0x2c0a,"Spanish (Argentina)"},
193 {0x300a,"Spanish (Ecuador)"},
194 {0x340a,"Spanish (Chile)"},
195 {0x380a,"Spanish (Uruguay)"},
196 {0x3c0a,"Spanish (Paraguay)"},
197 {0x400a,"Spanish (Bolivia)"},
198 {0x440a,"Spanish (El Salvador)"},
199 {0x480a,"Spanish (Honduras)"},
200 {0x4c0a,"Spanish (Nicaragua)"},
201 {0x500a,"Spanish (Puerto Rico)"},
203 {0x040c,"French (France)"},
204 {0x080c,"French (Belgium)"},
205 {0x0c0c,"French (Canada)"},
206 {0x100c,"French (Switzerland)"},
207 {0x140c,"French (Luxembourg)"},
208 {0x180c,"French (Monaco)"},
210 {0x040e,"Hungarian"},
211 {0x040f,"Icelandic"},
212 {0x0410,"Italian (Italy)"},
213 {0x0810,"Italian (Switzerland)"},
215 {0x0412,"Korean (Wansung)"},
216 {0x0812,"Korean (Johab)"},
217 {0x0413,"Dutch (Netherlands)"},
218 {0x0813,"Dutch (Belgium)"},
219 {0x0414,"Norwegian (Bokmal)"},
220 {0x0814,"Norwegian (Nynorsk)"},
222 {0x0416,"Portuguese (Brazil)"},
223 {0x0816,"Portuguese (Portugal)"},
224 {0x0417,"Rhaeto Romanic"},
226 {0x0818,"Moldavian"},
227 {0x0419,"Russian (Russia)"},
228 {0x0819,"Russian (Moldavia)"},
230 {0x081a,"Serbian (latin)"},
231 {0x0c1a,"Serbian (cyrillic)"},
234 {0x041d,"Swedish (Sweden)"},
235 {0x081d,"Swedish (Finland)"},
239 {0x0421,"Indonesian"},
240 {0x0422,"Ukrainian"},
241 {0x0423,"Belarusian"},
245 {0x0427,"Lithuanian (modern)"},
246 {0x0827,"Lithuanian (classic)"},
249 {0x042a,"Vietnamese"},
251 {0x042c,"Azeri (latin)"},
252 {0x082c,"Azeri (cyrillic)"},
255 {0x042f,"Macedonian"},
262 {0x0436,"Afrikaans"},
268 {0x043c,"Irish gaelic"},
269 {0x083c,"Scottish gaelic"},
270 {0x043e,"Malay (Malaysia)"},
271 {0x083e,"Malay (Brunei Darussalam)"},
274 {0x0443,"Uzbek (latin)"},
275 {0x0843,"Uzbek (cyrillic)"},
284 {0x044c,"Malayalam"},
289 {0x048f,"Esperanto"}, /* Non official */
293 {0x0402,"Bulgarisch"},
294 {0x0403,"Katalanisch"},
295 {0x0404,"Traditionales Chinesisch"},
296 {0x0405,"Tschecisch"},
299 {0x0408,"Griechisch"},
300 {0x0409,"Amerikanisches Englisch"},
301 {0x040A,"Kastilisches Spanisch"},
303 {0x040C,"Franzvsisch"},
304 {0x040D,"Hebrdisch"},
305 {0x040E,"Ungarisch"},
306 {0x040F,"Isldndisch"},
307 {0x0410,"Italienisch"},
308 {0x0411,"Japanisch"},
309 {0x0412,"Koreanisch"},
310 {0x0413,"Niederldndisch"},
311 {0x0414,"Norwegisch-Bokmal"},
313 {0x0416,"Brasilianisches Portugiesisch"},
314 {0x0417,"Rdtoromanisch"},
315 {0x0418,"Rumdnisch"},
317 {0x041A,"Kroatoserbisch (lateinisch)"},
318 {0x041B,"Slowenisch"},
319 {0x041C,"Albanisch"},
320 {0x041D,"Schwedisch"},
325 {0x0804,"Vereinfachtes Chinesisch"},
326 {0x0807,"Schweizerdeutsch"},
327 {0x0809,"Britisches Englisch"},
328 {0x080A,"Mexikanisches Spanisch"},
329 {0x080C,"Belgisches Franzvsisch"},
330 {0x0810,"Schweizerisches Italienisch"},
331 {0x0813,"Belgisches Niederldndisch"},
332 {0x0814,"Norgwegisch-Nynorsk"},
333 {0x0816,"Portugiesisch"},
334 {0x081A,"Serbokratisch (kyrillisch)"},
335 {0x0C1C,"Kanadisches Franzvsisch"},
336 {0x100C,"Schweizerisches Franzvsisch"},
337 {0x0000,"Unbekannt"},
340 /***********************************************************************
341 * GetUserDefaultLCID (OLE2NLS.1)
343 LCID WINAPI GetUserDefaultLCID()
345 return MAKELCID( GetUserDefaultLangID() , SORT_DEFAULT );
348 /***********************************************************************
349 * GetSystemDefaultLCID (OLE2NLS.2)
351 LCID WINAPI GetSystemDefaultLCID()
353 return GetUserDefaultLCID();
356 /***********************************************************************
357 * GetUserDefaultLangID (OLE2NLS.3)
359 LANGID WINAPI GetUserDefaultLangID()
362 char *lang,*country,*charset,*dialect,*next;
365 if (Options.language) return Languages[Options.language].langid;
367 buf=getenv("LANGUAGE");
368 if (!buf) buf=getenv("LANG");
369 if (!buf) buf=getenv("LC_ALL");
370 if (!buf) buf=getenv("LC_MESSAGES");
371 if (!buf) return MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT );
373 if (!strcmp(buf,"POSIX") || !strcmp(buf,"C")) {
375 return MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT );
381 next=strchr(lang,':'); if (next) *next++='\0';
382 dialect=strchr(lang,'@'); if (dialect) *dialect++='\0';
383 charset=strchr(lang,'.'); if (charset) *charset++='\0';
384 country=strchr(lang,'_'); if (country) *country++='\0';
386 ret=MAIN_GetLanguageID(lang, country, charset, dialect);
390 } while (lang && !ret);
396 /***********************************************************************
397 * GetSystemDefaultLangID (OLE2NLS.4)
399 LANGID WINAPI GetSystemDefaultLangID()
401 return GetUserDefaultLangID();
404 /***********************************************************************
405 * GetLocaleInfoA (OLE2NLS.5)
406 * Is the last parameter really WORD for Win16?
408 INT16 WINAPI GetLocaleInfo16(LCID lcid,LCTYPE LCType,LPSTR buf,INT16 len)
410 return GetLocaleInfo32A(lcid,LCType,buf,len);
413 INT32 WINAPI GetLocaleInfo32A(LCID lcid,LCTYPE LCType,LPSTR buf,INT32 len)
419 TRACE(ole,"(0x%lx,0x%lx,%p,%x)\n",
420 lcid,LCType,buf,len);
422 LCType &= ~(LOCALE_NOUSEROVERRIDE|LOCALE_USE_CP_ACP);
424 /* As an option, we could obtain the value from win.ini.
425 This would not match the Wine compile-time option.
426 Also, not all identifiers are available from win.ini */
428 /* If we are through all of this, retLen should not be zero anymore.
429 If it is, the value is not supported */
431 while (locale_name2id[i].name!=NULL) {
432 if (LCType == locale_name2id[i].id) {
433 retString = locale_name2id[i].name;
439 WARN(ole,"Unkown LC type %lX\n",LCType);
443 #define LOCVAL(type,value) case type:retString=value;found=1;break;
445 /* Now, the language specific definitions. They don't have to be
450 if (i=0) lang=Languages[Options.language].langid;
451 if (i=1) lang=MAKELANGID( PRIMARYLANGID(lang), SUBLANG_DEFAULT);
457 #include "nls/deu.nls"
458 default: found=0; break;
460 break; /* LANG(De) */
464 #include "nls/dan.nls"
465 default: found=0;break;
467 break; /* LANG(Da) */
471 #include "nls/enu.nls"
472 default: found=0;break;
474 break; /* LANG(En) */
478 #include "nls/esperanto.nls"
479 default: found=0;break;
481 break; /* LANG(Eo) */
485 #include "nls/fin.nls"
486 default: found=0;break;
488 break; /* LANG(Fi) */
492 #include "nls/ita.nls"
493 default: found=0;break;
495 break; /* LANG(It) */
499 #include "nls/eng.nls"
500 default: found=0;break;
502 break; /* LANG(0x0809) (U.K. English) */
504 case LANG_Ko: /* string using codepage 949 */
506 #include "nls/kor.nls"
507 default: found=0;break;
509 break; /* LANG(Ko) */
513 #include "nls/hun.nls"
514 default: found=0;break;
516 break; /* LANG(En) */
520 #include "nls/plk.nls"
521 default: found=0;break;
523 break; /* LANG(Pl) */
527 #include "nls/ptb.nls"
528 default: found=0;break;
530 break; /* LANG(Pt) */
534 #include "nls/sve.nls"
535 default: found=0;break;
537 break; /* LANG(Sv) */
539 /*Insert other languages here*/
545 } while (!found && i<2);
548 ERR(ole,"'%s' not supported for your language.\n",
550 retString = "<WINE-NLS-unknown>";
554 lstrcpyn32A(buf,retString,len);
555 return strlen(retString)+1;
558 /***********************************************************************
559 * GetLocaleInfo32W (KERNEL32.230)
560 * Is the last parameter really WORD for Win16?
562 INT32 WINAPI GetLocaleInfo32W(LCID lcid,LCTYPE LCType,LPWSTR wbuf,INT32 len)
564 LPSTR abuf = (LPSTR)HeapAlloc(GetProcessHeap(),0,len);
566 INT32 n = GetLocaleInfo32A(lcid, LCType, abuf, len);
568 lstrcpynAtoW(wbuf,abuf,len);
569 HeapFree(GetProcessHeap(),0,abuf);
573 /***********************************************************************
574 * SetLocaleInfoA [KERNEL32.499]
576 BOOL16 WINAPI SetLocaleInfoA(DWORD lcid, DWORD lctype, LPCSTR data)
578 FIXME(ole,"(%ld,%ld,%s): stub\n",lcid,lctype,data);
582 /***********************************************************************
583 * IsValidLocale [KERNEL32.361]
585 BOOL32 WINAPI IsValidLocale(LCID lcid,DWORD flags)
587 /* we support ANY language. Well, at least say that...*/
591 /***********************************************************************
592 * EnumSystemLocales32W [KERNEL32.93]
594 BOOL32 WINAPI EnumSystemLocales32W( LOCALE_ENUMPROC32W lpfnLocaleEnum,
602 TRACE(win32,"(%p,%08lx)\n",lpfnLocaleEnum,flags );
603 /* see if we can reuse the Win95 registry entries.... */
604 if (ERROR_SUCCESS==RegOpenKey32A(HKEY_LOCAL_MACHINE,"\\System\\CurrentControlSet\\control\\Nls\\Locale\\",&xhkey)) {
607 if (ERROR_SUCCESS!=RegEnumKey32W(xhkey,i,buffer,sizeof(buffer)))
609 if (!lpfnLocaleEnum(buffer))
618 while (languages[i].langname!=NULL)
623 sprintf(xbuffer,"%08lx",(DWORD)languages[i].langid);
625 cp = HEAP_strdupAtoW( GetProcessHeap(), 0, xbuffer );
626 ret = lpfnLocaleEnum(cp);
627 HeapFree( GetProcessHeap(), 0, cp );
634 /***********************************************************************
635 * EnumSystemLocales32A [KERNEL32.92]
637 BOOL32 WINAPI EnumSystemLocales32A(LOCALE_ENUMPROC32A lpfnLocaleEnum,
644 TRACE(win32,"(%p,%08lx)\n",
647 if (ERROR_SUCCESS==RegOpenKey32A(HKEY_LOCAL_MACHINE,"\\System\\CurrentControlSet\\control\\Nls\\Locale\\",&xhkey)) {
650 if (ERROR_SUCCESS!=RegEnumKey32A(xhkey,i,buffer,sizeof(buffer)))
652 if (!lpfnLocaleEnum(buffer))
660 while (languages[i].langname!=NULL) {
661 sprintf(buffer,"%08lx",(DWORD)languages[i].langid);
662 if (!lpfnLocaleEnum(buffer))
669 static const unsigned char CT_CType2_LUT[] = {
670 C2_NOTAPPLICABLE, /* - 0 */
671 C2_NOTAPPLICABLE, /* - 1 */
672 C2_NOTAPPLICABLE, /* - 2 */
673 C2_NOTAPPLICABLE, /* - 3 */
674 C2_NOTAPPLICABLE, /* - 4 */
675 C2_NOTAPPLICABLE, /* - 5 */
676 C2_NOTAPPLICABLE, /* - 6 */
677 C2_NOTAPPLICABLE, /* - 7 */
678 C2_NOTAPPLICABLE, /* - 8 */
679 C2_SEGMENTSEPARATOR, /* - 9 */
680 C2_NOTAPPLICABLE, /* - 10 */
681 C2_NOTAPPLICABLE, /* - 11 */
682 C2_NOTAPPLICABLE, /* - 12 */
683 C2_NOTAPPLICABLE, /* - 13 */
684 C2_NOTAPPLICABLE, /* - 14 */
685 C2_NOTAPPLICABLE, /* - 15 */
686 C2_NOTAPPLICABLE, /* - 16 */
687 C2_NOTAPPLICABLE, /* - 17 */
688 C2_NOTAPPLICABLE, /* - 18 */
689 C2_NOTAPPLICABLE, /* - 19 */
690 C2_NOTAPPLICABLE, /* - 20 */
691 C2_NOTAPPLICABLE, /* - 21 */
692 C2_NOTAPPLICABLE, /* - 22 */
693 C2_NOTAPPLICABLE, /* - 23 */
694 C2_NOTAPPLICABLE, /* - 24 */
695 C2_NOTAPPLICABLE, /* - 25 */
696 C2_NOTAPPLICABLE, /* - 26 */
697 C2_NOTAPPLICABLE, /* - 27 */
698 C2_NOTAPPLICABLE, /* - 28 */
699 C2_NOTAPPLICABLE, /* - 29 */
700 C2_NOTAPPLICABLE, /* - 30 */
701 C2_NOTAPPLICABLE, /* - 31 */
702 C2_WHITESPACE, /* - 32 */
703 C2_OTHERNEUTRAL, /* ! - 33 */
704 C2_OTHERNEUTRAL, /* " - 34 */ /* " */
705 C2_EUROPETERMINATOR, /* # - 35 */
706 C2_EUROPETERMINATOR, /* $ - 36 */
707 C2_EUROPETERMINATOR, /* % - 37 */
708 C2_LEFTTORIGHT, /* & - 38 */
709 C2_OTHERNEUTRAL, /* ' - 39 */
710 C2_OTHERNEUTRAL, /* ( - 40 */
711 C2_OTHERNEUTRAL, /* ) - 41 */
712 C2_OTHERNEUTRAL, /* * - 42 */
713 C2_EUROPETERMINATOR, /* + - 43 */
714 C2_COMMONSEPARATOR, /* , - 44 */
715 C2_EUROPETERMINATOR, /* - - 45 */
716 C2_EUROPESEPARATOR, /* . - 46 */
717 C2_EUROPESEPARATOR, /* / - 47 */
718 C2_EUROPENUMBER, /* 0 - 48 */
719 C2_EUROPENUMBER, /* 1 - 49 */
720 C2_EUROPENUMBER, /* 2 - 50 */
721 C2_EUROPENUMBER, /* 3 - 51 */
722 C2_EUROPENUMBER, /* 4 - 52 */
723 C2_EUROPENUMBER, /* 5 - 53 */
724 C2_EUROPENUMBER, /* 6 - 54 */
725 C2_EUROPENUMBER, /* 7 - 55 */
726 C2_EUROPENUMBER, /* 8 - 56 */
727 C2_EUROPENUMBER, /* 9 - 57 */
728 C2_COMMONSEPARATOR, /* : - 58 */
729 C2_OTHERNEUTRAL, /* ; - 59 */
730 C2_OTHERNEUTRAL, /* < - 60 */
731 C2_OTHERNEUTRAL, /* = - 61 */
732 C2_OTHERNEUTRAL, /* > - 62 */
733 C2_OTHERNEUTRAL, /* ? - 63 */
734 C2_LEFTTORIGHT, /* @ - 64 */
735 C2_LEFTTORIGHT, /* A - 65 */
736 C2_LEFTTORIGHT, /* B - 66 */
737 C2_LEFTTORIGHT, /* C - 67 */
738 C2_LEFTTORIGHT, /* D - 68 */
739 C2_LEFTTORIGHT, /* E - 69 */
740 C2_LEFTTORIGHT, /* F - 70 */
741 C2_LEFTTORIGHT, /* G - 71 */
742 C2_LEFTTORIGHT, /* H - 72 */
743 C2_LEFTTORIGHT, /* I - 73 */
744 C2_LEFTTORIGHT, /* J - 74 */
745 C2_LEFTTORIGHT, /* K - 75 */
746 C2_LEFTTORIGHT, /* L - 76 */
747 C2_LEFTTORIGHT, /* M - 77 */
748 C2_LEFTTORIGHT, /* N - 78 */
749 C2_LEFTTORIGHT, /* O - 79 */
750 C2_LEFTTORIGHT, /* P - 80 */
751 C2_LEFTTORIGHT, /* Q - 81 */
752 C2_LEFTTORIGHT, /* R - 82 */
753 C2_LEFTTORIGHT, /* S - 83 */
754 C2_LEFTTORIGHT, /* T - 84 */
755 C2_LEFTTORIGHT, /* U - 85 */
756 C2_LEFTTORIGHT, /* V - 86 */
757 C2_LEFTTORIGHT, /* W - 87 */
758 C2_LEFTTORIGHT, /* X - 88 */
759 C2_LEFTTORIGHT, /* Y - 89 */
760 C2_LEFTTORIGHT, /* Z - 90 */
761 C2_OTHERNEUTRAL, /* [ - 91 */
762 C2_OTHERNEUTRAL, /* \ - 92 */
763 C2_OTHERNEUTRAL, /* ] - 93 */
764 C2_OTHERNEUTRAL, /* ^ - 94 */
765 C2_OTHERNEUTRAL, /* _ - 95 */
766 C2_OTHERNEUTRAL, /* ` - 96 */
767 C2_LEFTTORIGHT, /* a - 97 */
768 C2_LEFTTORIGHT, /* b - 98 */
769 C2_LEFTTORIGHT, /* c - 99 */
770 C2_LEFTTORIGHT, /* d - 100 */
771 C2_LEFTTORIGHT, /* e - 101 */
772 C2_LEFTTORIGHT, /* f - 102 */
773 C2_LEFTTORIGHT, /* g - 103 */
774 C2_LEFTTORIGHT, /* h - 104 */
775 C2_LEFTTORIGHT, /* i - 105 */
776 C2_LEFTTORIGHT, /* j - 106 */
777 C2_LEFTTORIGHT, /* k - 107 */
778 C2_LEFTTORIGHT, /* l - 108 */
779 C2_LEFTTORIGHT, /* m - 109 */
780 C2_LEFTTORIGHT, /* n - 110 */
781 C2_LEFTTORIGHT, /* o - 111 */
782 C2_LEFTTORIGHT, /* p - 112 */
783 C2_LEFTTORIGHT, /* q - 113 */
784 C2_LEFTTORIGHT, /* r - 114 */
785 C2_LEFTTORIGHT, /* s - 115 */
786 C2_LEFTTORIGHT, /* t - 116 */
787 C2_LEFTTORIGHT, /* u - 117 */
788 C2_LEFTTORIGHT, /* v - 118 */
789 C2_LEFTTORIGHT, /* w - 119 */
790 C2_LEFTTORIGHT, /* x - 120 */
791 C2_LEFTTORIGHT, /* y - 121 */
792 C2_LEFTTORIGHT, /* z - 122 */
793 C2_OTHERNEUTRAL, /* { - 123 */
794 C2_OTHERNEUTRAL, /* | - 124 */
795 C2_OTHERNEUTRAL, /* } - 125 */
796 C2_OTHERNEUTRAL, /* ~ - 126 */
797 C2_NOTAPPLICABLE, /*
\7f - 127 */
798 C2_NOTAPPLICABLE, /*
\80 - 128 */
799 C2_NOTAPPLICABLE, /*
\81 - 129 */
800 C2_OTHERNEUTRAL, /*
\82 - 130 */
801 C2_LEFTTORIGHT, /*
\83 - 131 */
802 C2_OTHERNEUTRAL, /*
\84 - 132 */
803 C2_OTHERNEUTRAL, /*
\85 - 133 */
804 C2_OTHERNEUTRAL, /*
\86 - 134 */
805 C2_OTHERNEUTRAL, /*
\87 - 135 */
806 C2_LEFTTORIGHT, /*
\88 - 136 */
807 C2_EUROPETERMINATOR, /*
\89 - 137 */
808 C2_LEFTTORIGHT, /*
\8a - 138 */
809 C2_OTHERNEUTRAL, /*
\8b - 139 */
810 C2_LEFTTORIGHT, /*
\8c - 140 */
811 C2_NOTAPPLICABLE, /*
\8d - 141 */
812 C2_NOTAPPLICABLE, /*
\8e - 142 */
813 C2_NOTAPPLICABLE, /*
\8f - 143 */
814 C2_NOTAPPLICABLE, /*
\90 - 144 */
815 C2_OTHERNEUTRAL, /*
\91 - 145 */
816 C2_OTHERNEUTRAL, /*
\92 - 146 */
817 C2_OTHERNEUTRAL, /*
\93 - 147 */
818 C2_OTHERNEUTRAL, /*
\94 - 148 */
819 C2_OTHERNEUTRAL, /*
\95 - 149 */
820 C2_OTHERNEUTRAL, /*
\96 - 150 */
821 C2_OTHERNEUTRAL, /*
\97 - 151 */
822 C2_LEFTTORIGHT, /*
\98 - 152 */
823 C2_OTHERNEUTRAL, /*
\99 - 153 */
824 C2_LEFTTORIGHT, /*
\9a - 154 */
825 C2_OTHERNEUTRAL, /*
\9b - 155 */
826 C2_LEFTTORIGHT, /*
\9c - 156 */
827 C2_NOTAPPLICABLE, /*
\9d - 157 */
828 C2_NOTAPPLICABLE, /*
\9e - 158 */
829 C2_LEFTTORIGHT, /*
\9f - 159 */
830 C2_WHITESPACE, /* - 160 */
831 C2_OTHERNEUTRAL, /* ¡ - 161 */
832 C2_EUROPETERMINATOR, /* ¢ - 162 */
833 C2_EUROPETERMINATOR, /* £ - 163 */
834 C2_EUROPETERMINATOR, /* ¤ - 164 */
835 C2_EUROPETERMINATOR, /* ¥ - 165 */
836 C2_OTHERNEUTRAL, /* ¦ - 166 */
837 C2_OTHERNEUTRAL, /* § - 167 */
838 C2_OTHERNEUTRAL, /* ¨ - 168 */
839 C2_OTHERNEUTRAL, /* © - 169 */
840 C2_OTHERNEUTRAL, /* ª - 170 */
841 C2_OTHERNEUTRAL, /* « - 171 */
842 C2_OTHERNEUTRAL, /* ¬ - 172 */
843 C2_OTHERNEUTRAL, /* - 173 */
844 C2_OTHERNEUTRAL, /* ® - 174 */
845 C2_OTHERNEUTRAL, /* ¯ - 175 */
846 C2_EUROPETERMINATOR, /* ° - 176 */
847 C2_EUROPETERMINATOR, /* ± - 177 */
848 C2_EUROPENUMBER, /* ² - 178 */
849 C2_EUROPENUMBER, /* ³ - 179 */
850 C2_OTHERNEUTRAL, /* ´ - 180 */
851 C2_OTHERNEUTRAL, /* µ - 181 */
852 C2_OTHERNEUTRAL, /* ¶ - 182 */
853 C2_OTHERNEUTRAL, /* · - 183 */
854 C2_OTHERNEUTRAL, /* ¸ - 184 */
855 C2_EUROPENUMBER, /* ¹ - 185 */
856 C2_OTHERNEUTRAL, /* º - 186 */
857 C2_OTHERNEUTRAL, /* » - 187 */
858 C2_OTHERNEUTRAL, /* ¼ - 188 */
859 C2_OTHERNEUTRAL, /* ½ - 189 */
860 C2_OTHERNEUTRAL, /* ¾ - 190 */
861 C2_OTHERNEUTRAL, /* ¿ - 191 */
862 C2_LEFTTORIGHT, /* À - 192 */
863 C2_LEFTTORIGHT, /* Á - 193 */
864 C2_LEFTTORIGHT, /* Â - 194 */
865 C2_LEFTTORIGHT, /* Ã - 195 */
866 C2_LEFTTORIGHT, /* Ä - 196 */
867 C2_LEFTTORIGHT, /* Å - 197 */
868 C2_LEFTTORIGHT, /* Æ - 198 */
869 C2_LEFTTORIGHT, /* Ç - 199 */
870 C2_LEFTTORIGHT, /* È - 200 */
871 C2_LEFTTORIGHT, /* É - 201 */
872 C2_LEFTTORIGHT, /* Ê - 202 */
873 C2_LEFTTORIGHT, /* Ë - 203 */
874 C2_LEFTTORIGHT, /* Ì - 204 */
875 C2_LEFTTORIGHT, /* Í - 205 */
876 C2_LEFTTORIGHT, /* Î - 206 */
877 C2_LEFTTORIGHT, /* Ï - 207 */
878 C2_LEFTTORIGHT, /* Ð - 208 */
879 C2_LEFTTORIGHT, /* Ñ - 209 */
880 C2_LEFTTORIGHT, /* Ò - 210 */
881 C2_LEFTTORIGHT, /* Ó - 211 */
882 C2_LEFTTORIGHT, /* Ô - 212 */
883 C2_LEFTTORIGHT, /* Õ - 213 */
884 C2_LEFTTORIGHT, /* Ö - 214 */
885 C2_OTHERNEUTRAL, /* × - 215 */
886 C2_LEFTTORIGHT, /* Ø - 216 */
887 C2_LEFTTORIGHT, /* Ù - 217 */
888 C2_LEFTTORIGHT, /* Ú - 218 */
889 C2_LEFTTORIGHT, /* Û - 219 */
890 C2_LEFTTORIGHT, /* Ü - 220 */
891 C2_LEFTTORIGHT, /* Ý - 221 */
892 C2_LEFTTORIGHT, /* Þ - 222 */
893 C2_LEFTTORIGHT, /* ß - 223 */
894 C2_LEFTTORIGHT, /* à - 224 */
895 C2_LEFTTORIGHT, /* á - 225 */
896 C2_LEFTTORIGHT, /* â - 226 */
897 C2_LEFTTORIGHT, /* ã - 227 */
898 C2_LEFTTORIGHT, /* ä - 228 */
899 C2_LEFTTORIGHT, /* å - 229 */
900 C2_LEFTTORIGHT, /* æ - 230 */
901 C2_LEFTTORIGHT, /* ç - 231 */
902 C2_LEFTTORIGHT, /* è - 232 */
903 C2_LEFTTORIGHT, /* é - 233 */
904 C2_LEFTTORIGHT, /* ê - 234 */
905 C2_LEFTTORIGHT, /* ë - 235 */
906 C2_LEFTTORIGHT, /* ì - 236 */
907 C2_LEFTTORIGHT, /* í - 237 */
908 C2_LEFTTORIGHT, /* î - 238 */
909 C2_LEFTTORIGHT, /* ï - 239 */
910 C2_LEFTTORIGHT, /* ð - 240 */
911 C2_LEFTTORIGHT, /* ñ - 241 */
912 C2_LEFTTORIGHT, /* ò - 242 */
913 C2_LEFTTORIGHT, /* ó - 243 */
914 C2_LEFTTORIGHT, /* ô - 244 */
915 C2_LEFTTORIGHT, /* õ - 245 */
916 C2_LEFTTORIGHT, /* ö - 246 */
917 C2_OTHERNEUTRAL, /* ÷ - 247 */
918 C2_LEFTTORIGHT, /* ø - 248 */
919 C2_LEFTTORIGHT, /* ù - 249 */
920 C2_LEFTTORIGHT, /* ú - 250 */
921 C2_LEFTTORIGHT, /* û - 251 */
922 C2_LEFTTORIGHT, /* ü - 252 */
923 C2_LEFTTORIGHT, /* ý - 253 */
924 C2_LEFTTORIGHT, /* þ - 254 */
925 C2_LEFTTORIGHT /* ÿ - 255 */
928 static const WORD CT_CType3_LUT[] = {
963 0x0448, /* " - 34 */ /* " */
1000 0x8040, /* G - 71 */
1001 0x8040, /* H - 72 */
1002 0x8040, /* I - 73 */
1003 0x8040, /* J - 74 */
1004 0x8040, /* K - 75 */
1005 0x8040, /* L - 76 */
1006 0x8040, /* M - 77 */
1007 0x8040, /* N - 78 */
1008 0x8040, /* O - 79 */
1009 0x8040, /* P - 80 */
1010 0x8040, /* Q - 81 */
1011 0x8040, /* R - 82 */
1012 0x8040, /* S - 83 */
1013 0x8040, /* T - 84 */
1014 0x8040, /* U - 85 */
1015 0x8040, /* V - 86 */
1016 0x8040, /* W - 87 */
1017 0x8040, /* X - 88 */
1018 0x8040, /* Y - 89 */
1019 0x8040, /* Z - 90 */
1020 0x0048, /* [ - 91 */
1021 0x0448, /* \ - 92 */
1022 0x0048, /* ] - 93 */
1023 0x0448, /* ^ - 94 */
1024 0x0448, /* _ - 95 */
1025 0x0448, /* ` - 96 */
1026 0x8040, /* a - 97 */
1027 0x8040, /* b - 98 */
1028 0x8040, /* c - 99 */
1029 0x8040, /* d - 100 */
1030 0x8040, /* e - 101 */
1031 0x8040, /* f - 102 */
1032 0x8040, /* g - 103 */
1033 0x8040, /* h - 104 */
1034 0x8040, /* i - 105 */
1035 0x8040, /* j - 106 */
1036 0x8040, /* k - 107 */
1037 0x8040, /* l - 108 */
1038 0x8040, /* m - 109 */
1039 0x8040, /* n - 110 */
1040 0x8040, /* o - 111 */
1041 0x8040, /* p - 112 */
1042 0x8040, /* q - 113 */
1043 0x8040, /* r - 114 */
1044 0x8040, /* s - 115 */
1045 0x8040, /* t - 116 */
1046 0x8040, /* u - 117 */
1047 0x8040, /* v - 118 */
1048 0x8040, /* w - 119 */
1049 0x8040, /* x - 120 */
1050 0x8040, /* y - 121 */
1051 0x8040, /* z - 122 */
1052 0x0048, /* { - 123 */
1053 0x0048, /* | - 124 */
1054 0x0048, /* } - 125 */
1055 0x0448, /* ~ - 126 */
1056 0x0000, /*
\7f - 127 */
1057 0x0000, /*
\80 - 128 */
1058 0x0000, /*
\81 - 129 */
1059 0x0008, /*
\82 - 130 */
1060 0x8000, /*
\83 - 131 */
1061 0x0008, /*
\84 - 132 */
1062 0x0008, /*
\85 - 133 */
1063 0x0008, /*
\86 - 134 */
1064 0x0008, /*
\87 - 135 */
1065 0x0001, /*
\88 - 136 */
1066 0x0008, /*
\89 - 137 */
1067 0x8003, /*
\8a - 138 */
1068 0x0008, /*
\8b - 139 */
1069 0x8000, /*
\8c - 140 */
1070 0x0000, /*
\8d - 141 */
1071 0x0000, /*
\8e - 142 */
1072 0x0000, /*
\8f - 143 */
1073 0x0000, /*
\90 - 144 */
1074 0x0088, /*
\91 - 145 */
1075 0x0088, /*
\92 - 146 */
1076 0x0088, /*
\93 - 147 */
1077 0x0088, /*
\94 - 148 */
1078 0x0008, /*
\95 - 149 */
1079 0x0400, /*
\96 - 150 */
1080 0x0400, /*
\97 - 151 */
1081 0x0408, /*
\98 - 152 */
1082 0x0000, /*
\99 - 153 */
1083 0x8003, /*
\9a - 154 */
1084 0x0008, /*
\9b - 155 */
1085 0x8000, /*
\9c - 156 */
1086 0x0000, /*
\9d - 157 */
1087 0x0000, /*
\9e - 158 */
1088 0x8003, /*
\9f - 159 */
1090 0x0008, /* ¡ - 161 */
1091 0x0048, /* ¢ - 162 */
1092 0x0048, /* £ - 163 */
1093 0x0008, /* ¤ - 164 */
1094 0x0048, /* ¥ - 165 */
1095 0x0048, /* ¦ - 166 */
1096 0x0008, /* § - 167 */
1097 0x0408, /* ¨ - 168 */
1098 0x0008, /* © - 169 */
1099 0x0400, /* ª - 170 */
1100 0x0008, /* « - 171 */
1101 0x0048, /* ¬ - 172 */
1102 0x0408, /* - 173 */
1103 0x0008, /* ® - 174 */
1104 0x0448, /* ¯ - 175 */
1105 0x0008, /* ° - 176 */
1106 0x0008, /* ± - 177 */
1107 0x0000, /* ² - 178 */
1108 0x0000, /* ³ - 179 */
1109 0x0408, /* ´ - 180 */
1110 0x0008, /* µ - 181 */
1111 0x0008, /* ¶ - 182 */
1112 0x0008, /* · - 183 */
1113 0x0408, /* ¸ - 184 */
1114 0x0000, /* ¹ - 185 */
1115 0x0400, /* º - 186 */
1116 0x0008, /* » - 187 */
1117 0x0000, /* ¼ - 188 */
1118 0x0000, /* ½ - 189 */
1119 0x0000, /* ¾ - 190 */
1120 0x0008, /* ¿ - 191 */
1121 0x8003, /* À - 192 */
1122 0x8003, /* Á - 193 */
1123 0x8003, /* Â - 194 */
1124 0x8003, /* Ã - 195 */
1125 0x8003, /* Ä - 196 */
1126 0x8003, /* Å - 197 */
1127 0x8000, /* Æ - 198 */
1128 0x8003, /* Ç - 199 */
1129 0x8003, /* È - 200 */
1130 0x8003, /* É - 201 */
1131 0x8003, /* Ê - 202 */
1132 0x8003, /* Ë - 203 */
1133 0x8003, /* Ì - 204 */
1134 0x8003, /* Í - 205 */
1135 0x8003, /* Î - 206 */
1136 0x8003, /* Ï - 207 */
1137 0x8000, /* Ð - 208 */
1138 0x8003, /* Ñ - 209 */
1139 0x8003, /* Ò - 210 */
1140 0x8003, /* Ó - 211 */
1141 0x8003, /* Ô - 212 */
1142 0x8003, /* Õ - 213 */
1143 0x8003, /* Ö - 214 */
1144 0x0008, /* × - 215 */
1145 0x8003, /* Ø - 216 */
1146 0x8003, /* Ù - 217 */
1147 0x8003, /* Ú - 218 */
1148 0x8003, /* Û - 219 */
1149 0x8003, /* Ü - 220 */
1150 0x8003, /* Ý - 221 */
1151 0x8000, /* Þ - 222 */
1152 0x8000, /* ß - 223 */
1153 0x8003, /* à - 224 */
1154 0x8003, /* á - 225 */
1155 0x8003, /* â - 226 */
1156 0x8003, /* ã - 227 */
1157 0x8003, /* ä - 228 */
1158 0x8003, /* å - 229 */
1159 0x8000, /* æ - 230 */
1160 0x8003, /* ç - 231 */
1161 0x8003, /* è - 232 */
1162 0x8003, /* é - 233 */
1163 0x8003, /* ê - 234 */
1164 0x8003, /* ë - 235 */
1165 0x8003, /* ì - 236 */
1166 0x8003, /* í - 237 */
1167 0x8003, /* î - 238 */
1168 0x8003, /* ï - 239 */
1169 0x8000, /* ð - 240 */
1170 0x8003, /* ñ - 241 */
1171 0x8003, /* ò - 242 */
1172 0x8003, /* ó - 243 */
1173 0x8003, /* ô - 244 */
1174 0x8003, /* õ - 245 */
1175 0x8003, /* ö - 246 */
1176 0x0008, /* ÷ - 247 */
1177 0x8003, /* ø - 248 */
1178 0x8003, /* ù - 249 */
1179 0x8003, /* ú - 250 */
1180 0x8003, /* û - 251 */
1181 0x8003, /* ü - 252 */
1182 0x8003, /* ý - 253 */
1183 0x8000, /* þ - 254 */
1184 0x8003 /* ÿ - 255 */
1187 /***********************************************************************
1188 * GetStringTypeA [OLE2NLS.7]
1190 BOOL16 WINAPI GetStringType16(LCID locale,DWORD dwInfoType,LPCSTR src,
1191 INT16 cchSrc,LPWORD chartype)
1193 return GetStringTypeEx32A(locale,dwInfoType,src,cchSrc,chartype);
1195 /***********************************************************************
1196 * GetStringTypeA [KERNEL32.277]
1198 BOOL32 WINAPI GetStringType32A(LCID locale,DWORD dwInfoType,LPCSTR src,
1199 INT32 cchSrc,LPWORD chartype)
1201 return GetStringTypeEx32A(locale,dwInfoType,src,cchSrc,chartype);
1204 /***********************************************************************
1205 * GetStringTypeExA [KERNEL32.276]
1207 * FIXME: Ignores the locale.
1209 BOOL32 WINAPI GetStringTypeEx32A(LCID locale,DWORD dwInfoType,LPCSTR src,
1210 INT32 cchSrc,LPWORD chartype)
1214 if ((src==NULL) || (chartype==NULL) || (src==(LPSTR)chartype))
1216 SetLastError(ERROR_INVALID_PARAMETER);
1221 cchSrc=lstrlen32A(src)+1;
1223 switch (dwInfoType) {
1225 for (i=0;i<cchSrc;i++)
1228 if (isdigit(src[i])) chartype[i]|=C1_DIGIT;
1229 if (isalpha(src[i])) chartype[i]|=C1_ALPHA;
1230 if (islower(src[i])) chartype[i]|=C1_LOWER;
1231 if (isupper(src[i])) chartype[i]|=C1_UPPER;
1232 if (isspace(src[i])) chartype[i]|=C1_SPACE;
1233 if (ispunct(src[i])) chartype[i]|=C1_PUNCT;
1234 if (iscntrl(src[i])) chartype[i]|=C1_CNTRL;
1235 /* FIXME: isblank() is a GNU extension */
1236 /* if (isblank(src[i])) chartype[i]|=C1_BLANK; */
1237 if ((src[i] == ' ') || (src[i] == '\t')) chartype[i]|=C1_BLANK;
1243 for (i=0;i<cchSrc;i++)
1245 chartype[i]=(WORD)CT_CType2_LUT[i];
1250 for (i=0;i<cchSrc;i++)
1252 chartype[i]=CT_CType3_LUT[i];
1257 ERR(ole,"Unknown dwInfoType:%ld\n",dwInfoType);
1262 /*********************************************************************
1263 * GetStringTypeW [KERNEL32.279]
1266 * Yes, this is missing LCID locale. MS fault.
1268 BOOL32 WINAPI GetStringType32W(DWORD dwInfoType,LPCWSTR src,INT32 cchSrc,
1271 return GetStringTypeEx32W(0/*defaultlocale*/,dwInfoType,src,cchSrc,chartype);
1274 /*********************************************************************
1275 * GetStringTypeW [KERNEL32.278]
1276 * FIXME: unicode chars are assumed chars
1278 BOOL32 WINAPI GetStringTypeEx32W(LCID locale,DWORD dwInfoType,LPCWSTR src,
1279 INT32 cchSrc,LPWORD chartype)
1285 cchSrc=lstrlen32W(src)+1;
1287 switch (dwInfoType) {
1289 FIXME(ole,"CT_CTYPE2 not supported.\n");
1292 FIXME(ole,"CT_CTYPE3 not supported.\n");
1296 for (i=0;i<cchSrc;i++) {
1298 if (isdigit(src[i])) chartype[i]|=C1_DIGIT;
1299 if (isalpha(src[i])) chartype[i]|=C1_ALPHA;
1300 if (islower(src[i])) chartype[i]|=C1_LOWER;
1301 if (isupper(src[i])) chartype[i]|=C1_UPPER;
1302 if (isspace(src[i])) chartype[i]|=C1_SPACE;
1303 if (ispunct(src[i])) chartype[i]|=C1_PUNCT;
1304 if (iscntrl(src[i])) chartype[i]|=C1_CNTRL;
1305 /* FIXME: isblank() is a GNU extension */
1306 /* if (isblank(src[i])) chartype[i]|=C1_BLANK; */
1307 if ((src[i] == ' ') || (src[i] == '\t')) chartype[i]|=C1_BLANK;
1313 /*****************************************************************
1314 * VerLanguageName16 [VER.10]
1316 DWORD WINAPI VerLanguageName16(UINT16 langid,LPSTR langname,UINT16 langnamelen)
1322 TRACE(ver,"(%d,%p,%d)\n",langid,langname,langnamelen);
1323 /* First, check \System\CurrentControlSet\control\Nls\Locale\<langid>
1324 * from the registry.
1327 "\\System\\CurrentControlSet\\control\\Nls\\Locale\\%08x",
1329 result = RegQueryValue16(HKEY_LOCAL_MACHINE, buffer, langname,
1330 (LPDWORD)&langnamelen);
1331 if (result == ERROR_SUCCESS) {
1332 langname[langnamelen-1]='\0';
1335 /* if that fails, use the internal table */
1336 for (i=0;languages[i].langid!=0;i++)
1337 if (langid==languages[i].langid)
1339 strncpy(langname,languages[i].langname,langnamelen);
1340 langname[langnamelen-1]='\0';
1341 return strlen(languages[i].langname);
1344 /*****************************************************************
1345 * VerLanguageName32A [VERSION.9]
1347 DWORD WINAPI VerLanguageName32A(UINT32 langid,LPSTR langname,
1350 return VerLanguageName16(langid,langname,langnamelen);
1353 /*****************************************************************
1354 * VerLanguageName32W [VERSION.10]
1356 DWORD WINAPI VerLanguageName32W(UINT32 langid,LPWSTR langname,
1364 /* First, check \System\CurrentControlSet\control\Nls\Locale\<langid>
1365 * from the registry.
1368 "\\System\\CurrentControlSet\\control\\Nls\\Locale\\%08x",
1370 keyname = HEAP_strdupAtoW( GetProcessHeap(), 0, buffer );
1371 result = RegQueryValue32W(HKEY_LOCAL_MACHINE, keyname, langname,
1372 (LPDWORD)&langnamelen);
1373 HeapFree( GetProcessHeap(), 0, keyname );
1374 if (result != ERROR_SUCCESS) {
1375 /* if that fails, use the internal table */
1376 for (i=0;languages[i].langid!=0;i++)
1377 if (langid==languages[i].langid)
1379 lstrcpyAtoW( langname, languages[i].langname );
1380 langnamelen = strlen(languages[i].langname);
1381 /* same as strlenW(langname); */
1386 static const unsigned char LCM_Unicode_LUT[] = {
1419 7 , 28, /* ! - 33 */
1420 7 , 29, /* " - 34 */ /* " */
1421 7 , 31, /* # - 35 */
1422 7 , 33, /* $ - 36 */
1423 7 , 35, /* % - 37 */
1424 7 , 37, /* & - 38 */
1425 6 , 128, /* ' - 39 */
1426 7 , 39, /* ( - 40 */
1427 7 , 42, /* ) - 41 */
1428 7 , 45, /* * - 42 */
1430 7 , 47, /* , - 44 */
1431 6 , 130, /* - - 45 */
1432 7 , 51, /* . - 46 */
1433 7 , 53, /* / - 47 */
1434 12 , 3, /* 0 - 48 */
1435 12 , 33, /* 1 - 49 */
1436 12 , 51, /* 2 - 50 */
1437 12 , 70, /* 3 - 51 */
1438 12 , 88, /* 4 - 52 */
1439 12 , 106, /* 5 - 53 */
1440 12 , 125, /* 6 - 54 */
1441 12 , 144, /* 7 - 55 */
1442 12 , 162, /* 8 - 56 */
1443 12 , 180, /* 9 - 57 */
1444 7 , 55, /* : - 58 */
1445 7 , 58, /* ; - 59 */
1446 8 , 14, /* < - 60 */
1447 8 , 18, /* = - 61 */
1448 8 , 20, /* > - 62 */
1449 7 , 60, /* ? - 63 */
1450 7 , 62, /* @ - 64 */
1451 14 , 2, /* A - 65 */
1452 14 , 9, /* B - 66 */
1453 14 , 10, /* C - 67 */
1454 14 , 26, /* D - 68 */
1455 14 , 33, /* E - 69 */
1456 14 , 35, /* F - 70 */
1457 14 , 37, /* G - 71 */
1458 14 , 44, /* H - 72 */
1459 14 , 50, /* I - 73 */
1460 14 , 53, /* J - 74 */
1461 14 , 54, /* K - 75 */
1462 14 , 72, /* L - 76 */
1463 14 , 81, /* M - 77 */
1464 14 , 112, /* N - 78 */
1465 14 , 124, /* O - 79 */
1466 14 , 126, /* P - 80 */
1467 14 , 137, /* Q - 81 */
1468 14 , 138, /* R - 82 */
1469 14 , 145, /* S - 83 */
1470 14 , 153, /* T - 84 */
1471 14 , 159, /* U - 85 */
1472 14 , 162, /* V - 86 */
1473 14 , 164, /* W - 87 */
1474 14 , 166, /* X - 88 */
1475 14 , 167, /* Y - 89 */
1476 14 , 169, /* Z - 90 */
1477 7 , 63, /* [ - 91 */
1478 7 , 65, /* \ - 92 */
1479 7 , 66, /* ] - 93 */
1480 7 , 67, /* ^ - 94 */
1481 7 , 68, /* _ - 95 */
1482 7 , 72, /* ` - 96 */
1483 14 , 2, /* a - 97 */
1484 14 , 9, /* b - 98 */
1485 14 , 10, /* c - 99 */
1486 14 , 26, /* d - 100 */
1487 14 , 33, /* e - 101 */
1488 14 , 35, /* f - 102 */
1489 14 , 37, /* g - 103 */
1490 14 , 44, /* h - 104 */
1491 14 , 50, /* i - 105 */
1492 14 , 53, /* j - 106 */
1493 14 , 54, /* k - 107 */
1494 14 , 72, /* l - 108 */
1495 14 , 81, /* m - 109 */
1496 14 , 112, /* n - 110 */
1497 14 , 124, /* o - 111 */
1498 14 , 126, /* p - 112 */
1499 14 , 137, /* q - 113 */
1500 14 , 138, /* r - 114 */
1501 14 , 145, /* s - 115 */
1502 14 , 153, /* t - 116 */
1503 14 , 159, /* u - 117 */
1504 14 , 162, /* v - 118 */
1505 14 , 164, /* w - 119 */
1506 14 , 166, /* x - 120 */
1507 14 , 167, /* y - 121 */
1508 14 , 169, /* z - 122 */
1509 7 , 74, /* { - 123 */
1510 7 , 76, /* | - 124 */
1511 7 , 78, /* } - 125 */
1512 7 , 80, /* ~ - 126 */
1513 6 , 29, /*
\7f - 127 */
1514 6 , 30, /*
\80 - 128 */
1515 6 , 31, /*
\81 - 129 */
1516 7 , 123, /*
\82 - 130 */
1517 14 , 35, /*
\83 - 131 */
1518 7 , 127, /*
\84 - 132 */
1519 10 , 21, /*
\85 - 133 */
1520 10 , 15, /*
\86 - 134 */
1521 10 , 16, /*
\87 - 135 */
1522 7 , 67, /*
\88 - 136 */
1523 10 , 22, /*
\89 - 137 */
1524 14 , 145, /*
\8a - 138 */
1525 7 , 136, /*
\8b - 139 */
1526 14 + 16 , 124, /*
\8c - 140 */
1527 6 , 43, /*
\8d - 141 */
1528 6 , 44, /*
\8e - 142 */
1529 6 , 45, /*
\8f - 143 */
1530 6 , 46, /*
\90 - 144 */
1531 7 , 121, /*
\91 - 145 */
1532 7 , 122, /*
\92 - 146 */
1533 7 , 125, /*
\93 - 147 */
1534 7 , 126, /*
\94 - 148 */
1535 10 , 17, /*
\95 - 149 */
1536 6 , 137, /*
\96 - 150 */
1537 6 , 139, /*
\97 - 151 */
1538 7 , 93, /*
\98 - 152 */
1539 14 , 156, /*
\99 - 153 */
1540 14 , 145, /*
\9a - 154 */
1541 7 , 137, /*
\9b - 155 */
1542 14 + 16 , 124, /*
\9c - 156 */
1543 6 , 59, /*
\9d - 157 */
1544 6 , 60, /*
\9e - 158 */
1545 14 , 167, /*
\9f - 159 */
1547 7 , 81, /* ¡ - 161 */
1548 10 , 2, /* ¢ - 162 */
1549 10 , 3, /* £ - 163 */
1550 10 , 4, /* ¤ - 164 */
1551 10 , 5, /* ¥ - 165 */
1552 7 , 82, /* ¦ - 166 */
1553 10 , 6, /* § - 167 */
1554 7 , 83, /* ¨ - 168 */
1555 10 , 7, /* © - 169 */
1556 14 , 2, /* ª - 170 */
1557 8 , 24, /* « - 171 */
1558 10 , 8, /* ¬ - 172 */
1559 6 , 131, /* - 173 */
1560 10 , 9, /* ® - 174 */
1561 7 , 84, /* ¯ - 175 */
1562 10 , 10, /* ° - 176 */
1563 8 , 23, /* ± - 177 */
1564 12 , 51, /* ² - 178 */
1565 12 , 70, /* ³ - 179 */
1566 7 , 85, /* ´ - 180 */
1567 10 , 11, /* µ - 181 */
1568 10 , 12, /* ¶ - 182 */
1569 10 , 13, /* · - 183 */
1570 7 , 86, /* ¸ - 184 */
1571 12 , 33, /* ¹ - 185 */
1572 14 , 124, /* º - 186 */
1573 8 , 26, /* » - 187 */
1574 12 , 21, /* ¼ - 188 */
1575 12 , 25, /* ½ - 189 */
1576 12 , 29, /* ¾ - 190 */
1577 7 , 87, /* ¿ - 191 */
1578 14 , 2, /* À - 192 */
1579 14 , 2, /* Á - 193 */
1580 14 , 2, /* Â - 194 */
1581 14 , 2, /* Ã - 195 */
1582 14 , 2, /* Ä - 196 */
1583 14 , 2, /* Å - 197 */
1584 14 + 16 , 2, /* Æ - 198 */
1585 14 , 10, /* Ç - 199 */
1586 14 , 33, /* È - 200 */
1587 14 , 33, /* É - 201 */
1588 14 , 33, /* Ê - 202 */
1589 14 , 33, /* Ë - 203 */
1590 14 , 50, /* Ì - 204 */
1591 14 , 50, /* Í - 205 */
1592 14 , 50, /* Î - 206 */
1593 14 , 50, /* Ï - 207 */
1594 14 , 26, /* Ð - 208 */
1595 14 , 112, /* Ñ - 209 */
1596 14 , 124, /* Ò - 210 */
1597 14 , 124, /* Ó - 211 */
1598 14 , 124, /* Ô - 212 */
1599 14 , 124, /* Õ - 213 */
1600 14 , 124, /* Ö - 214 */
1601 8 , 28, /* × - 215 */
1602 14 , 124, /* Ø - 216 */
1603 14 , 159, /* Ù - 217 */
1604 14 , 159, /* Ú - 218 */
1605 14 , 159, /* Û - 219 */
1606 14 , 159, /* Ü - 220 */
1607 14 , 167, /* Ý - 221 */
1608 14 + 32 , 153, /* Þ - 222 */
1609 14 + 48 , 145, /* ß - 223 */
1610 14 , 2, /* à - 224 */
1611 14 , 2, /* á - 225 */
1612 14 , 2, /* â - 226 */
1613 14 , 2, /* ã - 227 */
1614 14 , 2, /* ä - 228 */
1615 14 , 2, /* å - 229 */
1616 14 + 16 , 2, /* æ - 230 */
1617 14 , 10, /* ç - 231 */
1618 14 , 33, /* è - 232 */
1619 14 , 33, /* é - 233 */
1620 14 , 33, /* ê - 234 */
1621 14 , 33, /* ë - 235 */
1622 14 , 50, /* ì - 236 */
1623 14 , 50, /* í - 237 */
1624 14 , 50, /* î - 238 */
1625 14 , 50, /* ï - 239 */
1626 14 , 26, /* ð - 240 */
1627 14 , 112, /* ñ - 241 */
1628 14 , 124, /* ò - 242 */
1629 14 , 124, /* ó - 243 */
1630 14 , 124, /* ô - 244 */
1631 14 , 124, /* õ - 245 */
1632 14 , 124, /* ö - 246 */
1633 8 , 29, /* ÷ - 247 */
1634 14 , 124, /* ø - 248 */
1635 14 , 159, /* ù - 249 */
1636 14 , 159, /* ú - 250 */
1637 14 , 159, /* û - 251 */
1638 14 , 159, /* ü - 252 */
1639 14 , 167, /* ý - 253 */
1640 14 + 32 , 153, /* þ - 254 */
1641 14 , 167 /* ÿ - 255 */ };
1643 static const unsigned char LCM_Unicode_LUT_2[] = { 33, 44, 145 };
1645 #define LCM_Diacritic_Start 131
1647 static const unsigned char LCM_Diacritic_LUT[] = {
1648 123, /*
\83 - 131 */
1775 static int OLE2NLS_isPunctuation(unsigned char c)
1777 /* "punctuation character" in this context is a character which is
1778 considered "less important" during word sort comparison.
1779 See LCMapString implementation for the precise definition
1780 of "less important". */
1782 return (LCM_Unicode_LUT[-2+2*c]==6);
1785 static int identity(int c)
1790 /*************************************************************************
1791 * LCMapString32A [KERNEL32.492]
1793 * Convert a string, or generate a sort key from it.
1795 * If (mapflags & LCMAP_SORTKEY), the function will generate
1796 * a sort key for the source string. Else, it will convert it
1797 * accordingly to the flags LCMAP_UPPERCASE, LCMAP_LOWERCASE,...
1801 * Success : length of the result string.
1804 * If called with scrlen = -1, the function will compute the length
1805 * of the 0-terminated string strsrc by itself.
1807 * If called with dstlen = 0, returns the buffer length that
1808 * would be required.
1810 * NORM_IGNOREWIDTH means to compare ASCII and Unicode characters
1811 * as if they are equal. Since Wine separates ASCII and Unicode into
1812 * separate functions, we shouldn't have to do anything for this flag.
1813 * I added it to the list of flags that don't need a fixme message
1814 * to make MS Word 95 not print several thousand fixme messages for
1817 INT32 WINAPI LCMapString32A(
1818 LCID lcid /* locale identifier created with MAKELCID;
1819 LOCALE_SYSTEM_DEFAULT and LOCALE_USER_DEFAULT are
1820 predefined values. */,
1821 DWORD mapflags /* flags */,
1822 LPCSTR srcstr /* source buffer */,
1823 INT32 srclen /* source length */,
1824 LPSTR dststr /* destination buffer */,
1825 INT32 dstlen /* destination buffer length */)
1829 TRACE(string,"(0x%04lx,0x%08lx,%s,%d,%p,%d)\n",
1830 lcid,mapflags,srcstr,srclen,dststr,dstlen);
1832 if ( ((dstlen!=0) && (dststr==NULL)) || (srcstr==NULL) )
1834 ERR(ole, "(src=%s,dest=%s): Invalid NULL string\n", srcstr, dststr);
1835 SetLastError(ERROR_INVALID_PARAMETER);
1839 srclen = lstrlen32A(srcstr) + 1 ; /* (include final '\0') */
1841 if (mapflags & ~ ( LCMAP_UPPERCASE | LCMAP_LOWERCASE | LCMAP_SORTKEY |
1842 NORM_IGNORECASE | NORM_IGNORENONSPACE | SORT_STRINGSORT |
1845 FIXME(string,"(0x%04lx,0x%08lx,%p,%d,%p,%d): "
1846 "unimplemented flags: 0x%08lx\n",
1847 lcid,mapflags,srcstr,srclen,dststr,dstlen,mapflags);
1850 if ( !(mapflags & LCMAP_SORTKEY) )
1852 int (*f)(int)=identity;
1855 return srclen; /* dstlen=0 means "do nothing but return required length" */
1857 srclen=dstlen; /* No, this case is not an error under Windows 95.
1858 And no '\0' gets written. */
1859 if (mapflags & LCMAP_UPPERCASE)
1861 else if (mapflags & LCMAP_LOWERCASE)
1863 for (i=0; i < srclen; i++)
1864 dststr[i] = (CHAR) f(srcstr[i]);
1868 /* else ... (mapflags & LCMAP_SORTKEY) */
1872 int diacritic_len=0;
1873 int delayed_punctuation_len=0;
1874 char *case_component;
1875 char *diacritic_component;
1876 char *delayed_punctuation_component;
1878 int flag_stringsort = mapflags & SORT_STRINGSORT;
1880 /* compute how much room we will need */
1881 for (i=0;i<srclen;i++)
1884 unsigned char source_char = srcstr[i];
1885 if (source_char!='\0')
1887 if (flag_stringsort || !OLE2NLS_isPunctuation(source_char))
1890 if ( LCM_Unicode_LUT[-2+2*source_char] & ~15 )
1891 unicode_len++; /* double letter */
1895 delayed_punctuation_len++;
1899 if (isupper(source_char))
1900 case_len=unicode_len;
1902 ofs = source_char - LCM_Diacritic_Start;
1903 if ((ofs>=0) && (LCM_Diacritic_LUT[ofs]!=2))
1904 diacritic_len=unicode_len;
1907 if (mapflags & NORM_IGNORECASE)
1909 if (mapflags & NORM_IGNORENONSPACE)
1912 room = 2 * unicode_len /* "unicode" component */
1913 + diacritic_len /* "diacritic" component */
1914 + case_len /* "case" component */
1915 + 4 * delayed_punctuation_len /* punctuation in word sort mode */
1916 + 4 /* four '\1' separators */
1917 + 1 ; /* terminal '\0' */
1920 else if (dstlen<room)
1922 SetLastError(ERROR_INSUFFICIENT_BUFFER);
1926 /*FIXME the Pointercheck should not be nessesary */
1927 if (IsBadWritePtr32 (dststr,room))
1928 { ERR (string,"bad destination buffer (dststr) : %p,%d\n",dststr,dstlen);
1929 SetLastError(ERROR_INSUFFICIENT_BUFFER);
1933 /* locate each component, write separators */
1934 diacritic_component = dststr + 2*unicode_len ;
1935 *diacritic_component++ = '\1';
1936 case_component = diacritic_component + diacritic_len ;
1937 *case_component++ = '\1';
1938 delayed_punctuation_component = case_component + case_len ;
1939 *delayed_punctuation_component++ = '\1';
1940 *delayed_punctuation_component++ = '\1';
1942 /* read source string char by char, write
1943 corresponding weight in each component. */
1944 for (i=0,count=0;i<srclen;i++)
1946 unsigned char source_char=srcstr[i];
1947 if (source_char!='\0')
1950 type = LCM_Unicode_LUT[-2+2*source_char];
1951 longcode = type >> 4;
1953 if (!flag_stringsort && OLE2NLS_isPunctuation(source_char))
1955 UINT16 encrypted_location = (1<<15) + 7 + 4*count;
1956 *delayed_punctuation_component++ = (unsigned char) (encrypted_location>>8);
1957 *delayed_punctuation_component++ = (unsigned char) (encrypted_location&255);
1958 /* big-endian is used here because it lets string comparison be
1959 compatible with numerical comparison */
1961 *delayed_punctuation_component++ = type;
1962 *delayed_punctuation_component++ = LCM_Unicode_LUT[-1+2*source_char];
1963 /* assumption : a punctuation character is never a
1964 double or accented letter */
1968 dststr[2*count] = type;
1969 dststr[2*count+1] = LCM_Unicode_LUT[-1+2*source_char];
1973 case_component[count] = ( isupper(source_char) ? 18 : 2 ) ;
1974 if (count<diacritic_len)
1975 diacritic_component[count] = 2; /* assumption: a double letter
1976 is never accented */
1979 dststr[2*count] = type;
1980 dststr[2*count+1] = *(LCM_Unicode_LUT_2 - 1 + longcode);
1981 /* 16 in the first column of LCM_Unicode_LUT --> longcode = 1
1982 32 in the first column of LCM_Unicode_LUT --> longcode = 2
1983 48 in the first column of LCM_Unicode_LUT --> longcode = 3 */
1987 case_component[count] = ( isupper(source_char) ? 18 : 2 ) ;
1988 if (count<diacritic_len)
1990 int ofs = source_char - LCM_Diacritic_Start;
1991 diacritic_component[count] = (ofs>=0 ? LCM_Diacritic_LUT[ofs] : 2);
1997 dststr[room-1] = '\0';
2002 /*************************************************************************
2003 * LCMapString32W [KERNEL32.493]
2005 * Convert a string, or generate a sort key from it.
2009 * See LCMapString32A for documentation
2011 INT32 WINAPI LCMapString32W(
2012 LCID lcid,DWORD mapflags,LPCWSTR srcstr,INT32 srclen,LPWSTR dststr,
2017 TRACE(string,"(0x%04lx,0x%08lx,%p,%d,%p,%d)\n",
2018 lcid,mapflags,srcstr,srclen,dststr,dstlen);
2020 if ( ((dstlen!=0) && (dststr==NULL)) || (srcstr==NULL) )
2022 ERR(ole, "(src=%p,dst=%p): Invalid NULL string\n", srcstr, dststr);
2023 SetLastError(ERROR_INVALID_PARAMETER);
2027 srclen = lstrlen32W(srcstr)+1;
2028 if (mapflags & LCMAP_SORTKEY)
2030 FIXME(string,"(0x%04lx,0x%08lx,%p,%d,%p,%d): "
2031 "unimplemented flags: 0x%08lx\n",
2032 lcid,mapflags,srcstr,srclen,dststr,dstlen,mapflags);
2037 int (*f)(int)=identity;
2043 if (mapflags & LCMAP_UPPERCASE)
2045 else if (mapflags & LCMAP_LOWERCASE)
2047 for (i=0; i < srclen; i++)
2048 dststr[i] = (WCHAR) f(srcstr[i]);
2053 /***********************************************************************
2054 * CompareString16 (OLE2NLS.8)
2056 UINT16 WINAPI CompareString16(DWORD lcid,DWORD fdwStyle,
2057 LPCSTR s1,DWORD l1,LPCSTR s2,DWORD l2)
2059 return (UINT16)CompareString32A(lcid,fdwStyle,s1,l1,s2,l2);
2062 /***********************************************************************
2063 * CompareString32A [KERNEL32.29] Compares two strings using locale
2067 * success: CSTR_LESS_THAN, CSTR_EQUAL, CSTR_GREATER_THAN
2072 * Defaults to a word sort, but uses a string sort if
2073 * SORT_STRINGSORT is set.
2074 * Calls SetLastError for ERROR_INVALID_FLAGS, ERROR_INVALID_PARAMETER.
2078 * This implementation ignores the locale
2082 * Quite inefficient.
2084 UINT32 WINAPI CompareString32A(
2085 DWORD lcid, /* locale ID */
2086 DWORD fdwStyle, /* comparison-style options */
2087 LPCSTR s1, /* first string */
2088 DWORD l1, /* length of first string */
2089 LPCSTR s2, /* second string */
2090 DWORD l2) /* length of second string */
2092 int mapstring_flags;
2096 TRACE(ole,"%s and %s\n",
2097 debugstr_a (s1), debugstr_a (s2));
2099 if ( (s1==NULL) || (s2==NULL) )
2101 ERR(ole, "(s1=%s,s2=%s): Invalid NULL string\n", s1, s2);
2102 SetLastError(ERROR_INVALID_PARAMETER);
2106 if(fdwStyle & NORM_IGNORESYMBOLS)
2107 FIXME(ole, "IGNORESYMBOLS not supported\n");
2109 mapstring_flags = LCMAP_SORTKEY | fdwStyle ;
2110 len1 = LCMapString32A(lcid,mapstring_flags,s1,l1,NULL,0);
2111 len2 = LCMapString32A(lcid,mapstring_flags,s2,l2,NULL,0);
2113 if ((len1==0)||(len2==0))
2114 return 0; /* something wrong happened */
2116 sk1 = (LPSTR)HeapAlloc(GetProcessHeap(),0,len1);
2117 sk2 = (LPSTR)HeapAlloc(GetProcessHeap(),0,len2);
2118 if ( (!LCMapString32A(lcid,mapstring_flags,s1,l1,sk1,len1))
2119 || (!LCMapString32A(lcid,mapstring_flags,s2,l2,sk2,len2)) )
2121 ERR(ole,"Bug in LCmapString32A.\n");
2126 /* strcmp doesn't necessarily return -1, 0, or 1 */
2127 result = strcmp(sk1,sk2);
2129 HeapFree(GetProcessHeap(),0,sk1);
2130 HeapFree(GetProcessHeap(),0,sk2);
2137 /* must be greater, if we reach this point */
2141 /***********************************************************************
2142 * CompareString32W (KERNEL32.30)
2143 * This implementation ignores the locale
2144 * FIXME : Does only string sort. Should
2145 * be reimplemented the same way as CompareString32A.
2147 UINT32 WINAPI CompareString32W(DWORD lcid, DWORD fdwStyle,
2148 LPCWSTR s1, DWORD l1, LPCWSTR s2,DWORD l2)
2151 if(fdwStyle & NORM_IGNORENONSPACE)
2152 FIXME(ole,"IGNORENONSPACE not supprted\n");
2153 if(fdwStyle & NORM_IGNORESYMBOLS)
2154 FIXME(ole,"IGNORESYMBOLS not supported\n");
2156 /* Is strcmp defaulting to string sort or to word sort?? */
2157 /* FIXME: Handle NORM_STRINGSORT */
2158 l1 = (l1==-1)?lstrlen32W(s1):l1;
2159 l2 = (l2==-1)?lstrlen32W(s2):l2;
2160 len = l1<l2 ? l1:l2;
2161 ret = (fdwStyle & NORM_IGNORECASE) ?
2162 lstrncmpi32W(s1,s2,len) : lstrncmp32W(s1,s2,len);
2163 /* not equal, return 1 or 3 */
2164 if(ret!=0) return ret+2;
2165 /* same len, return 2 */
2166 if(l1==l2) return 2;
2167 /* the longer one is lexically greater */
2168 return (l1<l2)? 1 : 3;
2171 /*****************************************************************
2173 * OLE_GetFormatA() [internal]
2176 This function implements stuff for GetDateFormat() and
2179 d single-digit (no leading zero) day (of month)
2180 dd two-digit day (of month)
2181 ddd short day-of-week name
2182 dddd long day-of-week name
2183 M single-digit month
2185 MMM short month name
2186 MMMM full month name
2187 y two-digit year, no leading 0
2189 yyyy four-digit year
2191 h hours with no leading zero (12-hour)
2192 hh hours with full two digits
2193 H hours with no leading zero (24-hour)
2194 HH hours with full two digits
2195 m minutes with no leading zero
2196 mm minutes with full two digits
2197 s seconds with no leading zero
2198 ss seconds with full two digits
2199 t time marker (A or P)
2200 tt time marker (AM, PM)
2201 '' used to quote literal characters
2202 '' (within a quoted string) indicates a literal '
2204 These functions REQUIRE valid locale, date, and format.
2208 INT32 WINAPI OLE_GetFormatA(LCID locale,
2213 LPSTR date, INT32 datelen)
2215 INT32 inpos, outpos;
2216 int count, type, inquote, Overflow;
2222 const char * _dgfmt[] = { "%d", "%02d" };
2223 const char ** dgfmt = _dgfmt - 1;
2225 /* report, for debugging */
2226 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",
2227 locale, flags, tflags,
2228 xtime->wDay, xtime->wHour, xtime->wMinute, xtime->wSecond,
2229 format, format, date, date, datelen);
2231 /* initalize state variables and output buffer */
2233 count = 0; inquote = 0; Overflow = 0;
2235 date[0] = buf[0] = '\0';
2237 strcpy(format,_format);
2239 /* alter the formatstring, while it works for all languages now in wine
2240 its possible that it fails when the time looks like ss:mm:hh as example*/
2241 if (tflags & (TIME_NOMINUTESORSECONDS))
2242 { if ((pos = strstr ( format, ":mm")))
2243 { memcpy ( pos, pos+3, strlen(format)-(pos-format)-2 );
2246 if (tflags & (TIME_NOSECONDS))
2247 { if ((pos = strstr ( format, ":ss")))
2248 { memcpy ( pos, pos+3, strlen(format)-(pos-format)-2 );
2252 for (inpos = 0;; inpos++) {
2253 /* 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]); */
2255 if (format[inpos] == '\'') {
2256 if (format[inpos+1] == '\'') {
2258 date[outpos++] = '\'';
2261 continue; /* we did nothing to the output */
2263 } else if (format[inpos] == '\0') {
2264 date[outpos++] = '\0';
2265 if (outpos > datelen) Overflow = 1;
2268 date[outpos++] = format[inpos];
2269 if (outpos > datelen) {
2271 date[outpos-1] = '\0'; /* this is the last place where
2272 it's safe to write */
2276 } else if ( (count && (format[inpos] != type))
2278 || (count == 2 && strchr("ghHmst", type)) )
2282 GetLocaleInfo32A(locale,
2284 + xtime->wDayOfWeek - 1,
2286 } else if (count == 3) {
2287 GetLocaleInfo32A(locale,
2288 LOCALE_SABBREVDAYNAME1
2289 + xtime->wDayOfWeek - 1,
2292 sprintf(buf, dgfmt[count], xtime->wDay);
2294 } else if (type == 'M') {
2296 GetLocaleInfo32A(locale,
2297 LOCALE_SABBREVMONTHNAME1
2298 + xtime->wMonth - 1,
2300 } else if (count == 4) {
2301 GetLocaleInfo32A(locale,
2303 + xtime->wMonth - 1,
2306 sprintf(buf, dgfmt[count], xtime->wMonth);
2308 } else if (type == 'y') {
2310 sprintf(buf, "%d", xtime->wYear);
2311 } else if (count == 3) {
2313 WARN(ole, "unknown format, c=%c, n=%d\n", type, count);
2315 sprintf(buf, dgfmt[count], xtime->wYear % 100);
2317 } else if (type == 'g') {
2319 FIXME(ole, "LOCALE_ICALENDARTYPE unimp.\n");
2323 WARN(ole, "unknown format, c=%c, n=%d\n", type, count);
2325 } else if (type == 'h') {
2326 /* gives us hours 1:00 -- 12:00 */
2327 sprintf(buf, dgfmt[count], (xtime->wHour-1)%12 +1);
2328 } else if (type == 'H') {
2330 sprintf(buf, dgfmt[count], xtime->wHour);
2331 } else if ( type == 'm') {
2332 sprintf(buf, dgfmt[count], xtime->wMinute);
2333 } else if ( type == 's') {
2334 sprintf(buf, dgfmt[count], xtime->wSecond);
2335 } else if (type == 't') {
2337 sprintf(buf, "%c", (xtime->wHour < 12) ? 'A' : 'P');
2338 } else if (count == 2) {
2339 /* sprintf(buf, "%s", (xtime->wHour < 12) ? "AM" : "PM"); */
2340 GetLocaleInfo32A(locale,
2342 ? LOCALE_S1159 : LOCALE_S2359,
2347 /* we need to check the next char in the format string
2348 again, no matter what happened */
2351 /* add the contents of buf to the output */
2352 buflen = strlen(buf);
2353 if (outpos + buflen < datelen) {
2354 date[outpos] = '\0'; /* for strcat to hook onto */
2358 date[outpos] = '\0';
2359 strncat(date, buf, datelen - outpos);
2360 date[datelen - 1] = '\0';
2361 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2362 WARN(ole, "insufficient buffer\n");
2366 /* reset the variables we used to keep track of this item */
2369 } else if (format[inpos] == '\0') {
2370 /* we can't check for this at the loop-head, because
2371 that breaks the printing of the last format-item */
2372 date[outpos] = '\0';
2375 /* continuing a code for an item */
2378 } else if (strchr("hHmstyMdg", format[inpos])) {
2379 type = format[inpos];
2382 } else if (format[inpos] == '\'') {
2386 date[outpos++] = format[inpos];
2388 /* now deal with a possible buffer overflow */
2389 if (outpos >= datelen) {
2390 date[datelen - 1] = '\0';
2391 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2397 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2400 /* finish it off with a string terminator */
2403 if (outpos > datelen-1) outpos = datelen-1;
2404 date[outpos] = '\0';
2406 TRACE(ole, "OLE_GetFormatA returns string '%s', len %d\n",
2411 /**************************************************************
2412 * OLE_GetFormatW [internal]
2414 INT32 WINAPI OLE_GetFormatW(LCID locale, DWORD flags, DWORD tflags,
2417 LPWSTR output, INT32 outlen)
2419 INT32 inpos, outpos;
2420 int count, type=0, inquote;
2421 int Overflow; /* loop check */
2422 int usedate, usetime;
2426 WCHAR arg0[] = {0}, arg1[] = {'%','d',0};
2427 WCHAR arg2[] = {'%','0','2','d',0};
2428 WCHAR *argarr[] = {arg0, arg1, arg2};
2429 int datevars=0, timevars=0;
2431 /* make a debug report */
2432 lstrcpynWtoA(abuf, format, sizeof(format));
2433 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",
2434 locale, flags, tflags,
2435 xtime->wDay, xtime->wHour, xtime->wMinute, xtime->wSecond,
2436 abuf, format, output, outlen);
2439 /* initialize state variables */
2442 inquote = Overflow = 0;
2443 /* this is really just a sanity check */
2444 output[0] = buf[0] = 0;
2446 /* for compatibility with official Windows behavior */
2447 usedate = flags & DATE_DATEVARSONLY;
2448 usetime = flags & TIME_TIMEVARSONLY;
2450 /* this loop is the core of the function */
2451 for (inpos = 0; /* we have several break points */ ; inpos++) {
2453 if (format[inpos] == (WCHAR) '\'') {
2454 if (format[inpos+1] == '\'') {
2456 output[outpos++] = '\'';
2461 } else if (format[inpos] == 0) {
2462 output[outpos++] = 0;
2463 if (outpos > outlen) Overflow = 1;
2464 break; /* normal exit (within a quote) */
2466 output[outpos++] = format[inpos]; /* copy input */
2467 if (outpos > outlen) {
2469 output[outpos-1] = 0;
2473 } else if ( (count && (format[inpos] != type))
2474 || ( (count==4 && type =='y') ||
2475 (count==4 && type =='M') ||
2476 (count==4 && type =='d') ||
2477 (count==2 && type =='g') ||
2478 (count==2 && type =='h') ||
2479 (count==2 && type =='H') ||
2480 (count==2 && type =='m') ||
2481 (count==2 && type =='s') ||
2482 (count==2 && type =='t') ) ) {
2485 GetLocaleInfo32W(locale,
2486 LOCALE_SDAYNAME1 + xtime->wDayOfWeek -1,
2487 buf, sizeof(buf)/sizeof(WCHAR) );
2488 } else if (count == 3) {
2489 GetLocaleInfo32W(locale,
2490 LOCALE_SABBREVDAYNAME1 +
2491 xtime->wDayOfWeek -1,
2492 buf, sizeof(buf)/sizeof(WCHAR) );
2494 wsnprintf32W(buf, 5, argarr[count], xtime->wDay );
2496 } else if (type == 'M') {
2498 GetLocaleInfo32W(locale, LOCALE_SMONTHNAME1 +
2499 xtime->wMonth -1, buf,
2500 sizeof(buf)/sizeof(WCHAR) );
2501 } else if (count == 3) {
2502 GetLocaleInfo32W(locale, LOCALE_SABBREVMONTHNAME1 +
2503 xtime->wMonth -1, buf,
2504 sizeof(buf)/sizeof(WCHAR) );
2506 wsnprintf32W(buf, 5, argarr[count], xtime->wMonth);
2508 } else if (type == 'y') {
2510 wsnprintf32W(buf, 6, argarr[1] /* "%d" */,
2512 } else if (count == 3) {
2513 lstrcpynAtoW(buf, "yyy", 5);
2515 wsnprintf32W(buf, 6, argarr[count],
2516 xtime->wYear % 100);
2518 } else if (type == 'g') {
2520 FIXME(ole, "LOCALE_ICALENDARTYPE unimplemented\n");
2521 lstrcpynAtoW(buf, "AD", 5);
2523 /* Win API sez we copy it verbatim */
2524 lstrcpynAtoW(buf, "g", 5);
2526 } else if (type == 'h') {
2527 /* hours 1:00-12:00 --- is this right? */
2528 wsnprintf32W(buf, 5, argarr[count],
2529 (xtime->wHour-1)%12 +1);
2530 } else if (type == 'H') {
2531 wsnprintf32W(buf, 5, argarr[count],
2533 } else if (type == 'm' ) {
2534 wsnprintf32W(buf, 5, argarr[count],
2536 } else if (type == 's' ) {
2537 wsnprintf32W(buf, 5, argarr[count],
2539 } else if (type == 't') {
2540 GetLocaleInfo32W(locale, (xtime->wHour < 12) ?
2541 LOCALE_S1159 : LOCALE_S2359,
2548 /* no matter what happened, we need to check this next
2549 character the next time we loop through */
2552 /* cat buf onto the output */
2553 outlen = lstrlen32W(buf);
2554 if (outpos + buflen < outlen) {
2555 output[outpos] = 0; /* a "hook" for strcat */
2556 lstrcat32W(output, buf);
2560 lstrcatn32W(output, buf, outlen - outpos);
2561 output[outlen - 1] = 0;
2563 break; /* Abnormal exit */
2566 /* reset the variables we used this time */
2569 } else if (format[inpos] == 0) {
2570 /* we can't check for this at the beginning, because that
2571 would keep us from printing a format spec that ended the
2574 break; /* NORMAL EXIT */
2576 /* how we keep track of the middle of a format spec */
2579 } else if ( (datevars && (format[inpos]=='d' ||
2580 format[inpos]=='M' ||
2581 format[inpos]=='y' ||
2582 format[inpos]=='g') ) ||
2583 (timevars && (format[inpos]=='H' ||
2584 format[inpos]=='h' ||
2585 format[inpos]=='m' ||
2586 format[inpos]=='s' ||
2587 format[inpos]=='t') ) ) {
2588 type = format[inpos];
2591 } else if (format[inpos] == '\'') {
2595 /* unquoted literals */
2596 output[outpos++] = format[inpos];
2601 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2602 WARN(ole, " buffer overflow\n");
2605 /* final string terminator and sanity check */
2607 if (outpos > outlen-1) outpos = outlen-1;
2608 output[outpos] = '0';
2610 lstrcpynWtoA(abuf, output, sizeof(abuf) );
2611 TRACE(ole, " returning string \'%s\'\n", abuf);
2613 return (!Overflow) ? outlen : 0;
2618 /*****************************************************************
2619 * GetDateFormat32A() [KERNEL32.310] Makes an ASCII string of the date
2621 * This function uses format to format the date, or, if format
2622 * is NULL, uses the default for the locale. format is a string
2623 * of literal fields and characters as follows:
2625 * - d single-digit (no leading zero) day (of month)
2626 * - dd two-digit day (of month)
2627 * - ddd short day-of-week name
2628 * - dddd long day-of-week name
2629 * - M single-digit month
2630 * - MM two-digit month
2631 * - MMM short month name
2632 * - MMMM full month name
2633 * - y two-digit year, no leading 0
2634 * - yy two-digit year
2635 * - yyyy four-digit year
2640 INT32 WINAPI GetDateFormat32A(LCID locale,DWORD flags,
2642 LPCSTR format, LPSTR date,INT32 datelen)
2645 char format_buf[40];
2648 LPSYSTEMTIME thistime;
2653 TRACE(ole,"(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",
2654 locale,flags,xtime,format,date,datelen);
2657 locale = LOCALE_SYSTEM_DEFAULT;
2660 if (locale == LOCALE_SYSTEM_DEFAULT) {
2661 thislocale = GetSystemDefaultLCID();
2662 } else if (locale == LOCALE_USER_DEFAULT) {
2663 thislocale = GetUserDefaultLCID();
2665 thislocale = locale;
2668 if (xtime == NULL) {
2675 if (format == NULL) {
2676 GetLocaleInfo32A(thislocale, ((flags&DATE_LONGDATE)
2678 : LOCALE_SSHORTDATE),
2679 format_buf, sizeof(format_buf));
2680 thisformat = format_buf;
2682 thisformat = format;
2686 ret = OLE_GetFormatA(thislocale, flags, 0, thistime, thisformat,
2691 "GetDateFormat32A() returning %d, with data=%s\n",
2696 /* ****************************************************************
2697 * GetDateFormat32W() [KERNEL32.311] Makes a Unicode string of the date
2699 * Acts the same as GetDateFormat32A(), except that it's Unicode.
2700 * Accepts & returns sizes as counts of Unicode characters.
2703 INT32 WINAPI GetDateFormat32W(LCID locale,DWORD flags,
2706 LPWSTR date, INT32 datelen)
2708 short datearr[] = {'1','9','9','4','-','1','-','1',0};
2710 FIXME(ole, "STUB (should call OLE_GetFormatW)\n");
2711 lstrcpyn32W(date, datearr, datelen);
2712 return ( datelen < 9) ? datelen : 9;
2717 /**************************************************************************
2718 * EnumDateFormats32A (KERNEL32.198)
2720 BOOL32 WINAPI EnumDateFormats32A(
2721 DATEFMT_ENUMPROC32A lpDateFmtEnumProc, LCID Locale, DWORD dwFlags)
2723 FIXME(ole, "Only US English supported\n");
2725 if(!lpDateFmtEnumProc)
2727 SetLastError(ERROR_INVALID_PARAMETER);
2733 case DATE_SHORTDATE:
2734 if(!(*lpDateFmtEnumProc)("M/d/yy")) return TRUE;
2735 if(!(*lpDateFmtEnumProc)("M/d/yyyy")) return TRUE;
2736 if(!(*lpDateFmtEnumProc)("MM/dd/yy")) return TRUE;
2737 if(!(*lpDateFmtEnumProc)("MM/dd/yyyy")) return TRUE;
2738 if(!(*lpDateFmtEnumProc)("yy/MM/dd")) return TRUE;
2739 if(!(*lpDateFmtEnumProc)("dd-MMM-yy")) return TRUE;
2742 if(!(*lpDateFmtEnumProc)("dddd, MMMM dd, yyyy")) return TRUE;
2743 if(!(*lpDateFmtEnumProc)("MMMM dd, yyyy")) return TRUE;
2744 if(!(*lpDateFmtEnumProc)("dddd, dd MMMM, yyyy")) return TRUE;
2745 if(!(*lpDateFmtEnumProc)("dd MMMM, yyyy")) return TRUE;
2748 FIXME(ole, "Unknown date format (%ld)\n", dwFlags);
2749 SetLastError(ERROR_INVALID_PARAMETER);
2754 /**************************************************************************
2755 * EnumDateFormats32W (KERNEL32.199)
2757 BOOL32 WINAPI EnumDateFormats32W(
2758 DATEFMT_ENUMPROC32W lpDateFmtEnumProc, LCID Locale, DWORD dwFlags)
2760 FIXME(ole, "(%p, %ld, %ld): stub\n", lpDateFmtEnumProc, Locale, dwFlags);
2761 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
2765 /**************************************************************************
2766 * EnumTimeFormats32A (KERNEL32.210)
2768 BOOL32 WINAPI EnumTimeFormats32A(
2769 TIMEFMT_ENUMPROC32A lpTimeFmtEnumProc, LCID Locale, DWORD dwFlags)
2771 FIXME(ole, "Only US English supported\n");
2773 if(!lpTimeFmtEnumProc)
2775 SetLastError(ERROR_INVALID_PARAMETER);
2781 FIXME(ole, "Unknown time format (%ld)\n", dwFlags);
2784 if(!(*lpTimeFmtEnumProc)("h:mm:ss tt")) return TRUE;
2785 if(!(*lpTimeFmtEnumProc)("hh:mm:ss tt")) return TRUE;
2786 if(!(*lpTimeFmtEnumProc)("H:mm:ss")) return TRUE;
2787 if(!(*lpTimeFmtEnumProc)("HH:mm:ss")) return TRUE;
2792 /**************************************************************************
2793 * EnumTimeFormats32W (KERNEL32.211)
2795 BOOL32 WINAPI EnumTimeFormats32W(
2796 TIMEFMT_ENUMPROC32W lpTimeFmtEnumProc, LCID Locale, DWORD dwFlags)
2798 FIXME(ole, "(%p,%ld,%ld): stub", lpTimeFmtEnumProc, Locale, dwFlags);
2799 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
2803 /**************************************************************************
2804 * GetNumberFormat32A (KERNEL32.355)
2805 * NOTE: type of lpFormat should be CONST NUMBERFORMAT
2807 INT32 WINAPI GetNumberFormat32A(LCID locale, DWORD dwflags,
2808 LPCSTR lpvalue, char *lpFormat,
2809 LPSTR lpNumberStr, int cchNumber)
2813 FIXME(file,"%s: stub, no reformating done\n",lpvalue);
2815 n = strlen(lpvalue);
2817 strncpy(lpNumberStr,lpvalue,cchNumber);
2818 if (cchNumber <= n) {
2819 lpNumberStr[cchNumber-1] = 0;
2828 /*****************************************************************
2830 * GetTimeFormat32A() [KERNEL32.422] Makes an ASCII string of the time
2832 * Formats date according to format, or locale default if format is
2833 * NULL. The format consists of literal characters and fields as follows:
2835 * h hours with no leading zero (12-hour)
2836 * hh hours with full two digits
2837 * H hours with no leading zero (24-hour)
2838 * HH hours with full two digits
2839 * m minutes with no leading zero
2840 * mm minutes with full two digits
2841 * s seconds with no leading zero
2842 * ss seconds with full two digits
2843 * t time marker (A or P)
2844 * tt time marker (AM, PM)
2849 GetTimeFormat32A(LCID locale, /* in */
2850 DWORD flags, /* in */
2851 LPSYSTEMTIME xtime, /* in */
2852 LPCSTR format, /* in */
2853 LPSTR timestr, /* out */
2854 INT32 timelen /* in */)
2855 { char format_buf[40];
2858 LPSYSTEMTIME thistime;
2860 DWORD thisflags=LOCALE_STIMEFORMAT; /* standart timeformat */;
2862 TRACE(ole,"GetTimeFormat(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",locale,flags,xtime,format,timestr,timelen);
2865 { locale = LOCALE_SYSTEM_DEFAULT;
2868 if (locale == LOCALE_SYSTEM_DEFAULT)
2869 { thislocale = GetSystemDefaultLCID();
2871 else if (locale == LOCALE_USER_DEFAULT)
2872 { thislocale = GetUserDefaultLCID();
2875 { thislocale = locale;
2878 if ( flags & (TIME_NOTIMEMARKER | TIME_FORCE24HOURFORMAT ))
2879 { FIXME(ole,"TIME_NOTIMEMARKER or TIME_FORCE24HOURFORMAT not implemented\n");
2881 flags &= (TIME_NOSECONDS | TIME_NOMINUTESORSECONDS); /* mask for OLE_GetFormatA*/
2884 { if (flags & LOCALE_NOUSEROVERRIDE) /*use system default*/
2885 { thislocale = GetSystemDefaultLCID();
2887 GetLocaleInfo32A(thislocale, thisflags, format_buf, sizeof(format_buf));
2888 thisformat = format_buf;
2891 { thisformat = format;
2894 if (xtime == NULL) /* NULL means use the current local time*/
2895 { GetSystemTime(&t);
2901 return OLE_GetFormatA(thislocale, thisflags, flags, thistime, thisformat, timestr, timelen);
2905 /* ****************************************************************
2906 * GetTimeFormat32W() [KERNEL32.423] Makes a Unicode string of the time
2912 GetTimeFormat32W(LCID locale,DWORD flags,
2915 LPWSTR timestr,INT32 timelen)
2919 LPCWSTR realformat=0;
2921 LPSYSTEMTIME realtime;
2922 WCHAR * fmt_buf = NULL;
2923 int fmt_buf_size = 0; /* units of WCHARs */
2926 lstrcpynWtoA(debugbuf, format, (sizeof(buf))/2);
2927 TRACE(ole, "GetTimeFormatW len %d flags 0x%lX format >%s<\n",
2928 timelen, flags, debugbuf);
2930 /* Enforce the Windows behavior */
2931 flags |= ~LOCALE_TIMEDATEBOTH;
2932 flags |= TIME_TIMEVARSONLY;
2934 /* take care of the format or locale not being given */
2936 realformat = format;
2937 } else if (locale) {
2938 /* allocate memory */
2939 retval = ERROR_INSUFFICIENT_BUFFER;
2940 fmt_buf = malloc((fmt_buf_size+=7) * sizeof(WCHAR));
2944 while(!GetLocaleInfo32W(locale, LOCALE_STIMEFORMAT,
2945 fmt_buf, fmt_buf_size)) {
2946 retval = ERROR_OUTOFMEMORY;
2947 fmt_buf = realloc(fmt_buf,
2948 (fmt_buf_size += 10) * sizeof(WCHAR));
2952 realformat = fmt_buf;
2954 FIXME(ole, "caller gave no locale, no format; what should we do?\n");
2955 SetLastError(ERROR_BAD_FORMAT);
2958 locale = GetSystemDefaultLCID();
2963 GetSystemTime(realtime);
2966 retval = OLE_GetFormatW(locale, flags, 0, realtime, realformat, timestr, timelen);
2972 SetLastError(retval);
2973 WARN(ole, "could not allocate %d chars of memory\n", fmt_buf_size);