4 * Copyright 1995 Martin von Loewis
5 * Copyright 1998 David Lee Lambert
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.
25 #define LOCALE_ENTRY(x) {#x,LOCALE_##x}
26 static struct tagLOCALE_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),
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),
131 LOCALE_ENTRY(SISO639LANGNAME),
132 LOCALE_ENTRY(SISO3166CTRYNAME),
136 const struct map_lcid2str {
138 const char *langname;
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"},
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)"},
165 {0x0407,"German (Germany)"},
166 {0x0807,"German (Switzerland)"},
167 {0x0c07,"German (Austria)"},
168 {0x1007,"German (Luxembourg)"},
169 {0x1407,"German (Liechtenstein)"},
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)"},
205 {0x040c,"French (France)"},
206 {0x080c,"French (Belgium)"},
207 {0x0c0c,"French (Canada)"},
208 {0x100c,"French (Switzerland)"},
209 {0x140c,"French (Luxembourg)"},
210 {0x180c,"French (Monaco)"},
212 {0x040e,"Hungarian"},
213 {0x040f,"Icelandic"},
214 {0x0410,"Italian (Italy)"},
215 {0x0810,"Italian (Switzerland)"},
217 {0x0412,"Korean (Wansung)"},
218 {0x0812,"Korean (Johab)"},
219 {0x0413,"Dutch (Netherlands)"},
220 {0x0813,"Dutch (Belgium)"},
221 {0x0414,"Norwegian (Bokmal)"},
222 {0x0814,"Norwegian (Nynorsk)"},
224 {0x0416,"Portuguese (Brazil)"},
225 {0x0816,"Portuguese (Portugal)"},
226 {0x0417,"Rhaeto Romanic"},
228 {0x0818,"Moldavian"},
229 {0x0419,"Russian (Russia)"},
230 {0x0819,"Russian (Moldavia)"},
232 {0x081a,"Serbian (latin)"},
233 {0x0c1a,"Serbian (cyrillic)"},
236 {0x041d,"Swedish (Sweden)"},
237 {0x081d,"Swedish (Finland)"},
241 {0x0421,"Indonesian"},
242 {0x0422,"Ukrainian"},
243 {0x0423,"Belarusian"},
247 {0x0427,"Lithuanian (modern)"},
248 {0x0827,"Lithuanian (classic)"},
251 {0x042a,"Vietnamese"},
253 {0x042c,"Azeri (latin)"},
254 {0x082c,"Azeri (cyrillic)"},
257 {0x042f,"Macedonian"},
264 {0x0436,"Afrikaans"},
270 {0x043c,"Irish gaelic"},
271 {0x083c,"Scottish gaelic"},
272 {0x043e,"Malay (Malaysia)"},
273 {0x083e,"Malay (Brunei Darussalam)"},
276 {0x0443,"Uzbek (latin)"},
277 {0x0843,"Uzbek (cyrillic)"},
286 {0x044c,"Malayalam"},
291 {0x048f,"Esperanto"}, /* Non official */
295 {0x0402,"Bulgarisch"},
296 {0x0403,"Katalanisch"},
297 {0x0404,"Traditionales Chinesisch"},
298 {0x0405,"Tschecisch"},
301 {0x0408,"Griechisch"},
302 {0x0409,"Amerikanisches Englisch"},
303 {0x040A,"Kastilisches Spanisch"},
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"},
315 {0x0416,"Brasilianisches Portugiesisch"},
316 {0x0417,"Rdtoromanisch"},
317 {0x0418,"Rumdnisch"},
319 {0x041A,"Kroatoserbisch (lateinisch)"},
320 {0x041B,"Slowenisch"},
321 {0x041C,"Albanisch"},
322 {0x041D,"Schwedisch"},
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()
364 char *lang,*country,*charset,*dialect,*next;
367 if (Options.language) return Languages[Options.language].langid;
369 buf=getenv("LANGUAGE");
370 if (!buf) buf=getenv("LANG");
371 if (!buf) buf=getenv("LC_ALL");
372 if (!buf) buf=getenv("LC_MESSAGES");
373 if (!buf) return MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT );
375 if (!strcmp(buf,"POSIX") || !strcmp(buf,"C")) {
377 return MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT );
383 next=strchr(lang,':'); if (next) *next++='\0';
384 dialect=strchr(lang,'@'); if (dialect) *dialect++='\0';
385 charset=strchr(lang,'.'); if (charset) *charset++='\0';
386 country=strchr(lang,'_'); if (country) *country++='\0';
388 ret=MAIN_GetLanguageID(lang, country, charset, dialect);
392 } while (lang && !ret);
398 /***********************************************************************
399 * GetSystemDefaultLangID (OLE2NLS.4)
401 LANGID WINAPI GetSystemDefaultLangID()
403 return GetUserDefaultLangID();
406 /******************************************************************************
407 * GetLocaleInfo16 [OLE2NLS.5]
408 * Is the last parameter really WORD for Win16?
410 INT16 WINAPI GetLocaleInfo16(LCID lcid,LCTYPE LCType,LPSTR buf,INT16 len)
412 return GetLocaleInfo32A(lcid,LCType,buf,len);
415 /******************************************************************************
416 * GetLocaleInfo32A [KERNEL32.342]
418 INT32 WINAPI GetLocaleInfo32A(LCID lcid,LCTYPE LCType,LPSTR buf,INT32 len)
424 TRACE(ole,"(lcid=0x%lx,lctype=0x%lx,%p,%x)\n",
425 lcid,LCType,buf,len);
428 { SetLastError(ERROR_INSUFFICIENT_BUFFER);
432 if (lcid == LOCALE_SYSTEM_DEFAULT || (LCType & LOCALE_NOUSEROVERRIDE) )
433 { lcid = GetSystemDefaultLCID();
435 else if (lcid == LOCALE_USER_DEFAULT)
436 { lcid = GetUserDefaultLCID();
439 LCType &= ~(LOCALE_NOUSEROVERRIDE|LOCALE_USE_CP_ACP);
441 /* As an option, we could obtain the value from win.ini.
442 This would not match the Wine compile-time option.
443 Also, not all identifiers are available from win.ini */
445 /* If we are through all of this, retLen should not be zero anymore.
446 If it is, the value is not supported */
448 while (locale_name2id[i].name!=NULL) {
449 if (LCType == locale_name2id[i].id) {
450 retString = locale_name2id[i].name;
456 WARN(ole,"Unkown LC type %lX\n",LCType);
460 #define LOCVAL(type,value) case type:retString=value;found=1;break;
461 #define LANG_BEGIN(l,s) case MAKELANGID(l,s): switch (LCType) {
462 #define LANG_END default: found=0; break; } break;
464 /* Now, the language specific definitions. They don't have to be
467 found=0; i=0; lang=lcid;
469 if (lang ==0x400) /*LANG_NEUTRAL ==> US English*/
471 WARN(ole,"no language set, assume LANG_ENGLISH_US \n");
479 LANG_BEGIN (LANG_GERMAN, SUBLANG_GERMAN) /*0x407*/
480 #include "nls/deu.nls"
483 LANG_BEGIN (LANG_DANISH, SUBLANG_DEFAULT) /*0x406*/
484 #include "nls/dan.nls"
487 LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_US) /*0x409*/
488 #include "nls/enu.nls"
491 LANG_BEGIN (LANG_ESPERANTO, SUBLANG_DEFAULT) /*0x48f*/
492 #include "nls/esperanto.nls"
495 LANG_BEGIN (LANG_FINNISH, SUBLANG_DEFAULT) /*0x040B*/
496 #include "nls/fin.nls"
499 LANG_BEGIN (LANG_ITALIAN, SUBLANG_ITALIAN) /*0x410*/
500 #include "nls/ita.nls"
503 LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_UK) /*0x809*/
504 #include "nls/eng.nls"
507 LANG_BEGIN (LANG_KOREAN, SUBLANG_KOREAN) /*0x412*/
508 #include "nls/kor.nls"
511 LANG_BEGIN (LANG_HUNGARIAN, SUBLANG_DEFAULT) /*0x40e*/
512 #include "nls/hun.nls"
515 LANG_BEGIN (LANG_POLISH, SUBLANG_DEFAULT) /*0x415*/
516 #include "nls/plk.nls"
519 LANG_BEGIN (LANG_PORTUGUESE ,SUBLANG_PORTUGUESE_BRAZILIAN) /*0x416*/
520 #include "nls/ptb.nls"
523 LANG_BEGIN (LANG_SWEDISH, SUBLANG_DEFAULT) /*0x41d*/
524 #include "nls/sve.nls"
527 /*Insert other languages here*/
535 /* language not found, try without a sublanguage*/
536 if (i==1) lang=MAKELANGID( PRIMARYLANGID(lang), SUBLANG_DEFAULT);
538 /* mask the LC Value */
539 if (i==2) LCType &= 0xfff;
542 } while (!found && i<3);
545 { ERR(ole,"'%s' not supported for your language.\n", retString);
546 SetLastError(ERROR_INVALID_PARAMETER);
549 /* if len=0 return only the length, don't touch the buffer*/
551 lstrcpyn32A(buf,retString,len);
553 return strlen(retString)+1;
556 /******************************************************************************
557 * GetLocaleInfo32W [KERNEL32.343]
560 INT32 WINAPI GetLocaleInfo32W(LCID lcid,LCTYPE LCType,LPWSTR wbuf,INT32 len)
564 if (len && (! wbuf) )
565 { SetLastError(ERROR_INSUFFICIENT_BUFFER);
569 abuf = (LPSTR)HeapAlloc(GetProcessHeap(),0,len);
570 wlen = 2 * GetLocaleInfo32A(lcid, LCType, abuf, len);
572 if (wlen && len) /* if len=0 return only the length*/
573 lstrcpynAtoW(wbuf,abuf,len/2);
575 HeapFree(GetProcessHeap(),0,abuf);
579 /******************************************************************************
580 * SetLocaleInfoA [KERNEL32.656]
582 BOOL16 WINAPI SetLocaleInfoA(DWORD lcid, DWORD lctype, LPCSTR data)
584 FIXME(ole,"(%ld,%ld,%s): stub\n",lcid,lctype,data);
588 /******************************************************************************
589 * IsValidLocale [KERNEL32.489]
591 BOOL32 WINAPI IsValidLocale(LCID lcid,DWORD flags)
593 /* we support ANY language. Well, at least say that...*/
597 /******************************************************************************
598 * EnumSystemLocales32W [KERNEL32.209]
600 BOOL32 WINAPI EnumSystemLocales32W( LOCALE_ENUMPROC32W lpfnLocaleEnum,
608 TRACE(win32,"(%p,%08lx)\n",lpfnLocaleEnum,flags );
609 /* see if we can reuse the Win95 registry entries.... */
610 if (ERROR_SUCCESS==RegOpenKey32A(HKEY_LOCAL_MACHINE,"\\System\\CurrentControlSet\\control\\Nls\\Locale\\",&xhkey)) {
613 if (ERROR_SUCCESS!=RegEnumKey32W(xhkey,i,buffer,sizeof(buffer)))
615 if (!lpfnLocaleEnum(buffer))
624 while (languages[i].langname!=NULL)
629 sprintf(xbuffer,"%08lx",(DWORD)languages[i].langid);
631 cp = HEAP_strdupAtoW( GetProcessHeap(), 0, xbuffer );
632 ret = lpfnLocaleEnum(cp);
633 HeapFree( GetProcessHeap(), 0, cp );
640 /******************************************************************************
641 * EnumSystemLocales32A [KERNEL32.208]
643 BOOL32 WINAPI EnumSystemLocales32A(LOCALE_ENUMPROC32A lpfnLocaleEnum,
650 TRACE(win32,"(%p,%08lx)\n",
653 if (ERROR_SUCCESS==RegOpenKey32A(HKEY_LOCAL_MACHINE,"\\System\\CurrentControlSet\\control\\Nls\\Locale\\",&xhkey)) {
656 if (ERROR_SUCCESS!=RegEnumKey32A(xhkey,i,buffer,sizeof(buffer)))
658 if (!lpfnLocaleEnum(buffer))
666 while (languages[i].langname!=NULL) {
667 sprintf(buffer,"%08lx",(DWORD)languages[i].langid);
668 if (!lpfnLocaleEnum(buffer))
675 static const unsigned char CT_CType2_LUT[] = {
676 C2_NOTAPPLICABLE, /* - 0 */
677 C2_NOTAPPLICABLE, /* - 1 */
678 C2_NOTAPPLICABLE, /* - 2 */
679 C2_NOTAPPLICABLE, /* - 3 */
680 C2_NOTAPPLICABLE, /* - 4 */
681 C2_NOTAPPLICABLE, /* - 5 */
682 C2_NOTAPPLICABLE, /* - 6 */
683 C2_NOTAPPLICABLE, /* - 7 */
684 C2_NOTAPPLICABLE, /* - 8 */
685 C2_SEGMENTSEPARATOR, /* - 9 */
686 C2_NOTAPPLICABLE, /* - 10 */
687 C2_NOTAPPLICABLE, /* - 11 */
688 C2_NOTAPPLICABLE, /* - 12 */
689 C2_NOTAPPLICABLE, /* - 13 */
690 C2_NOTAPPLICABLE, /* - 14 */
691 C2_NOTAPPLICABLE, /* - 15 */
692 C2_NOTAPPLICABLE, /* - 16 */
693 C2_NOTAPPLICABLE, /* - 17 */
694 C2_NOTAPPLICABLE, /* - 18 */
695 C2_NOTAPPLICABLE, /* - 19 */
696 C2_NOTAPPLICABLE, /* - 20 */
697 C2_NOTAPPLICABLE, /* - 21 */
698 C2_NOTAPPLICABLE, /* - 22 */
699 C2_NOTAPPLICABLE, /* - 23 */
700 C2_NOTAPPLICABLE, /* - 24 */
701 C2_NOTAPPLICABLE, /* - 25 */
702 C2_NOTAPPLICABLE, /* - 26 */
703 C2_NOTAPPLICABLE, /* - 27 */
704 C2_NOTAPPLICABLE, /* - 28 */
705 C2_NOTAPPLICABLE, /* - 29 */
706 C2_NOTAPPLICABLE, /* - 30 */
707 C2_NOTAPPLICABLE, /* - 31 */
708 C2_WHITESPACE, /* - 32 */
709 C2_OTHERNEUTRAL, /* ! - 33 */
710 C2_OTHERNEUTRAL, /* " - 34 */ /* " */
711 C2_EUROPETERMINATOR, /* # - 35 */
712 C2_EUROPETERMINATOR, /* $ - 36 */
713 C2_EUROPETERMINATOR, /* % - 37 */
714 C2_LEFTTORIGHT, /* & - 38 */
715 C2_OTHERNEUTRAL, /* ' - 39 */
716 C2_OTHERNEUTRAL, /* ( - 40 */
717 C2_OTHERNEUTRAL, /* ) - 41 */
718 C2_OTHERNEUTRAL, /* * - 42 */
719 C2_EUROPETERMINATOR, /* + - 43 */
720 C2_COMMONSEPARATOR, /* , - 44 */
721 C2_EUROPETERMINATOR, /* - - 45 */
722 C2_EUROPESEPARATOR, /* . - 46 */
723 C2_EUROPESEPARATOR, /* / - 47 */
724 C2_EUROPENUMBER, /* 0 - 48 */
725 C2_EUROPENUMBER, /* 1 - 49 */
726 C2_EUROPENUMBER, /* 2 - 50 */
727 C2_EUROPENUMBER, /* 3 - 51 */
728 C2_EUROPENUMBER, /* 4 - 52 */
729 C2_EUROPENUMBER, /* 5 - 53 */
730 C2_EUROPENUMBER, /* 6 - 54 */
731 C2_EUROPENUMBER, /* 7 - 55 */
732 C2_EUROPENUMBER, /* 8 - 56 */
733 C2_EUROPENUMBER, /* 9 - 57 */
734 C2_COMMONSEPARATOR, /* : - 58 */
735 C2_OTHERNEUTRAL, /* ; - 59 */
736 C2_OTHERNEUTRAL, /* < - 60 */
737 C2_OTHERNEUTRAL, /* = - 61 */
738 C2_OTHERNEUTRAL, /* > - 62 */
739 C2_OTHERNEUTRAL, /* ? - 63 */
740 C2_LEFTTORIGHT, /* @ - 64 */
741 C2_LEFTTORIGHT, /* A - 65 */
742 C2_LEFTTORIGHT, /* B - 66 */
743 C2_LEFTTORIGHT, /* C - 67 */
744 C2_LEFTTORIGHT, /* D - 68 */
745 C2_LEFTTORIGHT, /* E - 69 */
746 C2_LEFTTORIGHT, /* F - 70 */
747 C2_LEFTTORIGHT, /* G - 71 */
748 C2_LEFTTORIGHT, /* H - 72 */
749 C2_LEFTTORIGHT, /* I - 73 */
750 C2_LEFTTORIGHT, /* J - 74 */
751 C2_LEFTTORIGHT, /* K - 75 */
752 C2_LEFTTORIGHT, /* L - 76 */
753 C2_LEFTTORIGHT, /* M - 77 */
754 C2_LEFTTORIGHT, /* N - 78 */
755 C2_LEFTTORIGHT, /* O - 79 */
756 C2_LEFTTORIGHT, /* P - 80 */
757 C2_LEFTTORIGHT, /* Q - 81 */
758 C2_LEFTTORIGHT, /* R - 82 */
759 C2_LEFTTORIGHT, /* S - 83 */
760 C2_LEFTTORIGHT, /* T - 84 */
761 C2_LEFTTORIGHT, /* U - 85 */
762 C2_LEFTTORIGHT, /* V - 86 */
763 C2_LEFTTORIGHT, /* W - 87 */
764 C2_LEFTTORIGHT, /* X - 88 */
765 C2_LEFTTORIGHT, /* Y - 89 */
766 C2_LEFTTORIGHT, /* Z - 90 */
767 C2_OTHERNEUTRAL, /* [ - 91 */
768 C2_OTHERNEUTRAL, /* \ - 92 */
769 C2_OTHERNEUTRAL, /* ] - 93 */
770 C2_OTHERNEUTRAL, /* ^ - 94 */
771 C2_OTHERNEUTRAL, /* _ - 95 */
772 C2_OTHERNEUTRAL, /* ` - 96 */
773 C2_LEFTTORIGHT, /* a - 97 */
774 C2_LEFTTORIGHT, /* b - 98 */
775 C2_LEFTTORIGHT, /* c - 99 */
776 C2_LEFTTORIGHT, /* d - 100 */
777 C2_LEFTTORIGHT, /* e - 101 */
778 C2_LEFTTORIGHT, /* f - 102 */
779 C2_LEFTTORIGHT, /* g - 103 */
780 C2_LEFTTORIGHT, /* h - 104 */
781 C2_LEFTTORIGHT, /* i - 105 */
782 C2_LEFTTORIGHT, /* j - 106 */
783 C2_LEFTTORIGHT, /* k - 107 */
784 C2_LEFTTORIGHT, /* l - 108 */
785 C2_LEFTTORIGHT, /* m - 109 */
786 C2_LEFTTORIGHT, /* n - 110 */
787 C2_LEFTTORIGHT, /* o - 111 */
788 C2_LEFTTORIGHT, /* p - 112 */
789 C2_LEFTTORIGHT, /* q - 113 */
790 C2_LEFTTORIGHT, /* r - 114 */
791 C2_LEFTTORIGHT, /* s - 115 */
792 C2_LEFTTORIGHT, /* t - 116 */
793 C2_LEFTTORIGHT, /* u - 117 */
794 C2_LEFTTORIGHT, /* v - 118 */
795 C2_LEFTTORIGHT, /* w - 119 */
796 C2_LEFTTORIGHT, /* x - 120 */
797 C2_LEFTTORIGHT, /* y - 121 */
798 C2_LEFTTORIGHT, /* z - 122 */
799 C2_OTHERNEUTRAL, /* { - 123 */
800 C2_OTHERNEUTRAL, /* | - 124 */
801 C2_OTHERNEUTRAL, /* } - 125 */
802 C2_OTHERNEUTRAL, /* ~ - 126 */
803 C2_NOTAPPLICABLE, /*
\7f - 127 */
804 C2_NOTAPPLICABLE, /*
\80 - 128 */
805 C2_NOTAPPLICABLE, /*
\81 - 129 */
806 C2_OTHERNEUTRAL, /*
\82 - 130 */
807 C2_LEFTTORIGHT, /*
\83 - 131 */
808 C2_OTHERNEUTRAL, /*
\84 - 132 */
809 C2_OTHERNEUTRAL, /*
\85 - 133 */
810 C2_OTHERNEUTRAL, /*
\86 - 134 */
811 C2_OTHERNEUTRAL, /*
\87 - 135 */
812 C2_LEFTTORIGHT, /*
\88 - 136 */
813 C2_EUROPETERMINATOR, /*
\89 - 137 */
814 C2_LEFTTORIGHT, /*
\8a - 138 */
815 C2_OTHERNEUTRAL, /*
\8b - 139 */
816 C2_LEFTTORIGHT, /*
\8c - 140 */
817 C2_NOTAPPLICABLE, /*
\8d - 141 */
818 C2_NOTAPPLICABLE, /*
\8e - 142 */
819 C2_NOTAPPLICABLE, /*
\8f - 143 */
820 C2_NOTAPPLICABLE, /*
\90 - 144 */
821 C2_OTHERNEUTRAL, /*
\91 - 145 */
822 C2_OTHERNEUTRAL, /*
\92 - 146 */
823 C2_OTHERNEUTRAL, /*
\93 - 147 */
824 C2_OTHERNEUTRAL, /*
\94 - 148 */
825 C2_OTHERNEUTRAL, /*
\95 - 149 */
826 C2_OTHERNEUTRAL, /*
\96 - 150 */
827 C2_OTHERNEUTRAL, /*
\97 - 151 */
828 C2_LEFTTORIGHT, /*
\98 - 152 */
829 C2_OTHERNEUTRAL, /*
\99 - 153 */
830 C2_LEFTTORIGHT, /*
\9a - 154 */
831 C2_OTHERNEUTRAL, /*
\9b - 155 */
832 C2_LEFTTORIGHT, /*
\9c - 156 */
833 C2_NOTAPPLICABLE, /*
\9d - 157 */
834 C2_NOTAPPLICABLE, /*
\9e - 158 */
835 C2_LEFTTORIGHT, /*
\9f - 159 */
836 C2_WHITESPACE, /* - 160 */
837 C2_OTHERNEUTRAL, /* ¡ - 161 */
838 C2_EUROPETERMINATOR, /* ¢ - 162 */
839 C2_EUROPETERMINATOR, /* £ - 163 */
840 C2_EUROPETERMINATOR, /* ¤ - 164 */
841 C2_EUROPETERMINATOR, /* ¥ - 165 */
842 C2_OTHERNEUTRAL, /* ¦ - 166 */
843 C2_OTHERNEUTRAL, /* § - 167 */
844 C2_OTHERNEUTRAL, /* ¨ - 168 */
845 C2_OTHERNEUTRAL, /* © - 169 */
846 C2_OTHERNEUTRAL, /* ª - 170 */
847 C2_OTHERNEUTRAL, /* « - 171 */
848 C2_OTHERNEUTRAL, /* ¬ - 172 */
849 C2_OTHERNEUTRAL, /* - 173 */
850 C2_OTHERNEUTRAL, /* ® - 174 */
851 C2_OTHERNEUTRAL, /* ¯ - 175 */
852 C2_EUROPETERMINATOR, /* ° - 176 */
853 C2_EUROPETERMINATOR, /* ± - 177 */
854 C2_EUROPENUMBER, /* ² - 178 */
855 C2_EUROPENUMBER, /* ³ - 179 */
856 C2_OTHERNEUTRAL, /* ´ - 180 */
857 C2_OTHERNEUTRAL, /* µ - 181 */
858 C2_OTHERNEUTRAL, /* ¶ - 182 */
859 C2_OTHERNEUTRAL, /* · - 183 */
860 C2_OTHERNEUTRAL, /* ¸ - 184 */
861 C2_EUROPENUMBER, /* ¹ - 185 */
862 C2_OTHERNEUTRAL, /* º - 186 */
863 C2_OTHERNEUTRAL, /* » - 187 */
864 C2_OTHERNEUTRAL, /* ¼ - 188 */
865 C2_OTHERNEUTRAL, /* ½ - 189 */
866 C2_OTHERNEUTRAL, /* ¾ - 190 */
867 C2_OTHERNEUTRAL, /* ¿ - 191 */
868 C2_LEFTTORIGHT, /* À - 192 */
869 C2_LEFTTORIGHT, /* Á - 193 */
870 C2_LEFTTORIGHT, /* Â - 194 */
871 C2_LEFTTORIGHT, /* Ã - 195 */
872 C2_LEFTTORIGHT, /* Ä - 196 */
873 C2_LEFTTORIGHT, /* Å - 197 */
874 C2_LEFTTORIGHT, /* Æ - 198 */
875 C2_LEFTTORIGHT, /* Ç - 199 */
876 C2_LEFTTORIGHT, /* È - 200 */
877 C2_LEFTTORIGHT, /* É - 201 */
878 C2_LEFTTORIGHT, /* Ê - 202 */
879 C2_LEFTTORIGHT, /* Ë - 203 */
880 C2_LEFTTORIGHT, /* Ì - 204 */
881 C2_LEFTTORIGHT, /* Í - 205 */
882 C2_LEFTTORIGHT, /* Î - 206 */
883 C2_LEFTTORIGHT, /* Ï - 207 */
884 C2_LEFTTORIGHT, /* Ð - 208 */
885 C2_LEFTTORIGHT, /* Ñ - 209 */
886 C2_LEFTTORIGHT, /* Ò - 210 */
887 C2_LEFTTORIGHT, /* Ó - 211 */
888 C2_LEFTTORIGHT, /* Ô - 212 */
889 C2_LEFTTORIGHT, /* Õ - 213 */
890 C2_LEFTTORIGHT, /* Ö - 214 */
891 C2_OTHERNEUTRAL, /* × - 215 */
892 C2_LEFTTORIGHT, /* Ø - 216 */
893 C2_LEFTTORIGHT, /* Ù - 217 */
894 C2_LEFTTORIGHT, /* Ú - 218 */
895 C2_LEFTTORIGHT, /* Û - 219 */
896 C2_LEFTTORIGHT, /* Ü - 220 */
897 C2_LEFTTORIGHT, /* Ý - 221 */
898 C2_LEFTTORIGHT, /* Þ - 222 */
899 C2_LEFTTORIGHT, /* ß - 223 */
900 C2_LEFTTORIGHT, /* à - 224 */
901 C2_LEFTTORIGHT, /* á - 225 */
902 C2_LEFTTORIGHT, /* â - 226 */
903 C2_LEFTTORIGHT, /* ã - 227 */
904 C2_LEFTTORIGHT, /* ä - 228 */
905 C2_LEFTTORIGHT, /* å - 229 */
906 C2_LEFTTORIGHT, /* æ - 230 */
907 C2_LEFTTORIGHT, /* ç - 231 */
908 C2_LEFTTORIGHT, /* è - 232 */
909 C2_LEFTTORIGHT, /* é - 233 */
910 C2_LEFTTORIGHT, /* ê - 234 */
911 C2_LEFTTORIGHT, /* ë - 235 */
912 C2_LEFTTORIGHT, /* ì - 236 */
913 C2_LEFTTORIGHT, /* í - 237 */
914 C2_LEFTTORIGHT, /* î - 238 */
915 C2_LEFTTORIGHT, /* ï - 239 */
916 C2_LEFTTORIGHT, /* ð - 240 */
917 C2_LEFTTORIGHT, /* ñ - 241 */
918 C2_LEFTTORIGHT, /* ò - 242 */
919 C2_LEFTTORIGHT, /* ó - 243 */
920 C2_LEFTTORIGHT, /* ô - 244 */
921 C2_LEFTTORIGHT, /* õ - 245 */
922 C2_LEFTTORIGHT, /* ö - 246 */
923 C2_OTHERNEUTRAL, /* ÷ - 247 */
924 C2_LEFTTORIGHT, /* ø - 248 */
925 C2_LEFTTORIGHT, /* ù - 249 */
926 C2_LEFTTORIGHT, /* ú - 250 */
927 C2_LEFTTORIGHT, /* û - 251 */
928 C2_LEFTTORIGHT, /* ü - 252 */
929 C2_LEFTTORIGHT, /* ý - 253 */
930 C2_LEFTTORIGHT, /* þ - 254 */
931 C2_LEFTTORIGHT /* ÿ - 255 */
934 static const WORD CT_CType3_LUT[] = {
969 0x0448, /* " - 34 */ /* " */
1000 0x8040, /* A - 65 */
1001 0x8040, /* B - 66 */
1002 0x8040, /* C - 67 */
1003 0x8040, /* D - 68 */
1004 0x8040, /* E - 69 */
1005 0x8040, /* F - 70 */
1006 0x8040, /* G - 71 */
1007 0x8040, /* H - 72 */
1008 0x8040, /* I - 73 */
1009 0x8040, /* J - 74 */
1010 0x8040, /* K - 75 */
1011 0x8040, /* L - 76 */
1012 0x8040, /* M - 77 */
1013 0x8040, /* N - 78 */
1014 0x8040, /* O - 79 */
1015 0x8040, /* P - 80 */
1016 0x8040, /* Q - 81 */
1017 0x8040, /* R - 82 */
1018 0x8040, /* S - 83 */
1019 0x8040, /* T - 84 */
1020 0x8040, /* U - 85 */
1021 0x8040, /* V - 86 */
1022 0x8040, /* W - 87 */
1023 0x8040, /* X - 88 */
1024 0x8040, /* Y - 89 */
1025 0x8040, /* Z - 90 */
1026 0x0048, /* [ - 91 */
1027 0x0448, /* \ - 92 */
1028 0x0048, /* ] - 93 */
1029 0x0448, /* ^ - 94 */
1030 0x0448, /* _ - 95 */
1031 0x0448, /* ` - 96 */
1032 0x8040, /* a - 97 */
1033 0x8040, /* b - 98 */
1034 0x8040, /* c - 99 */
1035 0x8040, /* d - 100 */
1036 0x8040, /* e - 101 */
1037 0x8040, /* f - 102 */
1038 0x8040, /* g - 103 */
1039 0x8040, /* h - 104 */
1040 0x8040, /* i - 105 */
1041 0x8040, /* j - 106 */
1042 0x8040, /* k - 107 */
1043 0x8040, /* l - 108 */
1044 0x8040, /* m - 109 */
1045 0x8040, /* n - 110 */
1046 0x8040, /* o - 111 */
1047 0x8040, /* p - 112 */
1048 0x8040, /* q - 113 */
1049 0x8040, /* r - 114 */
1050 0x8040, /* s - 115 */
1051 0x8040, /* t - 116 */
1052 0x8040, /* u - 117 */
1053 0x8040, /* v - 118 */
1054 0x8040, /* w - 119 */
1055 0x8040, /* x - 120 */
1056 0x8040, /* y - 121 */
1057 0x8040, /* z - 122 */
1058 0x0048, /* { - 123 */
1059 0x0048, /* | - 124 */
1060 0x0048, /* } - 125 */
1061 0x0448, /* ~ - 126 */
1062 0x0000, /*
\7f - 127 */
1063 0x0000, /*
\80 - 128 */
1064 0x0000, /*
\81 - 129 */
1065 0x0008, /*
\82 - 130 */
1066 0x8000, /*
\83 - 131 */
1067 0x0008, /*
\84 - 132 */
1068 0x0008, /*
\85 - 133 */
1069 0x0008, /*
\86 - 134 */
1070 0x0008, /*
\87 - 135 */
1071 0x0001, /*
\88 - 136 */
1072 0x0008, /*
\89 - 137 */
1073 0x8003, /*
\8a - 138 */
1074 0x0008, /*
\8b - 139 */
1075 0x8000, /*
\8c - 140 */
1076 0x0000, /*
\8d - 141 */
1077 0x0000, /*
\8e - 142 */
1078 0x0000, /*
\8f - 143 */
1079 0x0000, /*
\90 - 144 */
1080 0x0088, /*
\91 - 145 */
1081 0x0088, /*
\92 - 146 */
1082 0x0088, /*
\93 - 147 */
1083 0x0088, /*
\94 - 148 */
1084 0x0008, /*
\95 - 149 */
1085 0x0400, /*
\96 - 150 */
1086 0x0400, /*
\97 - 151 */
1087 0x0408, /*
\98 - 152 */
1088 0x0000, /*
\99 - 153 */
1089 0x8003, /*
\9a - 154 */
1090 0x0008, /*
\9b - 155 */
1091 0x8000, /*
\9c - 156 */
1092 0x0000, /*
\9d - 157 */
1093 0x0000, /*
\9e - 158 */
1094 0x8003, /*
\9f - 159 */
1096 0x0008, /* ¡ - 161 */
1097 0x0048, /* ¢ - 162 */
1098 0x0048, /* £ - 163 */
1099 0x0008, /* ¤ - 164 */
1100 0x0048, /* ¥ - 165 */
1101 0x0048, /* ¦ - 166 */
1102 0x0008, /* § - 167 */
1103 0x0408, /* ¨ - 168 */
1104 0x0008, /* © - 169 */
1105 0x0400, /* ª - 170 */
1106 0x0008, /* « - 171 */
1107 0x0048, /* ¬ - 172 */
1108 0x0408, /* - 173 */
1109 0x0008, /* ® - 174 */
1110 0x0448, /* ¯ - 175 */
1111 0x0008, /* ° - 176 */
1112 0x0008, /* ± - 177 */
1113 0x0000, /* ² - 178 */
1114 0x0000, /* ³ - 179 */
1115 0x0408, /* ´ - 180 */
1116 0x0008, /* µ - 181 */
1117 0x0008, /* ¶ - 182 */
1118 0x0008, /* · - 183 */
1119 0x0408, /* ¸ - 184 */
1120 0x0000, /* ¹ - 185 */
1121 0x0400, /* º - 186 */
1122 0x0008, /* » - 187 */
1123 0x0000, /* ¼ - 188 */
1124 0x0000, /* ½ - 189 */
1125 0x0000, /* ¾ - 190 */
1126 0x0008, /* ¿ - 191 */
1127 0x8003, /* À - 192 */
1128 0x8003, /* Á - 193 */
1129 0x8003, /* Â - 194 */
1130 0x8003, /* Ã - 195 */
1131 0x8003, /* Ä - 196 */
1132 0x8003, /* Å - 197 */
1133 0x8000, /* Æ - 198 */
1134 0x8003, /* Ç - 199 */
1135 0x8003, /* È - 200 */
1136 0x8003, /* É - 201 */
1137 0x8003, /* Ê - 202 */
1138 0x8003, /* Ë - 203 */
1139 0x8003, /* Ì - 204 */
1140 0x8003, /* Í - 205 */
1141 0x8003, /* Î - 206 */
1142 0x8003, /* Ï - 207 */
1143 0x8000, /* Ð - 208 */
1144 0x8003, /* Ñ - 209 */
1145 0x8003, /* Ò - 210 */
1146 0x8003, /* Ó - 211 */
1147 0x8003, /* Ô - 212 */
1148 0x8003, /* Õ - 213 */
1149 0x8003, /* Ö - 214 */
1150 0x0008, /* × - 215 */
1151 0x8003, /* Ø - 216 */
1152 0x8003, /* Ù - 217 */
1153 0x8003, /* Ú - 218 */
1154 0x8003, /* Û - 219 */
1155 0x8003, /* Ü - 220 */
1156 0x8003, /* Ý - 221 */
1157 0x8000, /* Þ - 222 */
1158 0x8000, /* ß - 223 */
1159 0x8003, /* à - 224 */
1160 0x8003, /* á - 225 */
1161 0x8003, /* â - 226 */
1162 0x8003, /* ã - 227 */
1163 0x8003, /* ä - 228 */
1164 0x8003, /* å - 229 */
1165 0x8000, /* æ - 230 */
1166 0x8003, /* ç - 231 */
1167 0x8003, /* è - 232 */
1168 0x8003, /* é - 233 */
1169 0x8003, /* ê - 234 */
1170 0x8003, /* ë - 235 */
1171 0x8003, /* ì - 236 */
1172 0x8003, /* í - 237 */
1173 0x8003, /* î - 238 */
1174 0x8003, /* ï - 239 */
1175 0x8000, /* ð - 240 */
1176 0x8003, /* ñ - 241 */
1177 0x8003, /* ò - 242 */
1178 0x8003, /* ó - 243 */
1179 0x8003, /* ô - 244 */
1180 0x8003, /* õ - 245 */
1181 0x8003, /* ö - 246 */
1182 0x0008, /* ÷ - 247 */
1183 0x8003, /* ø - 248 */
1184 0x8003, /* ù - 249 */
1185 0x8003, /* ú - 250 */
1186 0x8003, /* û - 251 */
1187 0x8003, /* ü - 252 */
1188 0x8003, /* ý - 253 */
1189 0x8000, /* þ - 254 */
1190 0x8003 /* ÿ - 255 */
1193 /******************************************************************************
1194 * GetStringType16 [OLE2NLS.7]
1196 BOOL16 WINAPI GetStringType16(LCID locale,DWORD dwInfoType,LPCSTR src,
1197 INT16 cchSrc,LPWORD chartype)
1199 return GetStringTypeEx32A(locale,dwInfoType,src,cchSrc,chartype);
1201 /******************************************************************************
1202 * GetStringType32A [KERNEL32.396]
1204 BOOL32 WINAPI GetStringType32A(LCID locale,DWORD dwInfoType,LPCSTR src,
1205 INT32 cchSrc,LPWORD chartype)
1207 return GetStringTypeEx32A(locale,dwInfoType,src,cchSrc,chartype);
1210 /******************************************************************************
1211 * GetStringTypeEx32A [KERNEL32.397]
1213 * FIXME: Ignores the locale.
1215 BOOL32 WINAPI GetStringTypeEx32A(LCID locale,DWORD dwInfoType,LPCSTR src,
1216 INT32 cchSrc,LPWORD chartype)
1220 if ((src==NULL) || (chartype==NULL) || (src==(LPSTR)chartype))
1222 SetLastError(ERROR_INVALID_PARAMETER);
1227 cchSrc=lstrlen32A(src)+1;
1229 switch (dwInfoType) {
1231 for (i=0;i<cchSrc;i++)
1234 if (isdigit(src[i])) chartype[i]|=C1_DIGIT;
1235 if (isalpha(src[i])) chartype[i]|=C1_ALPHA;
1236 if (islower(src[i])) chartype[i]|=C1_LOWER;
1237 if (isupper(src[i])) chartype[i]|=C1_UPPER;
1238 if (isspace(src[i])) chartype[i]|=C1_SPACE;
1239 if (ispunct(src[i])) chartype[i]|=C1_PUNCT;
1240 if (iscntrl(src[i])) chartype[i]|=C1_CNTRL;
1241 /* FIXME: isblank() is a GNU extension */
1242 /* if (isblank(src[i])) chartype[i]|=C1_BLANK; */
1243 if ((src[i] == ' ') || (src[i] == '\t')) chartype[i]|=C1_BLANK;
1249 for (i=0;i<cchSrc;i++)
1251 chartype[i]=(WORD)CT_CType2_LUT[i];
1256 for (i=0;i<cchSrc;i++)
1258 chartype[i]=CT_CType3_LUT[i];
1263 ERR(ole,"Unknown dwInfoType:%ld\n",dwInfoType);
1268 /******************************************************************************
1269 * GetStringType32W [KERNEL32.399]
1272 * Yes, this is missing LCID locale. MS fault.
1274 BOOL32 WINAPI GetStringType32W(DWORD dwInfoType,LPCWSTR src,INT32 cchSrc,
1277 return GetStringTypeEx32W(0/*defaultlocale*/,dwInfoType,src,cchSrc,chartype);
1280 /******************************************************************************
1281 * GetStringTypeEx32W [KERNEL32.398]
1283 * FIXME: unicode chars are assumed chars
1285 BOOL32 WINAPI GetStringTypeEx32W(LCID locale,DWORD dwInfoType,LPCWSTR src,
1286 INT32 cchSrc,LPWORD chartype)
1292 cchSrc=lstrlen32W(src)+1;
1294 switch (dwInfoType) {
1296 FIXME(ole,"CT_CTYPE2 not supported.\n");
1299 FIXME(ole,"CT_CTYPE3 not supported.\n");
1303 for (i=0;i<cchSrc;i++) {
1305 if (isdigit(src[i])) chartype[i]|=C1_DIGIT;
1306 if (isalpha(src[i])) chartype[i]|=C1_ALPHA;
1307 if (islower(src[i])) chartype[i]|=C1_LOWER;
1308 if (isupper(src[i])) chartype[i]|=C1_UPPER;
1309 if (isspace(src[i])) chartype[i]|=C1_SPACE;
1310 if (ispunct(src[i])) chartype[i]|=C1_PUNCT;
1311 if (iscntrl(src[i])) chartype[i]|=C1_CNTRL;
1312 /* FIXME: isblank() is a GNU extension */
1313 /* if (isblank(src[i])) chartype[i]|=C1_BLANK; */
1314 if ((src[i] == ' ') || (src[i] == '\t')) chartype[i]|=C1_BLANK;
1320 /*****************************************************************
1321 * VerLanguageName16 [VER.10]
1323 DWORD WINAPI VerLanguageName16(UINT16 langid,LPSTR langname,UINT16 langnamelen)
1329 TRACE(ver,"(%d,%p,%d)\n",langid,langname,langnamelen);
1330 /* First, check \System\CurrentControlSet\control\Nls\Locale\<langid>
1331 * from the registry.
1334 "\\System\\CurrentControlSet\\control\\Nls\\Locale\\%08x",
1336 result = RegQueryValue16(HKEY_LOCAL_MACHINE, buffer, langname,
1337 (LPDWORD)&langnamelen);
1338 if (result == ERROR_SUCCESS) {
1339 langname[langnamelen-1]='\0';
1342 /* if that fails, use the internal table */
1343 for (i=0;languages[i].langid!=0;i++)
1344 if (langid==languages[i].langid)
1346 strncpy(langname,languages[i].langname,langnamelen);
1347 langname[langnamelen-1]='\0';
1348 return strlen(languages[i].langname);
1351 /*****************************************************************
1352 * VerLanguageName32A [VERSION.9]
1354 DWORD WINAPI VerLanguageName32A(UINT32 langid,LPSTR langname,
1357 return VerLanguageName16(langid,langname,langnamelen);
1360 /*****************************************************************
1361 * VerLanguageName32W [VERSION.10]
1363 DWORD WINAPI VerLanguageName32W(UINT32 langid,LPWSTR langname,
1371 /* First, check \System\CurrentControlSet\control\Nls\Locale\<langid>
1372 * from the registry.
1375 "\\System\\CurrentControlSet\\control\\Nls\\Locale\\%08x",
1377 keyname = HEAP_strdupAtoW( GetProcessHeap(), 0, buffer );
1378 result = RegQueryValue32W(HKEY_LOCAL_MACHINE, keyname, langname,
1379 (LPDWORD)&langnamelen);
1380 HeapFree( GetProcessHeap(), 0, keyname );
1381 if (result != ERROR_SUCCESS) {
1382 /* if that fails, use the internal table */
1383 for (i=0;languages[i].langid!=0;i++)
1384 if (langid==languages[i].langid)
1386 lstrcpyAtoW( langname, languages[i].langname );
1387 langnamelen = strlen(languages[i].langname);
1388 /* same as strlenW(langname); */
1393 static const unsigned char LCM_Unicode_LUT[] = {
1426 7 , 28, /* ! - 33 */
1427 7 , 29, /* " - 34 */ /* " */
1428 7 , 31, /* # - 35 */
1429 7 , 33, /* $ - 36 */
1430 7 , 35, /* % - 37 */
1431 7 , 37, /* & - 38 */
1432 6 , 128, /* ' - 39 */
1433 7 , 39, /* ( - 40 */
1434 7 , 42, /* ) - 41 */
1435 7 , 45, /* * - 42 */
1437 7 , 47, /* , - 44 */
1438 6 , 130, /* - - 45 */
1439 7 , 51, /* . - 46 */
1440 7 , 53, /* / - 47 */
1441 12 , 3, /* 0 - 48 */
1442 12 , 33, /* 1 - 49 */
1443 12 , 51, /* 2 - 50 */
1444 12 , 70, /* 3 - 51 */
1445 12 , 88, /* 4 - 52 */
1446 12 , 106, /* 5 - 53 */
1447 12 , 125, /* 6 - 54 */
1448 12 , 144, /* 7 - 55 */
1449 12 , 162, /* 8 - 56 */
1450 12 , 180, /* 9 - 57 */
1451 7 , 55, /* : - 58 */
1452 7 , 58, /* ; - 59 */
1453 8 , 14, /* < - 60 */
1454 8 , 18, /* = - 61 */
1455 8 , 20, /* > - 62 */
1456 7 , 60, /* ? - 63 */
1457 7 , 62, /* @ - 64 */
1458 14 , 2, /* A - 65 */
1459 14 , 9, /* B - 66 */
1460 14 , 10, /* C - 67 */
1461 14 , 26, /* D - 68 */
1462 14 , 33, /* E - 69 */
1463 14 , 35, /* F - 70 */
1464 14 , 37, /* G - 71 */
1465 14 , 44, /* H - 72 */
1466 14 , 50, /* I - 73 */
1467 14 , 53, /* J - 74 */
1468 14 , 54, /* K - 75 */
1469 14 , 72, /* L - 76 */
1470 14 , 81, /* M - 77 */
1471 14 , 112, /* N - 78 */
1472 14 , 124, /* O - 79 */
1473 14 , 126, /* P - 80 */
1474 14 , 137, /* Q - 81 */
1475 14 , 138, /* R - 82 */
1476 14 , 145, /* S - 83 */
1477 14 , 153, /* T - 84 */
1478 14 , 159, /* U - 85 */
1479 14 , 162, /* V - 86 */
1480 14 , 164, /* W - 87 */
1481 14 , 166, /* X - 88 */
1482 14 , 167, /* Y - 89 */
1483 14 , 169, /* Z - 90 */
1484 7 , 63, /* [ - 91 */
1485 7 , 65, /* \ - 92 */
1486 7 , 66, /* ] - 93 */
1487 7 , 67, /* ^ - 94 */
1488 7 , 68, /* _ - 95 */
1489 7 , 72, /* ` - 96 */
1490 14 , 2, /* a - 97 */
1491 14 , 9, /* b - 98 */
1492 14 , 10, /* c - 99 */
1493 14 , 26, /* d - 100 */
1494 14 , 33, /* e - 101 */
1495 14 , 35, /* f - 102 */
1496 14 , 37, /* g - 103 */
1497 14 , 44, /* h - 104 */
1498 14 , 50, /* i - 105 */
1499 14 , 53, /* j - 106 */
1500 14 , 54, /* k - 107 */
1501 14 , 72, /* l - 108 */
1502 14 , 81, /* m - 109 */
1503 14 , 112, /* n - 110 */
1504 14 , 124, /* o - 111 */
1505 14 , 126, /* p - 112 */
1506 14 , 137, /* q - 113 */
1507 14 , 138, /* r - 114 */
1508 14 , 145, /* s - 115 */
1509 14 , 153, /* t - 116 */
1510 14 , 159, /* u - 117 */
1511 14 , 162, /* v - 118 */
1512 14 , 164, /* w - 119 */
1513 14 , 166, /* x - 120 */
1514 14 , 167, /* y - 121 */
1515 14 , 169, /* z - 122 */
1516 7 , 74, /* { - 123 */
1517 7 , 76, /* | - 124 */
1518 7 , 78, /* } - 125 */
1519 7 , 80, /* ~ - 126 */
1520 6 , 29, /*
\7f - 127 */
1521 6 , 30, /*
\80 - 128 */
1522 6 , 31, /*
\81 - 129 */
1523 7 , 123, /*
\82 - 130 */
1524 14 , 35, /*
\83 - 131 */
1525 7 , 127, /*
\84 - 132 */
1526 10 , 21, /*
\85 - 133 */
1527 10 , 15, /*
\86 - 134 */
1528 10 , 16, /*
\87 - 135 */
1529 7 , 67, /*
\88 - 136 */
1530 10 , 22, /*
\89 - 137 */
1531 14 , 145, /*
\8a - 138 */
1532 7 , 136, /*
\8b - 139 */
1533 14 + 16 , 124, /*
\8c - 140 */
1534 6 , 43, /*
\8d - 141 */
1535 6 , 44, /*
\8e - 142 */
1536 6 , 45, /*
\8f - 143 */
1537 6 , 46, /*
\90 - 144 */
1538 7 , 121, /*
\91 - 145 */
1539 7 , 122, /*
\92 - 146 */
1540 7 , 125, /*
\93 - 147 */
1541 7 , 126, /*
\94 - 148 */
1542 10 , 17, /*
\95 - 149 */
1543 6 , 137, /*
\96 - 150 */
1544 6 , 139, /*
\97 - 151 */
1545 7 , 93, /*
\98 - 152 */
1546 14 , 156, /*
\99 - 153 */
1547 14 , 145, /*
\9a - 154 */
1548 7 , 137, /*
\9b - 155 */
1549 14 + 16 , 124, /*
\9c - 156 */
1550 6 , 59, /*
\9d - 157 */
1551 6 , 60, /*
\9e - 158 */
1552 14 , 167, /*
\9f - 159 */
1554 7 , 81, /* ¡ - 161 */
1555 10 , 2, /* ¢ - 162 */
1556 10 , 3, /* £ - 163 */
1557 10 , 4, /* ¤ - 164 */
1558 10 , 5, /* ¥ - 165 */
1559 7 , 82, /* ¦ - 166 */
1560 10 , 6, /* § - 167 */
1561 7 , 83, /* ¨ - 168 */
1562 10 , 7, /* © - 169 */
1563 14 , 2, /* ª - 170 */
1564 8 , 24, /* « - 171 */
1565 10 , 8, /* ¬ - 172 */
1566 6 , 131, /* - 173 */
1567 10 , 9, /* ® - 174 */
1568 7 , 84, /* ¯ - 175 */
1569 10 , 10, /* ° - 176 */
1570 8 , 23, /* ± - 177 */
1571 12 , 51, /* ² - 178 */
1572 12 , 70, /* ³ - 179 */
1573 7 , 85, /* ´ - 180 */
1574 10 , 11, /* µ - 181 */
1575 10 , 12, /* ¶ - 182 */
1576 10 , 13, /* · - 183 */
1577 7 , 86, /* ¸ - 184 */
1578 12 , 33, /* ¹ - 185 */
1579 14 , 124, /* º - 186 */
1580 8 , 26, /* » - 187 */
1581 12 , 21, /* ¼ - 188 */
1582 12 , 25, /* ½ - 189 */
1583 12 , 29, /* ¾ - 190 */
1584 7 , 87, /* ¿ - 191 */
1585 14 , 2, /* À - 192 */
1586 14 , 2, /* Á - 193 */
1587 14 , 2, /* Â - 194 */
1588 14 , 2, /* Ã - 195 */
1589 14 , 2, /* Ä - 196 */
1590 14 , 2, /* Å - 197 */
1591 14 + 16 , 2, /* Æ - 198 */
1592 14 , 10, /* Ç - 199 */
1593 14 , 33, /* È - 200 */
1594 14 , 33, /* É - 201 */
1595 14 , 33, /* Ê - 202 */
1596 14 , 33, /* Ë - 203 */
1597 14 , 50, /* Ì - 204 */
1598 14 , 50, /* Í - 205 */
1599 14 , 50, /* Î - 206 */
1600 14 , 50, /* Ï - 207 */
1601 14 , 26, /* Ð - 208 */
1602 14 , 112, /* Ñ - 209 */
1603 14 , 124, /* Ò - 210 */
1604 14 , 124, /* Ó - 211 */
1605 14 , 124, /* Ô - 212 */
1606 14 , 124, /* Õ - 213 */
1607 14 , 124, /* Ö - 214 */
1608 8 , 28, /* × - 215 */
1609 14 , 124, /* Ø - 216 */
1610 14 , 159, /* Ù - 217 */
1611 14 , 159, /* Ú - 218 */
1612 14 , 159, /* Û - 219 */
1613 14 , 159, /* Ü - 220 */
1614 14 , 167, /* Ý - 221 */
1615 14 + 32 , 153, /* Þ - 222 */
1616 14 + 48 , 145, /* ß - 223 */
1617 14 , 2, /* à - 224 */
1618 14 , 2, /* á - 225 */
1619 14 , 2, /* â - 226 */
1620 14 , 2, /* ã - 227 */
1621 14 , 2, /* ä - 228 */
1622 14 , 2, /* å - 229 */
1623 14 + 16 , 2, /* æ - 230 */
1624 14 , 10, /* ç - 231 */
1625 14 , 33, /* è - 232 */
1626 14 , 33, /* é - 233 */
1627 14 , 33, /* ê - 234 */
1628 14 , 33, /* ë - 235 */
1629 14 , 50, /* ì - 236 */
1630 14 , 50, /* í - 237 */
1631 14 , 50, /* î - 238 */
1632 14 , 50, /* ï - 239 */
1633 14 , 26, /* ð - 240 */
1634 14 , 112, /* ñ - 241 */
1635 14 , 124, /* ò - 242 */
1636 14 , 124, /* ó - 243 */
1637 14 , 124, /* ô - 244 */
1638 14 , 124, /* õ - 245 */
1639 14 , 124, /* ö - 246 */
1640 8 , 29, /* ÷ - 247 */
1641 14 , 124, /* ø - 248 */
1642 14 , 159, /* ù - 249 */
1643 14 , 159, /* ú - 250 */
1644 14 , 159, /* û - 251 */
1645 14 , 159, /* ü - 252 */
1646 14 , 167, /* ý - 253 */
1647 14 + 32 , 153, /* þ - 254 */
1648 14 , 167 /* ÿ - 255 */ };
1650 static const unsigned char LCM_Unicode_LUT_2[] = { 33, 44, 145 };
1652 #define LCM_Diacritic_Start 131
1654 static const unsigned char LCM_Diacritic_LUT[] = {
1655 123, /*
\83 - 131 */
1782 /******************************************************************************
1783 * OLE2NLS_isPunctuation [INTERNAL]
1785 static int OLE2NLS_isPunctuation(unsigned char c)
1787 /* "punctuation character" in this context is a character which is
1788 considered "less important" during word sort comparison.
1789 See LCMapString implementation for the precise definition
1790 of "less important". */
1792 return (LCM_Unicode_LUT[-2+2*c]==6);
1795 /******************************************************************************
1796 * identity [Internal]
1798 static int identity(int c)
1803 /*************************************************************************
1804 * LCMapString32A [KERNEL32.492]
1806 * Convert a string, or generate a sort key from it.
1808 * If (mapflags & LCMAP_SORTKEY), the function will generate
1809 * a sort key for the source string. Else, it will convert it
1810 * accordingly to the flags LCMAP_UPPERCASE, LCMAP_LOWERCASE,...
1814 * Success : length of the result string.
1817 * If called with scrlen = -1, the function will compute the length
1818 * of the 0-terminated string strsrc by itself.
1820 * If called with dstlen = 0, returns the buffer length that
1821 * would be required.
1823 * NORM_IGNOREWIDTH means to compare ASCII and Unicode characters
1824 * as if they are equal. Since Wine separates ASCII and Unicode into
1825 * separate functions, we shouldn't have to do anything for this flag.
1826 * I added it to the list of flags that don't need a fixme message
1827 * to make MS Word 95 not print several thousand fixme messages for
1830 INT32 WINAPI LCMapString32A(
1831 LCID lcid /* locale identifier created with MAKELCID;
1832 LOCALE_SYSTEM_DEFAULT and LOCALE_USER_DEFAULT are
1833 predefined values. */,
1834 DWORD mapflags /* flags */,
1835 LPCSTR srcstr /* source buffer */,
1836 INT32 srclen /* source length */,
1837 LPSTR dststr /* destination buffer */,
1838 INT32 dstlen /* destination buffer length */)
1842 TRACE(string,"(0x%04lx,0x%08lx,%s,%d,%p,%d)\n",
1843 lcid,mapflags,srcstr,srclen,dststr,dstlen);
1845 if ( ((dstlen!=0) && (dststr==NULL)) || (srcstr==NULL) )
1847 ERR(ole, "(src=%s,dest=%s): Invalid NULL string\n", srcstr, dststr);
1848 SetLastError(ERROR_INVALID_PARAMETER);
1852 srclen = lstrlen32A(srcstr) + 1 ; /* (include final '\0') */
1854 if (mapflags & ~ ( LCMAP_UPPERCASE | LCMAP_LOWERCASE | LCMAP_SORTKEY |
1855 NORM_IGNORECASE | NORM_IGNORENONSPACE | SORT_STRINGSORT |
1858 FIXME(string,"(0x%04lx,0x%08lx,%p,%d,%p,%d): "
1859 "unimplemented flags: 0x%08lx\n",
1860 lcid,mapflags,srcstr,srclen,dststr,dstlen,mapflags);
1863 if ( !(mapflags & LCMAP_SORTKEY) )
1865 int (*f)(int)=identity;
1868 return srclen; /* dstlen=0 means "do nothing but return required length" */
1870 srclen=dstlen; /* No, this case is not an error under Windows 95.
1871 And no '\0' gets written. */
1872 if (mapflags & LCMAP_UPPERCASE)
1874 else if (mapflags & LCMAP_LOWERCASE)
1876 for (i=0; i < srclen; i++)
1877 dststr[i] = (CHAR) f(srcstr[i]);
1881 /* else ... (mapflags & LCMAP_SORTKEY) */
1885 int diacritic_len=0;
1886 int delayed_punctuation_len=0;
1887 char *case_component;
1888 char *diacritic_component;
1889 char *delayed_punctuation_component;
1891 int flag_stringsort = mapflags & SORT_STRINGSORT;
1893 /* compute how much room we will need */
1894 for (i=0;i<srclen;i++)
1897 unsigned char source_char = srcstr[i];
1898 if (source_char!='\0')
1900 if (flag_stringsort || !OLE2NLS_isPunctuation(source_char))
1903 if ( LCM_Unicode_LUT[-2+2*source_char] & ~15 )
1904 unicode_len++; /* double letter */
1908 delayed_punctuation_len++;
1912 if (isupper(source_char))
1913 case_len=unicode_len;
1915 ofs = source_char - LCM_Diacritic_Start;
1916 if ((ofs>=0) && (LCM_Diacritic_LUT[ofs]!=2))
1917 diacritic_len=unicode_len;
1920 if (mapflags & NORM_IGNORECASE)
1922 if (mapflags & NORM_IGNORENONSPACE)
1925 room = 2 * unicode_len /* "unicode" component */
1926 + diacritic_len /* "diacritic" component */
1927 + case_len /* "case" component */
1928 + 4 * delayed_punctuation_len /* punctuation in word sort mode */
1929 + 4 /* four '\1' separators */
1930 + 1 ; /* terminal '\0' */
1933 else if (dstlen<room)
1935 SetLastError(ERROR_INSUFFICIENT_BUFFER);
1939 /*FIXME the Pointercheck should not be nessesary */
1940 if (IsBadWritePtr32 (dststr,room))
1941 { ERR (string,"bad destination buffer (dststr) : %p,%d\n",dststr,dstlen);
1942 SetLastError(ERROR_INSUFFICIENT_BUFFER);
1946 /* locate each component, write separators */
1947 diacritic_component = dststr + 2*unicode_len ;
1948 *diacritic_component++ = '\1';
1949 case_component = diacritic_component + diacritic_len ;
1950 *case_component++ = '\1';
1951 delayed_punctuation_component = case_component + case_len ;
1952 *delayed_punctuation_component++ = '\1';
1953 *delayed_punctuation_component++ = '\1';
1955 /* read source string char by char, write
1956 corresponding weight in each component. */
1957 for (i=0,count=0;i<srclen;i++)
1959 unsigned char source_char=srcstr[i];
1960 if (source_char!='\0')
1963 type = LCM_Unicode_LUT[-2+2*source_char];
1964 longcode = type >> 4;
1966 if (!flag_stringsort && OLE2NLS_isPunctuation(source_char))
1968 UINT16 encrypted_location = (1<<15) + 7 + 4*count;
1969 *delayed_punctuation_component++ = (unsigned char) (encrypted_location>>8);
1970 *delayed_punctuation_component++ = (unsigned char) (encrypted_location&255);
1971 /* big-endian is used here because it lets string comparison be
1972 compatible with numerical comparison */
1974 *delayed_punctuation_component++ = type;
1975 *delayed_punctuation_component++ = LCM_Unicode_LUT[-1+2*source_char];
1976 /* assumption : a punctuation character is never a
1977 double or accented letter */
1981 dststr[2*count] = type;
1982 dststr[2*count+1] = LCM_Unicode_LUT[-1+2*source_char];
1986 case_component[count] = ( isupper(source_char) ? 18 : 2 ) ;
1987 if (count<diacritic_len)
1988 diacritic_component[count] = 2; /* assumption: a double letter
1989 is never accented */
1992 dststr[2*count] = type;
1993 dststr[2*count+1] = *(LCM_Unicode_LUT_2 - 1 + longcode);
1994 /* 16 in the first column of LCM_Unicode_LUT --> longcode = 1
1995 32 in the first column of LCM_Unicode_LUT --> longcode = 2
1996 48 in the first column of LCM_Unicode_LUT --> longcode = 3 */
2000 case_component[count] = ( isupper(source_char) ? 18 : 2 ) ;
2001 if (count<diacritic_len)
2003 int ofs = source_char - LCM_Diacritic_Start;
2004 diacritic_component[count] = (ofs>=0 ? LCM_Diacritic_LUT[ofs] : 2);
2010 dststr[room-1] = '\0';
2015 /*************************************************************************
2016 * LCMapString32W [KERNEL32.493]
2018 * Convert a string, or generate a sort key from it.
2022 * See LCMapString32A for documentation
2024 INT32 WINAPI LCMapString32W(
2025 LCID lcid,DWORD mapflags,LPCWSTR srcstr,INT32 srclen,LPWSTR dststr,
2030 TRACE(string,"(0x%04lx,0x%08lx,%p,%d,%p,%d)\n",
2031 lcid,mapflags,srcstr,srclen,dststr,dstlen);
2033 if ( ((dstlen!=0) && (dststr==NULL)) || (srcstr==NULL) )
2035 ERR(ole, "(src=%p,dst=%p): Invalid NULL string\n", srcstr, dststr);
2036 SetLastError(ERROR_INVALID_PARAMETER);
2040 srclen = lstrlen32W(srcstr)+1;
2041 if (mapflags & LCMAP_SORTKEY)
2043 FIXME(string,"(0x%04lx,0x%08lx,%p,%d,%p,%d): "
2044 "unimplemented flags: 0x%08lx\n",
2045 lcid,mapflags,srcstr,srclen,dststr,dstlen,mapflags);
2050 int (*f)(int)=identity;
2056 if (mapflags & LCMAP_UPPERCASE)
2058 else if (mapflags & LCMAP_LOWERCASE)
2060 for (i=0; i < srclen; i++)
2061 dststr[i] = (WCHAR) f(srcstr[i]);
2066 /***********************************************************************
2067 * CompareString16 (OLE2NLS.8)
2069 UINT16 WINAPI CompareString16(DWORD lcid,DWORD fdwStyle,
2070 LPCSTR s1,DWORD l1,LPCSTR s2,DWORD l2)
2072 return (UINT16)CompareString32A(lcid,fdwStyle,s1,l1,s2,l2);
2075 /******************************************************************************
2076 * CompareString32A [KERNEL32.143]
2077 * Compares two strings using locale
2081 * success: CSTR_LESS_THAN, CSTR_EQUAL, CSTR_GREATER_THAN
2086 * Defaults to a word sort, but uses a string sort if
2087 * SORT_STRINGSORT is set.
2088 * Calls SetLastError for ERROR_INVALID_FLAGS, ERROR_INVALID_PARAMETER.
2092 * This implementation ignores the locale
2096 * Quite inefficient.
2098 UINT32 WINAPI CompareString32A(
2099 DWORD lcid, /* locale ID */
2100 DWORD fdwStyle, /* comparison-style options */
2101 LPCSTR s1, /* first string */
2102 DWORD l1, /* length of first string */
2103 LPCSTR s2, /* second string */
2104 DWORD l2) /* length of second string */
2106 int mapstring_flags;
2110 TRACE(ole,"%s and %s\n",
2111 debugstr_a (s1), debugstr_a (s2));
2113 if ( (s1==NULL) || (s2==NULL) )
2115 ERR(ole, "(s1=%s,s2=%s): Invalid NULL string\n", s1, s2);
2116 SetLastError(ERROR_INVALID_PARAMETER);
2120 if(fdwStyle & NORM_IGNORESYMBOLS)
2121 FIXME(ole, "IGNORESYMBOLS not supported\n");
2123 mapstring_flags = LCMAP_SORTKEY | fdwStyle ;
2124 len1 = LCMapString32A(lcid,mapstring_flags,s1,l1,NULL,0);
2125 len2 = LCMapString32A(lcid,mapstring_flags,s2,l2,NULL,0);
2127 if ((len1==0)||(len2==0))
2128 return 0; /* something wrong happened */
2130 sk1 = (LPSTR)HeapAlloc(GetProcessHeap(),0,len1);
2131 sk2 = (LPSTR)HeapAlloc(GetProcessHeap(),0,len2);
2132 if ( (!LCMapString32A(lcid,mapstring_flags,s1,l1,sk1,len1))
2133 || (!LCMapString32A(lcid,mapstring_flags,s2,l2,sk2,len2)) )
2135 ERR(ole,"Bug in LCmapString32A.\n");
2140 /* strcmp doesn't necessarily return -1, 0, or 1 */
2141 result = strcmp(sk1,sk2);
2143 HeapFree(GetProcessHeap(),0,sk1);
2144 HeapFree(GetProcessHeap(),0,sk2);
2151 /* must be greater, if we reach this point */
2155 /******************************************************************************
2156 * CompareString32W [KERNEL32.144]
2157 * This implementation ignores the locale
2158 * FIXME : Does only string sort. Should
2159 * be reimplemented the same way as CompareString32A.
2161 UINT32 WINAPI CompareString32W(DWORD lcid, DWORD fdwStyle,
2162 LPCWSTR s1, DWORD l1, LPCWSTR s2,DWORD l2)
2165 if(fdwStyle & NORM_IGNORENONSPACE)
2166 FIXME(ole,"IGNORENONSPACE not supprted\n");
2167 if(fdwStyle & NORM_IGNORESYMBOLS)
2168 FIXME(ole,"IGNORESYMBOLS not supported\n");
2170 /* Is strcmp defaulting to string sort or to word sort?? */
2171 /* FIXME: Handle NORM_STRINGSORT */
2172 l1 = (l1==-1)?lstrlen32W(s1):l1;
2173 l2 = (l2==-1)?lstrlen32W(s2):l2;
2174 len = l1<l2 ? l1:l2;
2175 ret = (fdwStyle & NORM_IGNORECASE) ?
2176 lstrncmpi32W(s1,s2,len) : lstrncmp32W(s1,s2,len);
2177 /* not equal, return 1 or 3 */
2178 if(ret!=0) return ret+2;
2179 /* same len, return 2 */
2180 if(l1==l2) return 2;
2181 /* the longer one is lexically greater */
2182 return (l1<l2)? 1 : 3;
2185 /******************************************************************************
2186 * OLE_GetFormatA [Internal]
2189 * Why is it WINAPI if internal?
2191 This function implements stuff for GetDateFormat() and
2194 d single-digit (no leading zero) day (of month)
2195 dd two-digit day (of month)
2196 ddd short day-of-week name
2197 dddd long day-of-week name
2198 M single-digit month
2200 MMM short month name
2201 MMMM full month name
2202 y two-digit year, no leading 0
2204 yyyy four-digit year
2206 h hours with no leading zero (12-hour)
2207 hh hours with full two digits
2208 H hours with no leading zero (24-hour)
2209 HH hours with full two digits
2210 m minutes with no leading zero
2211 mm minutes with full two digits
2212 s seconds with no leading zero
2213 ss seconds with full two digits
2214 t time marker (A or P)
2215 tt time marker (AM, PM)
2216 '' used to quote literal characters
2217 '' (within a quoted string) indicates a literal '
2219 These functions REQUIRE valid locale, date, and format.
2221 INT32 WINAPI OLE_GetFormatA(LCID locale,
2226 LPSTR date, INT32 datelen)
2228 INT32 inpos, outpos;
2229 int count, type, inquote, Overflow;
2235 const char * _dgfmt[] = { "%d", "%02d" };
2236 const char ** dgfmt = _dgfmt - 1;
2238 /* report, for debugging */
2239 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",
2240 locale, flags, tflags,
2241 xtime->wDay, xtime->wHour, xtime->wMinute, xtime->wSecond,
2242 format, format, date, date, datelen);
2244 /* initalize state variables and output buffer */
2246 count = 0; inquote = 0; Overflow = 0;
2248 date[0] = buf[0] = '\0';
2250 strcpy(format,_format);
2252 /* alter the formatstring, while it works for all languages now in wine
2253 its possible that it fails when the time looks like ss:mm:hh as example*/
2254 if (tflags & (TIME_NOMINUTESORSECONDS))
2255 { if ((pos = strstr ( format, ":mm")))
2256 { memcpy ( pos, pos+3, strlen(format)-(pos-format)-2 );
2259 if (tflags & (TIME_NOSECONDS))
2260 { if ((pos = strstr ( format, ":ss")))
2261 { memcpy ( pos, pos+3, strlen(format)-(pos-format)-2 );
2265 for (inpos = 0;; inpos++) {
2266 /* 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]); */
2268 if (format[inpos] == '\'') {
2269 if (format[inpos+1] == '\'') {
2271 date[outpos++] = '\'';
2274 continue; /* we did nothing to the output */
2276 } else if (format[inpos] == '\0') {
2277 date[outpos++] = '\0';
2278 if (outpos > datelen) Overflow = 1;
2281 date[outpos++] = format[inpos];
2282 if (outpos > datelen) {
2284 date[outpos-1] = '\0'; /* this is the last place where
2285 it's safe to write */
2289 } else if ( (count && (format[inpos] != type))
2291 || (count == 2 && strchr("ghHmst", type)) )
2295 GetLocaleInfo32A(locale,
2297 + xtime->wDayOfWeek - 1,
2299 } else if (count == 3) {
2300 GetLocaleInfo32A(locale,
2301 LOCALE_SABBREVDAYNAME1
2302 + xtime->wDayOfWeek - 1,
2305 sprintf(buf, dgfmt[count], xtime->wDay);
2307 } else if (type == 'M') {
2309 GetLocaleInfo32A(locale,
2310 LOCALE_SABBREVMONTHNAME1
2311 + xtime->wMonth - 1,
2313 } else if (count == 4) {
2314 GetLocaleInfo32A(locale,
2316 + xtime->wMonth - 1,
2319 sprintf(buf, dgfmt[count], xtime->wMonth);
2321 } else if (type == 'y') {
2323 sprintf(buf, "%d", xtime->wYear);
2324 } else if (count == 3) {
2326 WARN(ole, "unknown format, c=%c, n=%d\n", type, count);
2328 sprintf(buf, dgfmt[count], xtime->wYear % 100);
2330 } else if (type == 'g') {
2332 FIXME(ole, "LOCALE_ICALENDARTYPE unimp.\n");
2336 WARN(ole, "unknown format, c=%c, n=%d\n", type, count);
2338 } else if (type == 'h') {
2339 /* gives us hours 1:00 -- 12:00 */
2340 sprintf(buf, dgfmt[count], (xtime->wHour-1)%12 +1);
2341 } else if (type == 'H') {
2343 sprintf(buf, dgfmt[count], xtime->wHour);
2344 } else if ( type == 'm') {
2345 sprintf(buf, dgfmt[count], xtime->wMinute);
2346 } else if ( type == 's') {
2347 sprintf(buf, dgfmt[count], xtime->wSecond);
2348 } else if (type == 't') {
2350 sprintf(buf, "%c", (xtime->wHour < 12) ? 'A' : 'P');
2351 } else if (count == 2) {
2352 /* sprintf(buf, "%s", (xtime->wHour < 12) ? "AM" : "PM"); */
2353 GetLocaleInfo32A(locale,
2355 ? LOCALE_S1159 : LOCALE_S2359,
2360 /* we need to check the next char in the format string
2361 again, no matter what happened */
2364 /* add the contents of buf to the output */
2365 buflen = strlen(buf);
2366 if (outpos + buflen < datelen) {
2367 date[outpos] = '\0'; /* for strcat to hook onto */
2371 date[outpos] = '\0';
2372 strncat(date, buf, datelen - outpos);
2373 date[datelen - 1] = '\0';
2374 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2375 WARN(ole, "insufficient buffer\n");
2379 /* reset the variables we used to keep track of this item */
2382 } else if (format[inpos] == '\0') {
2383 /* we can't check for this at the loop-head, because
2384 that breaks the printing of the last format-item */
2385 date[outpos] = '\0';
2388 /* continuing a code for an item */
2391 } else if (strchr("hHmstyMdg", format[inpos])) {
2392 type = format[inpos];
2395 } else if (format[inpos] == '\'') {
2399 date[outpos++] = format[inpos];
2401 /* now deal with a possible buffer overflow */
2402 if (outpos >= datelen) {
2403 date[datelen - 1] = '\0';
2404 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2410 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2413 /* finish it off with a string terminator */
2416 if (outpos > datelen-1) outpos = datelen-1;
2417 date[outpos] = '\0';
2419 TRACE(ole, "OLE_GetFormatA returns string '%s', len %d\n",
2424 /******************************************************************************
2425 * OLE_GetFormatW [INTERNAL]
2427 INT32 WINAPI OLE_GetFormatW(LCID locale, DWORD flags, DWORD tflags,
2430 LPWSTR output, INT32 outlen)
2432 INT32 inpos, outpos;
2433 int count, type=0, inquote;
2434 int Overflow; /* loop check */
2435 int usedate, usetime;
2439 WCHAR arg0[] = {0}, arg1[] = {'%','d',0};
2440 WCHAR arg2[] = {'%','0','2','d',0};
2441 WCHAR *argarr[] = {arg0, arg1, arg2};
2442 int datevars=0, timevars=0;
2444 /* make a debug report */
2445 lstrcpynWtoA(abuf, format, sizeof(format));
2446 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",
2447 locale, flags, tflags,
2448 xtime->wDay, xtime->wHour, xtime->wMinute, xtime->wSecond,
2449 abuf, format, output, outlen);
2452 /* initialize state variables */
2455 inquote = Overflow = 0;
2456 /* this is really just a sanity check */
2457 output[0] = buf[0] = 0;
2459 /* for compatibility with official Windows behavior */
2460 usedate = flags & DATE_DATEVARSONLY;
2461 usetime = flags & TIME_TIMEVARSONLY;
2463 /* this loop is the core of the function */
2464 for (inpos = 0; /* we have several break points */ ; inpos++) {
2466 if (format[inpos] == (WCHAR) '\'') {
2467 if (format[inpos+1] == '\'') {
2469 output[outpos++] = '\'';
2474 } else if (format[inpos] == 0) {
2475 output[outpos++] = 0;
2476 if (outpos > outlen) Overflow = 1;
2477 break; /* normal exit (within a quote) */
2479 output[outpos++] = format[inpos]; /* copy input */
2480 if (outpos > outlen) {
2482 output[outpos-1] = 0;
2486 } else if ( (count && (format[inpos] != type))
2487 || ( (count==4 && type =='y') ||
2488 (count==4 && type =='M') ||
2489 (count==4 && type =='d') ||
2490 (count==2 && type =='g') ||
2491 (count==2 && type =='h') ||
2492 (count==2 && type =='H') ||
2493 (count==2 && type =='m') ||
2494 (count==2 && type =='s') ||
2495 (count==2 && type =='t') ) ) {
2498 GetLocaleInfo32W(locale,
2499 LOCALE_SDAYNAME1 + xtime->wDayOfWeek -1,
2500 buf, sizeof(buf)/sizeof(WCHAR) );
2501 } else if (count == 3) {
2502 GetLocaleInfo32W(locale,
2503 LOCALE_SABBREVDAYNAME1 +
2504 xtime->wDayOfWeek -1,
2505 buf, sizeof(buf)/sizeof(WCHAR) );
2507 wsnprintf32W(buf, 5, argarr[count], xtime->wDay );
2509 } else if (type == 'M') {
2511 GetLocaleInfo32W(locale, LOCALE_SMONTHNAME1 +
2512 xtime->wMonth -1, buf,
2513 sizeof(buf)/sizeof(WCHAR) );
2514 } else if (count == 3) {
2515 GetLocaleInfo32W(locale, LOCALE_SABBREVMONTHNAME1 +
2516 xtime->wMonth -1, buf,
2517 sizeof(buf)/sizeof(WCHAR) );
2519 wsnprintf32W(buf, 5, argarr[count], xtime->wMonth);
2521 } else if (type == 'y') {
2523 wsnprintf32W(buf, 6, argarr[1] /* "%d" */,
2525 } else if (count == 3) {
2526 lstrcpynAtoW(buf, "yyy", 5);
2528 wsnprintf32W(buf, 6, argarr[count],
2529 xtime->wYear % 100);
2531 } else if (type == 'g') {
2533 FIXME(ole, "LOCALE_ICALENDARTYPE unimplemented\n");
2534 lstrcpynAtoW(buf, "AD", 5);
2536 /* Win API sez we copy it verbatim */
2537 lstrcpynAtoW(buf, "g", 5);
2539 } else if (type == 'h') {
2540 /* hours 1:00-12:00 --- is this right? */
2541 wsnprintf32W(buf, 5, argarr[count],
2542 (xtime->wHour-1)%12 +1);
2543 } else if (type == 'H') {
2544 wsnprintf32W(buf, 5, argarr[count],
2546 } else if (type == 'm' ) {
2547 wsnprintf32W(buf, 5, argarr[count],
2549 } else if (type == 's' ) {
2550 wsnprintf32W(buf, 5, argarr[count],
2552 } else if (type == 't') {
2553 GetLocaleInfo32W(locale, (xtime->wHour < 12) ?
2554 LOCALE_S1159 : LOCALE_S2359,
2561 /* no matter what happened, we need to check this next
2562 character the next time we loop through */
2565 /* cat buf onto the output */
2566 outlen = lstrlen32W(buf);
2567 if (outpos + buflen < outlen) {
2568 output[outpos] = 0; /* a "hook" for strcat */
2569 lstrcat32W(output, buf);
2573 lstrcatn32W(output, buf, outlen - outpos);
2574 output[outlen - 1] = 0;
2576 break; /* Abnormal exit */
2579 /* reset the variables we used this time */
2582 } else if (format[inpos] == 0) {
2583 /* we can't check for this at the beginning, because that
2584 would keep us from printing a format spec that ended the
2587 break; /* NORMAL EXIT */
2589 /* how we keep track of the middle of a format spec */
2592 } else if ( (datevars && (format[inpos]=='d' ||
2593 format[inpos]=='M' ||
2594 format[inpos]=='y' ||
2595 format[inpos]=='g') ) ||
2596 (timevars && (format[inpos]=='H' ||
2597 format[inpos]=='h' ||
2598 format[inpos]=='m' ||
2599 format[inpos]=='s' ||
2600 format[inpos]=='t') ) ) {
2601 type = format[inpos];
2604 } else if (format[inpos] == '\'') {
2608 /* unquoted literals */
2609 output[outpos++] = format[inpos];
2614 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2615 WARN(ole, " buffer overflow\n");
2618 /* final string terminator and sanity check */
2620 if (outpos > outlen-1) outpos = outlen-1;
2621 output[outpos] = '0';
2623 lstrcpynWtoA(abuf, output, sizeof(abuf) );
2624 TRACE(ole, " returning string \'%s\'\n", abuf);
2626 return (!Overflow) ? outlen : 0;
2631 /******************************************************************************
2632 * GetDateFormat32A [KERNEL32.310]
2633 * Makes an ASCII string of the date
2635 * This function uses format to format the date, or, if format
2636 * is NULL, uses the default for the locale. format is a string
2637 * of literal fields and characters as follows:
2639 * - d single-digit (no leading zero) day (of month)
2640 * - dd two-digit day (of month)
2641 * - ddd short day-of-week name
2642 * - dddd long day-of-week name
2643 * - M single-digit month
2644 * - MM two-digit month
2645 * - MMM short month name
2646 * - MMMM full month name
2647 * - y two-digit year, no leading 0
2648 * - yy two-digit year
2649 * - yyyy four-digit year
2653 INT32 WINAPI GetDateFormat32A(LCID locale,DWORD flags,
2655 LPCSTR format, LPSTR date,INT32 datelen)
2658 char format_buf[40];
2661 LPSYSTEMTIME thistime;
2666 TRACE(ole,"(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",
2667 locale,flags,xtime,format,date,datelen);
2670 locale = LOCALE_SYSTEM_DEFAULT;
2673 if (locale == LOCALE_SYSTEM_DEFAULT) {
2674 thislocale = GetSystemDefaultLCID();
2675 } else if (locale == LOCALE_USER_DEFAULT) {
2676 thislocale = GetUserDefaultLCID();
2678 thislocale = locale;
2681 if (xtime == NULL) {
2688 if (format == NULL) {
2689 GetLocaleInfo32A(thislocale, ((flags&DATE_LONGDATE)
2691 : LOCALE_SSHORTDATE),
2692 format_buf, sizeof(format_buf));
2693 thisformat = format_buf;
2695 thisformat = format;
2699 ret = OLE_GetFormatA(thislocale, flags, 0, thistime, thisformat,
2704 "GetDateFormat32A() returning %d, with data=%s\n",
2709 /******************************************************************************
2710 * GetDateFormat32W [KERNEL32.311]
2711 * Makes a Unicode string of the date
2713 * Acts the same as GetDateFormat32A(), except that it's Unicode.
2714 * Accepts & returns sizes as counts of Unicode characters.
2717 INT32 WINAPI GetDateFormat32W(LCID locale,DWORD flags,
2720 LPWSTR date, INT32 datelen)
2722 short datearr[] = {'1','9','9','4','-','1','-','1',0};
2724 FIXME(ole, "STUB (should call OLE_GetFormatW)\n");
2725 lstrcpyn32W(date, datearr, datelen);
2726 return ( datelen < 9) ? datelen : 9;
2731 /**************************************************************************
2732 * EnumDateFormats32A (KERNEL32.198)
2734 BOOL32 WINAPI EnumDateFormats32A(
2735 DATEFMT_ENUMPROC32A lpDateFmtEnumProc, LCID Locale, DWORD dwFlags)
2737 FIXME(ole, "Only US English supported\n");
2739 if(!lpDateFmtEnumProc)
2741 SetLastError(ERROR_INVALID_PARAMETER);
2747 case DATE_SHORTDATE:
2748 if(!(*lpDateFmtEnumProc)("M/d/yy")) return TRUE;
2749 if(!(*lpDateFmtEnumProc)("M/d/yyyy")) return TRUE;
2750 if(!(*lpDateFmtEnumProc)("MM/dd/yy")) return TRUE;
2751 if(!(*lpDateFmtEnumProc)("MM/dd/yyyy")) return TRUE;
2752 if(!(*lpDateFmtEnumProc)("yy/MM/dd")) return TRUE;
2753 if(!(*lpDateFmtEnumProc)("dd-MMM-yy")) return TRUE;
2756 if(!(*lpDateFmtEnumProc)("dddd, MMMM dd, yyyy")) return TRUE;
2757 if(!(*lpDateFmtEnumProc)("MMMM dd, yyyy")) return TRUE;
2758 if(!(*lpDateFmtEnumProc)("dddd, dd MMMM, yyyy")) return TRUE;
2759 if(!(*lpDateFmtEnumProc)("dd MMMM, yyyy")) return TRUE;
2762 FIXME(ole, "Unknown date format (%ld)\n", dwFlags);
2763 SetLastError(ERROR_INVALID_PARAMETER);
2768 /**************************************************************************
2769 * EnumDateFormats32W (KERNEL32.199)
2771 BOOL32 WINAPI EnumDateFormats32W(
2772 DATEFMT_ENUMPROC32W lpDateFmtEnumProc, LCID Locale, DWORD dwFlags)
2774 FIXME(ole, "(%p, %ld, %ld): stub\n", lpDateFmtEnumProc, Locale, dwFlags);
2775 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
2779 /**************************************************************************
2780 * EnumTimeFormats32A (KERNEL32.210)
2782 BOOL32 WINAPI EnumTimeFormats32A(
2783 TIMEFMT_ENUMPROC32A lpTimeFmtEnumProc, LCID Locale, DWORD dwFlags)
2785 FIXME(ole, "Only US English supported\n");
2787 if(!lpTimeFmtEnumProc)
2789 SetLastError(ERROR_INVALID_PARAMETER);
2795 FIXME(ole, "Unknown time format (%ld)\n", dwFlags);
2798 if(!(*lpTimeFmtEnumProc)("h:mm:ss tt")) return TRUE;
2799 if(!(*lpTimeFmtEnumProc)("hh:mm:ss tt")) return TRUE;
2800 if(!(*lpTimeFmtEnumProc)("H:mm:ss")) return TRUE;
2801 if(!(*lpTimeFmtEnumProc)("HH:mm:ss")) return TRUE;
2806 /**************************************************************************
2807 * EnumTimeFormats32W (KERNEL32.211)
2809 BOOL32 WINAPI EnumTimeFormats32W(
2810 TIMEFMT_ENUMPROC32W lpTimeFmtEnumProc, LCID Locale, DWORD dwFlags)
2812 FIXME(ole, "(%p,%ld,%ld): stub", lpTimeFmtEnumProc, Locale, dwFlags);
2813 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
2817 /**************************************************************************
2818 * GetNumberFormat32A (KERNEL32.355)
2819 * NOTE: type of lpFormat should be CONST NUMBERFORMAT
2821 INT32 WINAPI GetNumberFormat32A(LCID locale, DWORD dwflags,
2822 LPCSTR lpvalue, char *lpFormat,
2823 LPSTR lpNumberStr, int cchNumber)
2827 FIXME(file,"%s: stub, no reformating done\n",lpvalue);
2829 n = strlen(lpvalue);
2831 strncpy(lpNumberStr,lpvalue,cchNumber);
2832 if (cchNumber <= n) {
2833 lpNumberStr[cchNumber-1] = 0;
2842 /******************************************************************************
2843 * GetTimeFormat32A [KERNEL32.422]
2844 * Makes an ASCII string of the time
2846 * Formats date according to format, or locale default if format is
2847 * NULL. The format consists of literal characters and fields as follows:
2849 * h hours with no leading zero (12-hour)
2850 * hh hours with full two digits
2851 * H hours with no leading zero (24-hour)
2852 * HH hours with full two digits
2853 * m minutes with no leading zero
2854 * mm minutes with full two digits
2855 * s seconds with no leading zero
2856 * ss seconds with full two digits
2857 * t time marker (A or P)
2858 * tt time marker (AM, PM)
2862 GetTimeFormat32A(LCID locale, /* in */
2863 DWORD flags, /* in */
2864 LPSYSTEMTIME xtime, /* in */
2865 LPCSTR format, /* in */
2866 LPSTR timestr, /* out */
2867 INT32 timelen /* in */)
2868 { char format_buf[40];
2871 LPSYSTEMTIME thistime;
2873 DWORD thisflags=LOCALE_STIMEFORMAT; /* standart timeformat */;
2875 TRACE(ole,"GetTimeFormat(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",locale,flags,xtime,format,timestr,timelen);
2878 { locale = LOCALE_SYSTEM_DEFAULT;
2881 if (locale == LOCALE_SYSTEM_DEFAULT)
2882 { thislocale = GetSystemDefaultLCID();
2884 else if (locale == LOCALE_USER_DEFAULT)
2885 { thislocale = GetUserDefaultLCID();
2888 { thislocale = locale;
2891 if ( flags & (TIME_NOTIMEMARKER | TIME_FORCE24HOURFORMAT ))
2892 { FIXME(ole,"TIME_NOTIMEMARKER or TIME_FORCE24HOURFORMAT not implemented\n");
2894 flags &= (TIME_NOSECONDS | TIME_NOMINUTESORSECONDS); /* mask for OLE_GetFormatA*/
2897 { if (flags & LOCALE_NOUSEROVERRIDE) /*use system default*/
2898 { thislocale = GetSystemDefaultLCID();
2900 GetLocaleInfo32A(thislocale, thisflags, format_buf, sizeof(format_buf));
2901 thisformat = format_buf;
2904 { thisformat = format;
2907 if (xtime == NULL) /* NULL means use the current local time*/
2908 { GetSystemTime(&t);
2914 return OLE_GetFormatA(thislocale, thisflags, flags, thistime, thisformat, timestr, timelen);
2918 /******************************************************************************
2919 * GetTimeFormat32W [KERNEL32.423]
2920 * Makes a Unicode string of the time
2923 GetTimeFormat32W(LCID locale,DWORD flags,
2926 LPWSTR timestr,INT32 timelen)
2930 LPCWSTR realformat=0;
2932 LPSYSTEMTIME realtime;
2933 WCHAR * fmt_buf = NULL;
2934 int fmt_buf_size = 0; /* units of WCHARs */
2937 lstrcpynWtoA(debugbuf, format, (sizeof(buf))/2);
2938 TRACE(ole, "GetTimeFormatW len %d flags 0x%lX format >%s<\n",
2939 timelen, flags, debugbuf);
2941 /* Enforce the Windows behavior */
2942 flags |= ~LOCALE_TIMEDATEBOTH;
2943 flags |= TIME_TIMEVARSONLY;
2945 /* take care of the format or locale not being given */
2947 realformat = format;
2948 } else if (locale) {
2949 /* allocate memory */
2950 retval = ERROR_INSUFFICIENT_BUFFER;
2951 fmt_buf = malloc((fmt_buf_size+=7) * sizeof(WCHAR));
2955 while(!GetLocaleInfo32W(locale, LOCALE_STIMEFORMAT,
2956 fmt_buf, fmt_buf_size)) {
2957 retval = ERROR_OUTOFMEMORY;
2958 fmt_buf = realloc(fmt_buf,
2959 (fmt_buf_size += 10) * sizeof(WCHAR));
2963 realformat = fmt_buf;
2965 FIXME(ole, "caller gave no locale, no format; what should we do?\n");
2966 SetLastError(ERROR_BAD_FORMAT);
2969 locale = GetSystemDefaultLCID();
2974 GetSystemTime(realtime);
2977 retval = OLE_GetFormatW(locale, flags, 0, realtime, realformat, timestr, timelen);
2983 SetLastError(retval);
2984 WARN(ole, "could not allocate %d chars of memory\n", fmt_buf_size);