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 * GetLocaleInfo16 [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
,"(lcid=0x%lx,lctype=0x%lx,%p,%x)\n",
420 lcid
,LCType
,buf
,len
);
422 if (lcid
== LOCALE_SYSTEM_DEFAULT
|| (LCType
& LOCALE_NOUSEROVERRIDE
) )
423 { lcid
= GetSystemDefaultLCID();
425 else if (lcid
== LOCALE_USER_DEFAULT
)
426 { lcid
= GetUserDefaultLCID();
429 LCType
&= ~(LOCALE_NOUSEROVERRIDE
|LOCALE_USE_CP_ACP
);
431 /* As an option, we could obtain the value from win.ini.
432 This would not match the Wine compile-time option.
433 Also, not all identifiers are available from win.ini */
435 /* If we are through all of this, retLen should not be zero anymore.
436 If it is, the value is not supported */
438 while (locale_name2id
[i
].name
!=NULL
) {
439 if (LCType
== locale_name2id
[i
].id
) {
440 retString
= locale_name2id
[i
].name
;
446 WARN(ole
,"Unkown LC type %lX\n",LCType
);
450 #define LOCVAL(type,value) case type:retString=value;found=1;break;
451 #define LANG_BEGIN(l,s) case MAKELANGID(l,s): switch (LCType) {
452 #define LANG_END default: found=0; break; } break;
454 /* Now, the language specific definitions. They don't have to be
457 found
=0; i
=0; lang
=lcid
;
459 if (lang
==0x400) /*LANG_NEUTRAL ==> US English*/
461 WARN(ole
,"no language set, assume LANG_ENGLISH_US \n");
469 LANG_BEGIN (LANG_GERMAN
, SUBLANG_GERMAN
) /*0x407*/
470 #include "nls/deu.nls"
473 LANG_BEGIN (LANG_DANISH
, SUBLANG_DEFAULT
) /*0x406*/
474 #include "nls/dan.nls"
477 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_US
) /*0x409*/
478 #include "nls/enu.nls"
481 LANG_BEGIN (LANG_ESPERANTO
, SUBLANG_DEFAULT
) /*0x48f*/
482 #include "nls/esperanto.nls"
485 LANG_BEGIN (LANG_FINNISH
, SUBLANG_DEFAULT
) /*0x040B*/
486 #include "nls/fin.nls"
489 LANG_BEGIN (LANG_ITALIAN
, SUBLANG_ITALIAN
) /*0x410*/
490 #include "nls/ita.nls"
493 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_UK
) /*0x809*/
494 #include "nls/eng.nls"
497 LANG_BEGIN (LANG_KOREAN
, SUBLANG_KOREAN
) /*0x412*/
498 #include "nls/kor.nls"
501 LANG_BEGIN (LANG_HUNGARIAN
, SUBLANG_DEFAULT
) /*0x40e*/
502 #include "nls/hun.nls"
505 LANG_BEGIN (LANG_POLISH
, SUBLANG_DEFAULT
) /*0x415*/
506 #include "nls/plk.nls"
509 LANG_BEGIN (LANG_PORTUGUESE
,SUBLANG_PORTUGUESE_BRAZILIAN
) /*0x416*/
510 #include "nls/ptb.nls"
513 LANG_BEGIN (LANG_SWEDISH
, SUBLANG_DEFAULT
) /*0x41d*/
514 #include "nls/sve.nls"
517 /*Insert other languages here*/
524 /* language not found, try without a sublanguage*/
525 lang
=MAKELANGID( PRIMARYLANGID(lang
), SUBLANG_DEFAULT
);
527 } while (!found
&& i
<2);
530 ERR(ole
,"'%s' not supported for your language.\n",
532 retString
= "<WINE-NLS-unknown>";
535 lstrcpyn32A(buf
,retString
,len
);
536 return strlen(retString
)+1;
539 /******************************************************************************
540 * GetLocaleInfo32W [KERNEL32.343]
542 * Is the last parameter really WORD for Win16?
544 INT32 WINAPI
GetLocaleInfo32W(LCID lcid
,LCTYPE LCType
,LPWSTR wbuf
,INT32 len
)
546 LPSTR abuf
= (LPSTR
)HeapAlloc(GetProcessHeap(),0,len
);
548 INT32 n
= GetLocaleInfo32A(lcid
, LCType
, abuf
, len
);
550 lstrcpynAtoW(wbuf
,abuf
,len
);
551 HeapFree(GetProcessHeap(),0,abuf
);
555 /******************************************************************************
556 * SetLocaleInfoA [KERNEL32.656]
558 BOOL16 WINAPI
SetLocaleInfoA(DWORD lcid
, DWORD lctype
, LPCSTR data
)
560 FIXME(ole
,"(%ld,%ld,%s): stub\n",lcid
,lctype
,data
);
564 /******************************************************************************
565 * IsValidLocale [KERNEL32.489]
567 BOOL32 WINAPI
IsValidLocale(LCID lcid
,DWORD flags
)
569 /* we support ANY language. Well, at least say that...*/
573 /******************************************************************************
574 * EnumSystemLocales32W [KERNEL32.209]
576 BOOL32 WINAPI
EnumSystemLocales32W( LOCALE_ENUMPROC32W lpfnLocaleEnum
,
584 TRACE(win32
,"(%p,%08lx)\n",lpfnLocaleEnum
,flags
);
585 /* see if we can reuse the Win95 registry entries.... */
586 if (ERROR_SUCCESS
==RegOpenKey32A(HKEY_LOCAL_MACHINE
,"\\System\\CurrentControlSet\\control\\Nls\\Locale\\",&xhkey
)) {
589 if (ERROR_SUCCESS
!=RegEnumKey32W(xhkey
,i
,buffer
,sizeof(buffer
)))
591 if (!lpfnLocaleEnum(buffer
))
600 while (languages
[i
].langname
!=NULL
)
605 sprintf(xbuffer
,"%08lx",(DWORD
)languages
[i
].langid
);
607 cp
= HEAP_strdupAtoW( GetProcessHeap(), 0, xbuffer
);
608 ret
= lpfnLocaleEnum(cp
);
609 HeapFree( GetProcessHeap(), 0, cp
);
616 /******************************************************************************
617 * EnumSystemLocales32A [KERNEL32.208]
619 BOOL32 WINAPI
EnumSystemLocales32A(LOCALE_ENUMPROC32A lpfnLocaleEnum
,
626 TRACE(win32
,"(%p,%08lx)\n",
629 if (ERROR_SUCCESS
==RegOpenKey32A(HKEY_LOCAL_MACHINE
,"\\System\\CurrentControlSet\\control\\Nls\\Locale\\",&xhkey
)) {
632 if (ERROR_SUCCESS
!=RegEnumKey32A(xhkey
,i
,buffer
,sizeof(buffer
)))
634 if (!lpfnLocaleEnum(buffer
))
642 while (languages
[i
].langname
!=NULL
) {
643 sprintf(buffer
,"%08lx",(DWORD
)languages
[i
].langid
);
644 if (!lpfnLocaleEnum(buffer
))
651 static const unsigned char CT_CType2_LUT
[] = {
652 C2_NOTAPPLICABLE
, /* - 0 */
653 C2_NOTAPPLICABLE
, /* - 1 */
654 C2_NOTAPPLICABLE
, /* - 2 */
655 C2_NOTAPPLICABLE
, /* - 3 */
656 C2_NOTAPPLICABLE
, /* - 4 */
657 C2_NOTAPPLICABLE
, /* - 5 */
658 C2_NOTAPPLICABLE
, /* - 6 */
659 C2_NOTAPPLICABLE
, /* - 7 */
660 C2_NOTAPPLICABLE
, /* - 8 */
661 C2_SEGMENTSEPARATOR
, /* - 9 */
662 C2_NOTAPPLICABLE
, /* - 10 */
663 C2_NOTAPPLICABLE
, /* - 11 */
664 C2_NOTAPPLICABLE
, /* - 12 */
665 C2_NOTAPPLICABLE
, /* - 13 */
666 C2_NOTAPPLICABLE
, /* - 14 */
667 C2_NOTAPPLICABLE
, /* - 15 */
668 C2_NOTAPPLICABLE
, /* - 16 */
669 C2_NOTAPPLICABLE
, /* - 17 */
670 C2_NOTAPPLICABLE
, /* - 18 */
671 C2_NOTAPPLICABLE
, /* - 19 */
672 C2_NOTAPPLICABLE
, /* - 20 */
673 C2_NOTAPPLICABLE
, /* - 21 */
674 C2_NOTAPPLICABLE
, /* - 22 */
675 C2_NOTAPPLICABLE
, /* - 23 */
676 C2_NOTAPPLICABLE
, /* - 24 */
677 C2_NOTAPPLICABLE
, /* - 25 */
678 C2_NOTAPPLICABLE
, /* - 26 */
679 C2_NOTAPPLICABLE
, /* - 27 */
680 C2_NOTAPPLICABLE
, /* - 28 */
681 C2_NOTAPPLICABLE
, /* - 29 */
682 C2_NOTAPPLICABLE
, /* - 30 */
683 C2_NOTAPPLICABLE
, /* - 31 */
684 C2_WHITESPACE
, /* - 32 */
685 C2_OTHERNEUTRAL
, /* ! - 33 */
686 C2_OTHERNEUTRAL
, /* " - 34 */ /* " */
687 C2_EUROPETERMINATOR
, /* # - 35 */
688 C2_EUROPETERMINATOR
, /* $ - 36 */
689 C2_EUROPETERMINATOR
, /* % - 37 */
690 C2_LEFTTORIGHT
, /* & - 38 */
691 C2_OTHERNEUTRAL
, /* ' - 39 */
692 C2_OTHERNEUTRAL
, /* ( - 40 */
693 C2_OTHERNEUTRAL
, /* ) - 41 */
694 C2_OTHERNEUTRAL
, /* * - 42 */
695 C2_EUROPETERMINATOR
, /* + - 43 */
696 C2_COMMONSEPARATOR
, /* , - 44 */
697 C2_EUROPETERMINATOR
, /* - - 45 */
698 C2_EUROPESEPARATOR
, /* . - 46 */
699 C2_EUROPESEPARATOR
, /* / - 47 */
700 C2_EUROPENUMBER
, /* 0 - 48 */
701 C2_EUROPENUMBER
, /* 1 - 49 */
702 C2_EUROPENUMBER
, /* 2 - 50 */
703 C2_EUROPENUMBER
, /* 3 - 51 */
704 C2_EUROPENUMBER
, /* 4 - 52 */
705 C2_EUROPENUMBER
, /* 5 - 53 */
706 C2_EUROPENUMBER
, /* 6 - 54 */
707 C2_EUROPENUMBER
, /* 7 - 55 */
708 C2_EUROPENUMBER
, /* 8 - 56 */
709 C2_EUROPENUMBER
, /* 9 - 57 */
710 C2_COMMONSEPARATOR
, /* : - 58 */
711 C2_OTHERNEUTRAL
, /* ; - 59 */
712 C2_OTHERNEUTRAL
, /* < - 60 */
713 C2_OTHERNEUTRAL
, /* = - 61 */
714 C2_OTHERNEUTRAL
, /* > - 62 */
715 C2_OTHERNEUTRAL
, /* ? - 63 */
716 C2_LEFTTORIGHT
, /* @ - 64 */
717 C2_LEFTTORIGHT
, /* A - 65 */
718 C2_LEFTTORIGHT
, /* B - 66 */
719 C2_LEFTTORIGHT
, /* C - 67 */
720 C2_LEFTTORIGHT
, /* D - 68 */
721 C2_LEFTTORIGHT
, /* E - 69 */
722 C2_LEFTTORIGHT
, /* F - 70 */
723 C2_LEFTTORIGHT
, /* G - 71 */
724 C2_LEFTTORIGHT
, /* H - 72 */
725 C2_LEFTTORIGHT
, /* I - 73 */
726 C2_LEFTTORIGHT
, /* J - 74 */
727 C2_LEFTTORIGHT
, /* K - 75 */
728 C2_LEFTTORIGHT
, /* L - 76 */
729 C2_LEFTTORIGHT
, /* M - 77 */
730 C2_LEFTTORIGHT
, /* N - 78 */
731 C2_LEFTTORIGHT
, /* O - 79 */
732 C2_LEFTTORIGHT
, /* P - 80 */
733 C2_LEFTTORIGHT
, /* Q - 81 */
734 C2_LEFTTORIGHT
, /* R - 82 */
735 C2_LEFTTORIGHT
, /* S - 83 */
736 C2_LEFTTORIGHT
, /* T - 84 */
737 C2_LEFTTORIGHT
, /* U - 85 */
738 C2_LEFTTORIGHT
, /* V - 86 */
739 C2_LEFTTORIGHT
, /* W - 87 */
740 C2_LEFTTORIGHT
, /* X - 88 */
741 C2_LEFTTORIGHT
, /* Y - 89 */
742 C2_LEFTTORIGHT
, /* Z - 90 */
743 C2_OTHERNEUTRAL
, /* [ - 91 */
744 C2_OTHERNEUTRAL
, /* \ - 92 */
745 C2_OTHERNEUTRAL
, /* ] - 93 */
746 C2_OTHERNEUTRAL
, /* ^ - 94 */
747 C2_OTHERNEUTRAL
, /* _ - 95 */
748 C2_OTHERNEUTRAL
, /* ` - 96 */
749 C2_LEFTTORIGHT
, /* a - 97 */
750 C2_LEFTTORIGHT
, /* b - 98 */
751 C2_LEFTTORIGHT
, /* c - 99 */
752 C2_LEFTTORIGHT
, /* d - 100 */
753 C2_LEFTTORIGHT
, /* e - 101 */
754 C2_LEFTTORIGHT
, /* f - 102 */
755 C2_LEFTTORIGHT
, /* g - 103 */
756 C2_LEFTTORIGHT
, /* h - 104 */
757 C2_LEFTTORIGHT
, /* i - 105 */
758 C2_LEFTTORIGHT
, /* j - 106 */
759 C2_LEFTTORIGHT
, /* k - 107 */
760 C2_LEFTTORIGHT
, /* l - 108 */
761 C2_LEFTTORIGHT
, /* m - 109 */
762 C2_LEFTTORIGHT
, /* n - 110 */
763 C2_LEFTTORIGHT
, /* o - 111 */
764 C2_LEFTTORIGHT
, /* p - 112 */
765 C2_LEFTTORIGHT
, /* q - 113 */
766 C2_LEFTTORIGHT
, /* r - 114 */
767 C2_LEFTTORIGHT
, /* s - 115 */
768 C2_LEFTTORIGHT
, /* t - 116 */
769 C2_LEFTTORIGHT
, /* u - 117 */
770 C2_LEFTTORIGHT
, /* v - 118 */
771 C2_LEFTTORIGHT
, /* w - 119 */
772 C2_LEFTTORIGHT
, /* x - 120 */
773 C2_LEFTTORIGHT
, /* y - 121 */
774 C2_LEFTTORIGHT
, /* z - 122 */
775 C2_OTHERNEUTRAL
, /* { - 123 */
776 C2_OTHERNEUTRAL
, /* | - 124 */
777 C2_OTHERNEUTRAL
, /* } - 125 */
778 C2_OTHERNEUTRAL
, /* ~ - 126 */
779 C2_NOTAPPLICABLE
, /* \x7f - 127 */
780 C2_NOTAPPLICABLE
, /* € - 128 */
781 C2_NOTAPPLICABLE
, /* � - 129 */
782 C2_OTHERNEUTRAL
, /* ‚ - 130 */
783 C2_LEFTTORIGHT
, /* ƒ - 131 */
784 C2_OTHERNEUTRAL
, /* „ - 132 */
785 C2_OTHERNEUTRAL
, /* … - 133 */
786 C2_OTHERNEUTRAL
, /* † - 134 */
787 C2_OTHERNEUTRAL
, /* ‡ - 135 */
788 C2_LEFTTORIGHT
, /* ˆ - 136 */
789 C2_EUROPETERMINATOR
, /* ‰ - 137 */
790 C2_LEFTTORIGHT
, /* Š - 138 */
791 C2_OTHERNEUTRAL
, /* ‹ - 139 */
792 C2_LEFTTORIGHT
, /* Œ - 140 */
793 C2_NOTAPPLICABLE
, /* � - 141 */
794 C2_NOTAPPLICABLE
, /* Ž - 142 */
795 C2_NOTAPPLICABLE
, /* � - 143 */
796 C2_NOTAPPLICABLE
, /* � - 144 */
797 C2_OTHERNEUTRAL
, /* ‘ - 145 */
798 C2_OTHERNEUTRAL
, /* ’ - 146 */
799 C2_OTHERNEUTRAL
, /* “ - 147 */
800 C2_OTHERNEUTRAL
, /* ” - 148 */
801 C2_OTHERNEUTRAL
, /* • - 149 */
802 C2_OTHERNEUTRAL
, /* – - 150 */
803 C2_OTHERNEUTRAL
, /* — - 151 */
804 C2_LEFTTORIGHT
, /* ˜ - 152 */
805 C2_OTHERNEUTRAL
, /* ™ - 153 */
806 C2_LEFTTORIGHT
, /* š - 154 */
807 C2_OTHERNEUTRAL
, /* › - 155 */
808 C2_LEFTTORIGHT
, /* œ - 156 */
809 C2_NOTAPPLICABLE
, /* � - 157 */
810 C2_NOTAPPLICABLE
, /* ž - 158 */
811 C2_LEFTTORIGHT
, /* Ÿ - 159 */
812 C2_WHITESPACE
, /* - 160 */
813 C2_OTHERNEUTRAL
, /* ¡ - 161 */
814 C2_EUROPETERMINATOR
, /* ¢ - 162 */
815 C2_EUROPETERMINATOR
, /* £ - 163 */
816 C2_EUROPETERMINATOR
, /* ¤ - 164 */
817 C2_EUROPETERMINATOR
, /* ¥ - 165 */
818 C2_OTHERNEUTRAL
, /* ¦ - 166 */
819 C2_OTHERNEUTRAL
, /* § - 167 */
820 C2_OTHERNEUTRAL
, /* ¨ - 168 */
821 C2_OTHERNEUTRAL
, /* © - 169 */
822 C2_OTHERNEUTRAL
, /* ª - 170 */
823 C2_OTHERNEUTRAL
, /* « - 171 */
824 C2_OTHERNEUTRAL
, /* ¬ - 172 */
825 C2_OTHERNEUTRAL
, /* - 173 */
826 C2_OTHERNEUTRAL
, /* ® - 174 */
827 C2_OTHERNEUTRAL
, /* ¯ - 175 */
828 C2_EUROPETERMINATOR
, /* ° - 176 */
829 C2_EUROPETERMINATOR
, /* ± - 177 */
830 C2_EUROPENUMBER
, /* ² - 178 */
831 C2_EUROPENUMBER
, /* ³ - 179 */
832 C2_OTHERNEUTRAL
, /* ´ - 180 */
833 C2_OTHERNEUTRAL
, /* µ - 181 */
834 C2_OTHERNEUTRAL
, /* ¶ - 182 */
835 C2_OTHERNEUTRAL
, /* · - 183 */
836 C2_OTHERNEUTRAL
, /* ¸ - 184 */
837 C2_EUROPENUMBER
, /* ¹ - 185 */
838 C2_OTHERNEUTRAL
, /* º - 186 */
839 C2_OTHERNEUTRAL
, /* » - 187 */
840 C2_OTHERNEUTRAL
, /* ¼ - 188 */
841 C2_OTHERNEUTRAL
, /* ½ - 189 */
842 C2_OTHERNEUTRAL
, /* ¾ - 190 */
843 C2_OTHERNEUTRAL
, /* ¿ - 191 */
844 C2_LEFTTORIGHT
, /* À - 192 */
845 C2_LEFTTORIGHT
, /* Á - 193 */
846 C2_LEFTTORIGHT
, /* Â - 194 */
847 C2_LEFTTORIGHT
, /* Ã - 195 */
848 C2_LEFTTORIGHT
, /* Ä - 196 */
849 C2_LEFTTORIGHT
, /* Å - 197 */
850 C2_LEFTTORIGHT
, /* Æ - 198 */
851 C2_LEFTTORIGHT
, /* Ç - 199 */
852 C2_LEFTTORIGHT
, /* È - 200 */
853 C2_LEFTTORIGHT
, /* É - 201 */
854 C2_LEFTTORIGHT
, /* Ê - 202 */
855 C2_LEFTTORIGHT
, /* Ë - 203 */
856 C2_LEFTTORIGHT
, /* Ì - 204 */
857 C2_LEFTTORIGHT
, /* Í - 205 */
858 C2_LEFTTORIGHT
, /* Î - 206 */
859 C2_LEFTTORIGHT
, /* Ï - 207 */
860 C2_LEFTTORIGHT
, /* Ð - 208 */
861 C2_LEFTTORIGHT
, /* Ñ - 209 */
862 C2_LEFTTORIGHT
, /* Ò - 210 */
863 C2_LEFTTORIGHT
, /* Ó - 211 */
864 C2_LEFTTORIGHT
, /* Ô - 212 */
865 C2_LEFTTORIGHT
, /* Õ - 213 */
866 C2_LEFTTORIGHT
, /* Ö - 214 */
867 C2_OTHERNEUTRAL
, /* × - 215 */
868 C2_LEFTTORIGHT
, /* Ø - 216 */
869 C2_LEFTTORIGHT
, /* Ù - 217 */
870 C2_LEFTTORIGHT
, /* Ú - 218 */
871 C2_LEFTTORIGHT
, /* Û - 219 */
872 C2_LEFTTORIGHT
, /* Ü - 220 */
873 C2_LEFTTORIGHT
, /* Ý - 221 */
874 C2_LEFTTORIGHT
, /* Þ - 222 */
875 C2_LEFTTORIGHT
, /* ß - 223 */
876 C2_LEFTTORIGHT
, /* à - 224 */
877 C2_LEFTTORIGHT
, /* á - 225 */
878 C2_LEFTTORIGHT
, /* â - 226 */
879 C2_LEFTTORIGHT
, /* ã - 227 */
880 C2_LEFTTORIGHT
, /* ä - 228 */
881 C2_LEFTTORIGHT
, /* å - 229 */
882 C2_LEFTTORIGHT
, /* æ - 230 */
883 C2_LEFTTORIGHT
, /* ç - 231 */
884 C2_LEFTTORIGHT
, /* è - 232 */
885 C2_LEFTTORIGHT
, /* é - 233 */
886 C2_LEFTTORIGHT
, /* ê - 234 */
887 C2_LEFTTORIGHT
, /* ë - 235 */
888 C2_LEFTTORIGHT
, /* ì - 236 */
889 C2_LEFTTORIGHT
, /* í - 237 */
890 C2_LEFTTORIGHT
, /* î - 238 */
891 C2_LEFTTORIGHT
, /* ï - 239 */
892 C2_LEFTTORIGHT
, /* ð - 240 */
893 C2_LEFTTORIGHT
, /* ñ - 241 */
894 C2_LEFTTORIGHT
, /* ò - 242 */
895 C2_LEFTTORIGHT
, /* ó - 243 */
896 C2_LEFTTORIGHT
, /* ô - 244 */
897 C2_LEFTTORIGHT
, /* õ - 245 */
898 C2_LEFTTORIGHT
, /* ö - 246 */
899 C2_OTHERNEUTRAL
, /* ÷ - 247 */
900 C2_LEFTTORIGHT
, /* ø - 248 */
901 C2_LEFTTORIGHT
, /* ù - 249 */
902 C2_LEFTTORIGHT
, /* ú - 250 */
903 C2_LEFTTORIGHT
, /* û - 251 */
904 C2_LEFTTORIGHT
, /* ü - 252 */
905 C2_LEFTTORIGHT
, /* ý - 253 */
906 C2_LEFTTORIGHT
, /* þ - 254 */
907 C2_LEFTTORIGHT
/* ÿ - 255 */
910 static const WORD CT_CType3_LUT
[] = {
945 0x0448, /* " - 34 */ /* " */
1000 0x8040, /* Y - 89 */
1001 0x8040, /* Z - 90 */
1002 0x0048, /* [ - 91 */
1003 0x0448, /* \ - 92 */
1004 0x0048, /* ] - 93 */
1005 0x0448, /* ^ - 94 */
1006 0x0448, /* _ - 95 */
1007 0x0448, /* ` - 96 */
1008 0x8040, /* a - 97 */
1009 0x8040, /* b - 98 */
1010 0x8040, /* c - 99 */
1011 0x8040, /* d - 100 */
1012 0x8040, /* e - 101 */
1013 0x8040, /* f - 102 */
1014 0x8040, /* g - 103 */
1015 0x8040, /* h - 104 */
1016 0x8040, /* i - 105 */
1017 0x8040, /* j - 106 */
1018 0x8040, /* k - 107 */
1019 0x8040, /* l - 108 */
1020 0x8040, /* m - 109 */
1021 0x8040, /* n - 110 */
1022 0x8040, /* o - 111 */
1023 0x8040, /* p - 112 */
1024 0x8040, /* q - 113 */
1025 0x8040, /* r - 114 */
1026 0x8040, /* s - 115 */
1027 0x8040, /* t - 116 */
1028 0x8040, /* u - 117 */
1029 0x8040, /* v - 118 */
1030 0x8040, /* w - 119 */
1031 0x8040, /* x - 120 */
1032 0x8040, /* y - 121 */
1033 0x8040, /* z - 122 */
1034 0x0048, /* { - 123 */
1035 0x0048, /* | - 124 */
1036 0x0048, /* } - 125 */
1037 0x0448, /* ~ - 126 */
1038 0x0000, /* \x7f - 127 */
1039 0x0000, /* € - 128 */
1040 0x0000, /* � - 129 */
1041 0x0008, /* ‚ - 130 */
1042 0x8000, /* ƒ - 131 */
1043 0x0008, /* „ - 132 */
1044 0x0008, /* … - 133 */
1045 0x0008, /* † - 134 */
1046 0x0008, /* ‡ - 135 */
1047 0x0001, /* ˆ - 136 */
1048 0x0008, /* ‰ - 137 */
1049 0x8003, /* Š - 138 */
1050 0x0008, /* ‹ - 139 */
1051 0x8000, /* Œ - 140 */
1052 0x0000, /* � - 141 */
1053 0x0000, /* Ž - 142 */
1054 0x0000, /* � - 143 */
1055 0x0000, /* � - 144 */
1056 0x0088, /* ‘ - 145 */
1057 0x0088, /* ’ - 146 */
1058 0x0088, /* “ - 147 */
1059 0x0088, /* ” - 148 */
1060 0x0008, /* • - 149 */
1061 0x0400, /* – - 150 */
1062 0x0400, /* — - 151 */
1063 0x0408, /* ˜ - 152 */
1064 0x0000, /* ™ - 153 */
1065 0x8003, /* š - 154 */
1066 0x0008, /* › - 155 */
1067 0x8000, /* œ - 156 */
1068 0x0000, /* � - 157 */
1069 0x0000, /* ž - 158 */
1070 0x8003, /* Ÿ - 159 */
1072 0x0008, /* ¡ - 161 */
1073 0x0048, /* ¢ - 162 */
1074 0x0048, /* £ - 163 */
1075 0x0008, /* ¤ - 164 */
1076 0x0048, /* ¥ - 165 */
1077 0x0048, /* ¦ - 166 */
1078 0x0008, /* § - 167 */
1079 0x0408, /* ¨ - 168 */
1080 0x0008, /* © - 169 */
1081 0x0400, /* ª - 170 */
1082 0x0008, /* « - 171 */
1083 0x0048, /* ¬ - 172 */
1084 0x0408, /* - 173 */
1085 0x0008, /* ® - 174 */
1086 0x0448, /* ¯ - 175 */
1087 0x0008, /* ° - 176 */
1088 0x0008, /* ± - 177 */
1089 0x0000, /* ² - 178 */
1090 0x0000, /* ³ - 179 */
1091 0x0408, /* ´ - 180 */
1092 0x0008, /* µ - 181 */
1093 0x0008, /* ¶ - 182 */
1094 0x0008, /* · - 183 */
1095 0x0408, /* ¸ - 184 */
1096 0x0000, /* ¹ - 185 */
1097 0x0400, /* º - 186 */
1098 0x0008, /* » - 187 */
1099 0x0000, /* ¼ - 188 */
1100 0x0000, /* ½ - 189 */
1101 0x0000, /* ¾ - 190 */
1102 0x0008, /* ¿ - 191 */
1103 0x8003, /* À - 192 */
1104 0x8003, /* Á - 193 */
1105 0x8003, /* Â - 194 */
1106 0x8003, /* Ã - 195 */
1107 0x8003, /* Ä - 196 */
1108 0x8003, /* Å - 197 */
1109 0x8000, /* Æ - 198 */
1110 0x8003, /* Ç - 199 */
1111 0x8003, /* È - 200 */
1112 0x8003, /* É - 201 */
1113 0x8003, /* Ê - 202 */
1114 0x8003, /* Ë - 203 */
1115 0x8003, /* Ì - 204 */
1116 0x8003, /* Í - 205 */
1117 0x8003, /* Î - 206 */
1118 0x8003, /* Ï - 207 */
1119 0x8000, /* Ð - 208 */
1120 0x8003, /* Ñ - 209 */
1121 0x8003, /* Ò - 210 */
1122 0x8003, /* Ó - 211 */
1123 0x8003, /* Ô - 212 */
1124 0x8003, /* Õ - 213 */
1125 0x8003, /* Ö - 214 */
1126 0x0008, /* × - 215 */
1127 0x8003, /* Ø - 216 */
1128 0x8003, /* Ù - 217 */
1129 0x8003, /* Ú - 218 */
1130 0x8003, /* Û - 219 */
1131 0x8003, /* Ü - 220 */
1132 0x8003, /* Ý - 221 */
1133 0x8000, /* Þ - 222 */
1134 0x8000, /* ß - 223 */
1135 0x8003, /* à - 224 */
1136 0x8003, /* á - 225 */
1137 0x8003, /* â - 226 */
1138 0x8003, /* ã - 227 */
1139 0x8003, /* ä - 228 */
1140 0x8003, /* å - 229 */
1141 0x8000, /* æ - 230 */
1142 0x8003, /* ç - 231 */
1143 0x8003, /* è - 232 */
1144 0x8003, /* é - 233 */
1145 0x8003, /* ê - 234 */
1146 0x8003, /* ë - 235 */
1147 0x8003, /* ì - 236 */
1148 0x8003, /* í - 237 */
1149 0x8003, /* î - 238 */
1150 0x8003, /* ï - 239 */
1151 0x8000, /* ð - 240 */
1152 0x8003, /* ñ - 241 */
1153 0x8003, /* ò - 242 */
1154 0x8003, /* ó - 243 */
1155 0x8003, /* ô - 244 */
1156 0x8003, /* õ - 245 */
1157 0x8003, /* ö - 246 */
1158 0x0008, /* ÷ - 247 */
1159 0x8003, /* ø - 248 */
1160 0x8003, /* ù - 249 */
1161 0x8003, /* ú - 250 */
1162 0x8003, /* û - 251 */
1163 0x8003, /* ü - 252 */
1164 0x8003, /* ý - 253 */
1165 0x8000, /* þ - 254 */
1166 0x8003 /* ÿ - 255 */
1169 /******************************************************************************
1170 * GetStringType16 [OLE2NLS.7]
1172 BOOL16 WINAPI
GetStringType16(LCID locale
,DWORD dwInfoType
,LPCSTR src
,
1173 INT16 cchSrc
,LPWORD chartype
)
1175 return GetStringTypeEx32A(locale
,dwInfoType
,src
,cchSrc
,chartype
);
1177 /******************************************************************************
1178 * GetStringType32A [KERNEL32.396]
1180 BOOL32 WINAPI
GetStringType32A(LCID locale
,DWORD dwInfoType
,LPCSTR src
,
1181 INT32 cchSrc
,LPWORD chartype
)
1183 return GetStringTypeEx32A(locale
,dwInfoType
,src
,cchSrc
,chartype
);
1186 /******************************************************************************
1187 * GetStringTypeEx32A [KERNEL32.397]
1189 * FIXME: Ignores the locale.
1191 BOOL32 WINAPI
GetStringTypeEx32A(LCID locale
,DWORD dwInfoType
,LPCSTR src
,
1192 INT32 cchSrc
,LPWORD chartype
)
1196 if ((src
==NULL
) || (chartype
==NULL
) || (src
==(LPSTR
)chartype
))
1198 SetLastError(ERROR_INVALID_PARAMETER
);
1203 cchSrc
=lstrlen32A(src
)+1;
1205 switch (dwInfoType
) {
1207 for (i
=0;i
<cchSrc
;i
++)
1210 if (isdigit(src
[i
])) chartype
[i
]|=C1_DIGIT
;
1211 if (isalpha(src
[i
])) chartype
[i
]|=C1_ALPHA
;
1212 if (islower(src
[i
])) chartype
[i
]|=C1_LOWER
;
1213 if (isupper(src
[i
])) chartype
[i
]|=C1_UPPER
;
1214 if (isspace(src
[i
])) chartype
[i
]|=C1_SPACE
;
1215 if (ispunct(src
[i
])) chartype
[i
]|=C1_PUNCT
;
1216 if (iscntrl(src
[i
])) chartype
[i
]|=C1_CNTRL
;
1217 /* FIXME: isblank() is a GNU extension */
1218 /* if (isblank(src[i])) chartype[i]|=C1_BLANK; */
1219 if ((src
[i
] == ' ') || (src
[i
] == '\t')) chartype
[i
]|=C1_BLANK
;
1225 for (i
=0;i
<cchSrc
;i
++)
1227 chartype
[i
]=(WORD
)CT_CType2_LUT
[i
];
1232 for (i
=0;i
<cchSrc
;i
++)
1234 chartype
[i
]=CT_CType3_LUT
[i
];
1239 ERR(ole
,"Unknown dwInfoType:%ld\n",dwInfoType
);
1244 /******************************************************************************
1245 * GetStringType32W [KERNEL32.399]
1248 * Yes, this is missing LCID locale. MS fault.
1250 BOOL32 WINAPI
GetStringType32W(DWORD dwInfoType
,LPCWSTR src
,INT32 cchSrc
,
1253 return GetStringTypeEx32W(0/*defaultlocale*/,dwInfoType
,src
,cchSrc
,chartype
);
1256 /******************************************************************************
1257 * GetStringTypeEx32W [KERNEL32.398]
1259 * FIXME: unicode chars are assumed chars
1261 BOOL32 WINAPI
GetStringTypeEx32W(LCID locale
,DWORD dwInfoType
,LPCWSTR src
,
1262 INT32 cchSrc
,LPWORD chartype
)
1268 cchSrc
=lstrlen32W(src
)+1;
1270 switch (dwInfoType
) {
1272 FIXME(ole
,"CT_CTYPE2 not supported.\n");
1275 FIXME(ole
,"CT_CTYPE3 not supported.\n");
1279 for (i
=0;i
<cchSrc
;i
++) {
1281 if (isdigit(src
[i
])) chartype
[i
]|=C1_DIGIT
;
1282 if (isalpha(src
[i
])) chartype
[i
]|=C1_ALPHA
;
1283 if (islower(src
[i
])) chartype
[i
]|=C1_LOWER
;
1284 if (isupper(src
[i
])) chartype
[i
]|=C1_UPPER
;
1285 if (isspace(src
[i
])) chartype
[i
]|=C1_SPACE
;
1286 if (ispunct(src
[i
])) chartype
[i
]|=C1_PUNCT
;
1287 if (iscntrl(src
[i
])) chartype
[i
]|=C1_CNTRL
;
1288 /* FIXME: isblank() is a GNU extension */
1289 /* if (isblank(src[i])) chartype[i]|=C1_BLANK; */
1290 if ((src
[i
] == ' ') || (src
[i
] == '\t')) chartype
[i
]|=C1_BLANK
;
1296 /*****************************************************************
1297 * VerLanguageName16 [VER.10]
1299 DWORD WINAPI
VerLanguageName16(UINT16 langid
,LPSTR langname
,UINT16 langnamelen
)
1305 TRACE(ver
,"(%d,%p,%d)\n",langid
,langname
,langnamelen
);
1306 /* First, check \System\CurrentControlSet\control\Nls\Locale\<langid>
1307 * from the registry.
1310 "\\System\\CurrentControlSet\\control\\Nls\\Locale\\%08x",
1312 result
= RegQueryValue16(HKEY_LOCAL_MACHINE
, buffer
, langname
,
1313 (LPDWORD
)&langnamelen
);
1314 if (result
== ERROR_SUCCESS
) {
1315 langname
[langnamelen
-1]='\0';
1318 /* if that fails, use the internal table */
1319 for (i
=0;languages
[i
].langid
!=0;i
++)
1320 if (langid
==languages
[i
].langid
)
1322 strncpy(langname
,languages
[i
].langname
,langnamelen
);
1323 langname
[langnamelen
-1]='\0';
1324 return strlen(languages
[i
].langname
);
1327 /*****************************************************************
1328 * VerLanguageName32A [VERSION.9]
1330 DWORD WINAPI
VerLanguageName32A(UINT32 langid
,LPSTR langname
,
1333 return VerLanguageName16(langid
,langname
,langnamelen
);
1336 /*****************************************************************
1337 * VerLanguageName32W [VERSION.10]
1339 DWORD WINAPI
VerLanguageName32W(UINT32 langid
,LPWSTR langname
,
1347 /* First, check \System\CurrentControlSet\control\Nls\Locale\<langid>
1348 * from the registry.
1351 "\\System\\CurrentControlSet\\control\\Nls\\Locale\\%08x",
1353 keyname
= HEAP_strdupAtoW( GetProcessHeap(), 0, buffer
);
1354 result
= RegQueryValue32W(HKEY_LOCAL_MACHINE
, keyname
, langname
,
1355 (LPDWORD
)&langnamelen
);
1356 HeapFree( GetProcessHeap(), 0, keyname
);
1357 if (result
!= ERROR_SUCCESS
) {
1358 /* if that fails, use the internal table */
1359 for (i
=0;languages
[i
].langid
!=0;i
++)
1360 if (langid
==languages
[i
].langid
)
1362 lstrcpyAtoW( langname
, languages
[i
].langname
);
1363 langnamelen
= strlen(languages
[i
].langname
);
1364 /* same as strlenW(langname); */
1369 static const unsigned char LCM_Unicode_LUT
[] = {
1402 7 , 28, /* ! - 33 */
1403 7 , 29, /* " - 34 */ /* " */
1404 7 , 31, /* # - 35 */
1405 7 , 33, /* $ - 36 */
1406 7 , 35, /* % - 37 */
1407 7 , 37, /* & - 38 */
1408 6 , 128, /* ' - 39 */
1409 7 , 39, /* ( - 40 */
1410 7 , 42, /* ) - 41 */
1411 7 , 45, /* * - 42 */
1413 7 , 47, /* , - 44 */
1414 6 , 130, /* - - 45 */
1415 7 , 51, /* . - 46 */
1416 7 , 53, /* / - 47 */
1417 12 , 3, /* 0 - 48 */
1418 12 , 33, /* 1 - 49 */
1419 12 , 51, /* 2 - 50 */
1420 12 , 70, /* 3 - 51 */
1421 12 , 88, /* 4 - 52 */
1422 12 , 106, /* 5 - 53 */
1423 12 , 125, /* 6 - 54 */
1424 12 , 144, /* 7 - 55 */
1425 12 , 162, /* 8 - 56 */
1426 12 , 180, /* 9 - 57 */
1427 7 , 55, /* : - 58 */
1428 7 , 58, /* ; - 59 */
1429 8 , 14, /* < - 60 */
1430 8 , 18, /* = - 61 */
1431 8 , 20, /* > - 62 */
1432 7 , 60, /* ? - 63 */
1433 7 , 62, /* @ - 64 */
1434 14 , 2, /* A - 65 */
1435 14 , 9, /* B - 66 */
1436 14 , 10, /* C - 67 */
1437 14 , 26, /* D - 68 */
1438 14 , 33, /* E - 69 */
1439 14 , 35, /* F - 70 */
1440 14 , 37, /* G - 71 */
1441 14 , 44, /* H - 72 */
1442 14 , 50, /* I - 73 */
1443 14 , 53, /* J - 74 */
1444 14 , 54, /* K - 75 */
1445 14 , 72, /* L - 76 */
1446 14 , 81, /* M - 77 */
1447 14 , 112, /* N - 78 */
1448 14 , 124, /* O - 79 */
1449 14 , 126, /* P - 80 */
1450 14 , 137, /* Q - 81 */
1451 14 , 138, /* R - 82 */
1452 14 , 145, /* S - 83 */
1453 14 , 153, /* T - 84 */
1454 14 , 159, /* U - 85 */
1455 14 , 162, /* V - 86 */
1456 14 , 164, /* W - 87 */
1457 14 , 166, /* X - 88 */
1458 14 , 167, /* Y - 89 */
1459 14 , 169, /* Z - 90 */
1460 7 , 63, /* [ - 91 */
1461 7 , 65, /* \ - 92 */
1462 7 , 66, /* ] - 93 */
1463 7 , 67, /* ^ - 94 */
1464 7 , 68, /* _ - 95 */
1465 7 , 72, /* ` - 96 */
1466 14 , 2, /* a - 97 */
1467 14 , 9, /* b - 98 */
1468 14 , 10, /* c - 99 */
1469 14 , 26, /* d - 100 */
1470 14 , 33, /* e - 101 */
1471 14 , 35, /* f - 102 */
1472 14 , 37, /* g - 103 */
1473 14 , 44, /* h - 104 */
1474 14 , 50, /* i - 105 */
1475 14 , 53, /* j - 106 */
1476 14 , 54, /* k - 107 */
1477 14 , 72, /* l - 108 */
1478 14 , 81, /* m - 109 */
1479 14 , 112, /* n - 110 */
1480 14 , 124, /* o - 111 */
1481 14 , 126, /* p - 112 */
1482 14 , 137, /* q - 113 */
1483 14 , 138, /* r - 114 */
1484 14 , 145, /* s - 115 */
1485 14 , 153, /* t - 116 */
1486 14 , 159, /* u - 117 */
1487 14 , 162, /* v - 118 */
1488 14 , 164, /* w - 119 */
1489 14 , 166, /* x - 120 */
1490 14 , 167, /* y - 121 */
1491 14 , 169, /* z - 122 */
1492 7 , 74, /* { - 123 */
1493 7 , 76, /* | - 124 */
1494 7 , 78, /* } - 125 */
1495 7 , 80, /* ~ - 126 */
1496 6 , 29, /* \x7f - 127 */
1497 6 , 30, /* € - 128 */
1498 6 , 31, /* � - 129 */
1499 7 , 123, /* ‚ - 130 */
1500 14 , 35, /* ƒ - 131 */
1501 7 , 127, /* „ - 132 */
1502 10 , 21, /* … - 133 */
1503 10 , 15, /* † - 134 */
1504 10 , 16, /* ‡ - 135 */
1505 7 , 67, /* ˆ - 136 */
1506 10 , 22, /* ‰ - 137 */
1507 14 , 145, /* Š - 138 */
1508 7 , 136, /* ‹ - 139 */
1509 14 + 16 , 124, /* Œ - 140 */
1510 6 , 43, /* � - 141 */
1511 6 , 44, /* Ž - 142 */
1512 6 , 45, /* � - 143 */
1513 6 , 46, /* � - 144 */
1514 7 , 121, /* ‘ - 145 */
1515 7 , 122, /* ’ - 146 */
1516 7 , 125, /* “ - 147 */
1517 7 , 126, /* ” - 148 */
1518 10 , 17, /* • - 149 */
1519 6 , 137, /* – - 150 */
1520 6 , 139, /* — - 151 */
1521 7 , 93, /* ˜ - 152 */
1522 14 , 156, /* ™ - 153 */
1523 14 , 145, /* š - 154 */
1524 7 , 137, /* › - 155 */
1525 14 + 16 , 124, /* œ - 156 */
1526 6 , 59, /* � - 157 */
1527 6 , 60, /* ž - 158 */
1528 14 , 167, /* Ÿ - 159 */
1530 7 , 81, /* ¡ - 161 */
1531 10 , 2, /* ¢ - 162 */
1532 10 , 3, /* £ - 163 */
1533 10 , 4, /* ¤ - 164 */
1534 10 , 5, /* ¥ - 165 */
1535 7 , 82, /* ¦ - 166 */
1536 10 , 6, /* § - 167 */
1537 7 , 83, /* ¨ - 168 */
1538 10 , 7, /* © - 169 */
1539 14 , 2, /* ª - 170 */
1540 8 , 24, /* « - 171 */
1541 10 , 8, /* ¬ - 172 */
1542 6 , 131, /* - 173 */
1543 10 , 9, /* ® - 174 */
1544 7 , 84, /* ¯ - 175 */
1545 10 , 10, /* ° - 176 */
1546 8 , 23, /* ± - 177 */
1547 12 , 51, /* ² - 178 */
1548 12 , 70, /* ³ - 179 */
1549 7 , 85, /* ´ - 180 */
1550 10 , 11, /* µ - 181 */
1551 10 , 12, /* ¶ - 182 */
1552 10 , 13, /* · - 183 */
1553 7 , 86, /* ¸ - 184 */
1554 12 , 33, /* ¹ - 185 */
1555 14 , 124, /* º - 186 */
1556 8 , 26, /* » - 187 */
1557 12 , 21, /* ¼ - 188 */
1558 12 , 25, /* ½ - 189 */
1559 12 , 29, /* ¾ - 190 */
1560 7 , 87, /* ¿ - 191 */
1561 14 , 2, /* À - 192 */
1562 14 , 2, /* Á - 193 */
1563 14 , 2, /* Â - 194 */
1564 14 , 2, /* Ã - 195 */
1565 14 , 2, /* Ä - 196 */
1566 14 , 2, /* Å - 197 */
1567 14 + 16 , 2, /* Æ - 198 */
1568 14 , 10, /* Ç - 199 */
1569 14 , 33, /* È - 200 */
1570 14 , 33, /* É - 201 */
1571 14 , 33, /* Ê - 202 */
1572 14 , 33, /* Ë - 203 */
1573 14 , 50, /* Ì - 204 */
1574 14 , 50, /* Í - 205 */
1575 14 , 50, /* Î - 206 */
1576 14 , 50, /* Ï - 207 */
1577 14 , 26, /* Ð - 208 */
1578 14 , 112, /* Ñ - 209 */
1579 14 , 124, /* Ò - 210 */
1580 14 , 124, /* Ó - 211 */
1581 14 , 124, /* Ô - 212 */
1582 14 , 124, /* Õ - 213 */
1583 14 , 124, /* Ö - 214 */
1584 8 , 28, /* × - 215 */
1585 14 , 124, /* Ø - 216 */
1586 14 , 159, /* Ù - 217 */
1587 14 , 159, /* Ú - 218 */
1588 14 , 159, /* Û - 219 */
1589 14 , 159, /* Ü - 220 */
1590 14 , 167, /* Ý - 221 */
1591 14 + 32 , 153, /* Þ - 222 */
1592 14 + 48 , 145, /* ß - 223 */
1593 14 , 2, /* à - 224 */
1594 14 , 2, /* á - 225 */
1595 14 , 2, /* â - 226 */
1596 14 , 2, /* ã - 227 */
1597 14 , 2, /* ä - 228 */
1598 14 , 2, /* å - 229 */
1599 14 + 16 , 2, /* æ - 230 */
1600 14 , 10, /* ç - 231 */
1601 14 , 33, /* è - 232 */
1602 14 , 33, /* é - 233 */
1603 14 , 33, /* ê - 234 */
1604 14 , 33, /* ë - 235 */
1605 14 , 50, /* ì - 236 */
1606 14 , 50, /* í - 237 */
1607 14 , 50, /* î - 238 */
1608 14 , 50, /* ï - 239 */
1609 14 , 26, /* ð - 240 */
1610 14 , 112, /* ñ - 241 */
1611 14 , 124, /* ò - 242 */
1612 14 , 124, /* ó - 243 */
1613 14 , 124, /* ô - 244 */
1614 14 , 124, /* õ - 245 */
1615 14 , 124, /* ö - 246 */
1616 8 , 29, /* ÷ - 247 */
1617 14 , 124, /* ø - 248 */
1618 14 , 159, /* ù - 249 */
1619 14 , 159, /* ú - 250 */
1620 14 , 159, /* û - 251 */
1621 14 , 159, /* ü - 252 */
1622 14 , 167, /* ý - 253 */
1623 14 + 32 , 153, /* þ - 254 */
1624 14 , 167 /* ÿ - 255 */ };
1626 static const unsigned char LCM_Unicode_LUT_2
[] = { 33, 44, 145 };
1628 #define LCM_Diacritic_Start 131
1630 static const unsigned char LCM_Diacritic_LUT
[] = {
1758 static int OLE2NLS_isPunctuation(unsigned char c
)
1760 /* "punctuation character" in this context is a character which is
1761 considered "less important" during word sort comparison.
1762 See LCMapString implementation for the precise definition
1763 of "less important". */
1765 return (LCM_Unicode_LUT
[-2+2*c
]==6);
1768 /******************************************************************************
1769 * identity [Internal]
1771 static int identity(int c
)
1776 /*************************************************************************
1777 * LCMapString32A [KERNEL32.492]
1779 * Convert a string, or generate a sort key from it.
1781 * If (mapflags & LCMAP_SORTKEY), the function will generate
1782 * a sort key for the source string. Else, it will convert it
1783 * accordingly to the flags LCMAP_UPPERCASE, LCMAP_LOWERCASE,...
1787 * Success : length of the result string.
1790 * If called with scrlen = -1, the function will compute the length
1791 * of the 0-terminated string strsrc by itself.
1793 * If called with dstlen = 0, returns the buffer length that
1794 * would be required.
1796 * NORM_IGNOREWIDTH means to compare ASCII and Unicode characters
1797 * as if they are equal. Since Wine separates ASCII and Unicode into
1798 * separate functions, we shouldn't have to do anything for this flag.
1799 * I added it to the list of flags that don't need a fixme message
1800 * to make MS Word 95 not print several thousand fixme messages for
1803 INT32 WINAPI
LCMapString32A(
1804 LCID lcid
/* locale identifier created with MAKELCID;
1805 LOCALE_SYSTEM_DEFAULT and LOCALE_USER_DEFAULT are
1806 predefined values. */,
1807 DWORD mapflags
/* flags */,
1808 LPCSTR srcstr
/* source buffer */,
1809 INT32 srclen
/* source length */,
1810 LPSTR dststr
/* destination buffer */,
1811 INT32 dstlen
/* destination buffer length */)
1815 TRACE(string
,"(0x%04lx,0x%08lx,%s,%d,%p,%d)\n",
1816 lcid
,mapflags
,srcstr
,srclen
,dststr
,dstlen
);
1818 if ( ((dstlen
!=0) && (dststr
==NULL
)) || (srcstr
==NULL
) )
1820 ERR(ole
, "(src=%s,dest=%s): Invalid NULL string\n", srcstr
, dststr
);
1821 SetLastError(ERROR_INVALID_PARAMETER
);
1825 srclen
= lstrlen32A(srcstr
) + 1 ; /* (include final '\0') */
1827 if (mapflags
& ~ ( LCMAP_UPPERCASE
| LCMAP_LOWERCASE
| LCMAP_SORTKEY
|
1828 NORM_IGNORECASE
| NORM_IGNORENONSPACE
| SORT_STRINGSORT
|
1831 FIXME(string
,"(0x%04lx,0x%08lx,%p,%d,%p,%d): "
1832 "unimplemented flags: 0x%08lx\n",
1833 lcid
,mapflags
,srcstr
,srclen
,dststr
,dstlen
,mapflags
);
1836 if ( !(mapflags
& LCMAP_SORTKEY
) )
1838 int (*f
)(int)=identity
;
1841 return srclen
; /* dstlen=0 means "do nothing but return required length" */
1843 srclen
=dstlen
; /* No, this case is not an error under Windows 95.
1844 And no '\0' gets written. */
1845 if (mapflags
& LCMAP_UPPERCASE
)
1847 else if (mapflags
& LCMAP_LOWERCASE
)
1849 for (i
=0; i
< srclen
; i
++)
1850 dststr
[i
] = (CHAR
) f(srcstr
[i
]);
1854 /* else ... (mapflags & LCMAP_SORTKEY) */
1858 int diacritic_len
=0;
1859 int delayed_punctuation_len
=0;
1860 char *case_component
;
1861 char *diacritic_component
;
1862 char *delayed_punctuation_component
;
1864 int flag_stringsort
= mapflags
& SORT_STRINGSORT
;
1866 /* compute how much room we will need */
1867 for (i
=0;i
<srclen
;i
++)
1870 unsigned char source_char
= srcstr
[i
];
1871 if (source_char
!='\0')
1873 if (flag_stringsort
|| !OLE2NLS_isPunctuation(source_char
))
1876 if ( LCM_Unicode_LUT
[-2+2*source_char
] & ~15 )
1877 unicode_len
++; /* double letter */
1881 delayed_punctuation_len
++;
1885 if (isupper(source_char
))
1886 case_len
=unicode_len
;
1888 ofs
= source_char
- LCM_Diacritic_Start
;
1889 if ((ofs
>=0) && (LCM_Diacritic_LUT
[ofs
]!=2))
1890 diacritic_len
=unicode_len
;
1893 if (mapflags
& NORM_IGNORECASE
)
1895 if (mapflags
& NORM_IGNORENONSPACE
)
1898 room
= 2 * unicode_len
/* "unicode" component */
1899 + diacritic_len
/* "diacritic" component */
1900 + case_len
/* "case" component */
1901 + 4 * delayed_punctuation_len
/* punctuation in word sort mode */
1902 + 4 /* four '\1' separators */
1903 + 1 ; /* terminal '\0' */
1906 else if (dstlen
<room
)
1908 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1912 /*FIXME the Pointercheck should not be nessesary */
1913 if (IsBadWritePtr32 (dststr
,room
))
1914 { ERR (string
,"bad destination buffer (dststr) : %p,%d\n",dststr
,dstlen
);
1915 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1919 /* locate each component, write separators */
1920 diacritic_component
= dststr
+ 2*unicode_len
;
1921 *diacritic_component
++ = '\1';
1922 case_component
= diacritic_component
+ diacritic_len
;
1923 *case_component
++ = '\1';
1924 delayed_punctuation_component
= case_component
+ case_len
;
1925 *delayed_punctuation_component
++ = '\1';
1926 *delayed_punctuation_component
++ = '\1';
1928 /* read source string char by char, write
1929 corresponding weight in each component. */
1930 for (i
=0,count
=0;i
<srclen
;i
++)
1932 unsigned char source_char
=srcstr
[i
];
1933 if (source_char
!='\0')
1936 type
= LCM_Unicode_LUT
[-2+2*source_char
];
1937 longcode
= type
>> 4;
1939 if (!flag_stringsort
&& OLE2NLS_isPunctuation(source_char
))
1941 UINT16 encrypted_location
= (1<<15) + 7 + 4*count
;
1942 *delayed_punctuation_component
++ = (unsigned char) (encrypted_location
>>8);
1943 *delayed_punctuation_component
++ = (unsigned char) (encrypted_location
&255);
1944 /* big-endian is used here because it lets string comparison be
1945 compatible with numerical comparison */
1947 *delayed_punctuation_component
++ = type
;
1948 *delayed_punctuation_component
++ = LCM_Unicode_LUT
[-1+2*source_char
];
1949 /* assumption : a punctuation character is never a
1950 double or accented letter */
1954 dststr
[2*count
] = type
;
1955 dststr
[2*count
+1] = LCM_Unicode_LUT
[-1+2*source_char
];
1959 case_component
[count
] = ( isupper(source_char
) ? 18 : 2 ) ;
1960 if (count
<diacritic_len
)
1961 diacritic_component
[count
] = 2; /* assumption: a double letter
1962 is never accented */
1965 dststr
[2*count
] = type
;
1966 dststr
[2*count
+1] = *(LCM_Unicode_LUT_2
- 1 + longcode
);
1967 /* 16 in the first column of LCM_Unicode_LUT --> longcode = 1
1968 32 in the first column of LCM_Unicode_LUT --> longcode = 2
1969 48 in the first column of LCM_Unicode_LUT --> longcode = 3 */
1973 case_component
[count
] = ( isupper(source_char
) ? 18 : 2 ) ;
1974 if (count
<diacritic_len
)
1976 int ofs
= source_char
- LCM_Diacritic_Start
;
1977 diacritic_component
[count
] = (ofs
>=0 ? LCM_Diacritic_LUT
[ofs
] : 2);
1983 dststr
[room
-1] = '\0';
1988 /*************************************************************************
1989 * LCMapString32W [KERNEL32.493]
1991 * Convert a string, or generate a sort key from it.
1995 * See LCMapString32A for documentation
1997 INT32 WINAPI
LCMapString32W(
1998 LCID lcid
,DWORD mapflags
,LPCWSTR srcstr
,INT32 srclen
,LPWSTR dststr
,
2003 TRACE(string
,"(0x%04lx,0x%08lx,%p,%d,%p,%d)\n",
2004 lcid
,mapflags
,srcstr
,srclen
,dststr
,dstlen
);
2006 if ( ((dstlen
!=0) && (dststr
==NULL
)) || (srcstr
==NULL
) )
2008 ERR(ole
, "(src=%p,dst=%p): Invalid NULL string\n", srcstr
, dststr
);
2009 SetLastError(ERROR_INVALID_PARAMETER
);
2013 srclen
= lstrlen32W(srcstr
)+1;
2014 if (mapflags
& LCMAP_SORTKEY
)
2016 FIXME(string
,"(0x%04lx,0x%08lx,%p,%d,%p,%d): "
2017 "unimplemented flags: 0x%08lx\n",
2018 lcid
,mapflags
,srcstr
,srclen
,dststr
,dstlen
,mapflags
);
2023 int (*f
)(int)=identity
;
2029 if (mapflags
& LCMAP_UPPERCASE
)
2031 else if (mapflags
& LCMAP_LOWERCASE
)
2033 for (i
=0; i
< srclen
; i
++)
2034 dststr
[i
] = (WCHAR
) f(srcstr
[i
]);
2039 /***********************************************************************
2040 * CompareString16 (OLE2NLS.8)
2042 UINT16 WINAPI
CompareString16(DWORD lcid
,DWORD fdwStyle
,
2043 LPCSTR s1
,DWORD l1
,LPCSTR s2
,DWORD l2
)
2045 return (UINT16
)CompareString32A(lcid
,fdwStyle
,s1
,l1
,s2
,l2
);
2048 /******************************************************************************
2049 * CompareString32A [KERNEL32.143]
2050 * Compares two strings using locale
2054 * success: CSTR_LESS_THAN, CSTR_EQUAL, CSTR_GREATER_THAN
2059 * Defaults to a word sort, but uses a string sort if
2060 * SORT_STRINGSORT is set.
2061 * Calls SetLastError for ERROR_INVALID_FLAGS, ERROR_INVALID_PARAMETER.
2065 * This implementation ignores the locale
2069 * Quite inefficient.
2071 UINT32 WINAPI
CompareString32A(
2072 DWORD lcid
, /* locale ID */
2073 DWORD fdwStyle
, /* comparison-style options */
2074 LPCSTR s1
, /* first string */
2075 DWORD l1
, /* length of first string */
2076 LPCSTR s2
, /* second string */
2077 DWORD l2
) /* length of second string */
2079 int mapstring_flags
;
2083 TRACE(ole
,"%s and %s\n",
2084 debugstr_a (s1
), debugstr_a (s2
));
2086 if ( (s1
==NULL
) || (s2
==NULL
) )
2088 ERR(ole
, "(s1=%s,s2=%s): Invalid NULL string\n", s1
, s2
);
2089 SetLastError(ERROR_INVALID_PARAMETER
);
2093 if(fdwStyle
& NORM_IGNORESYMBOLS
)
2094 FIXME(ole
, "IGNORESYMBOLS not supported\n");
2096 mapstring_flags
= LCMAP_SORTKEY
| fdwStyle
;
2097 len1
= LCMapString32A(lcid
,mapstring_flags
,s1
,l1
,NULL
,0);
2098 len2
= LCMapString32A(lcid
,mapstring_flags
,s2
,l2
,NULL
,0);
2100 if ((len1
==0)||(len2
==0))
2101 return 0; /* something wrong happened */
2103 sk1
= (LPSTR
)HeapAlloc(GetProcessHeap(),0,len1
);
2104 sk2
= (LPSTR
)HeapAlloc(GetProcessHeap(),0,len2
);
2105 if ( (!LCMapString32A(lcid
,mapstring_flags
,s1
,l1
,sk1
,len1
))
2106 || (!LCMapString32A(lcid
,mapstring_flags
,s2
,l2
,sk2
,len2
)) )
2108 ERR(ole
,"Bug in LCmapString32A.\n");
2113 /* strcmp doesn't necessarily return -1, 0, or 1 */
2114 result
= strcmp(sk1
,sk2
);
2116 HeapFree(GetProcessHeap(),0,sk1
);
2117 HeapFree(GetProcessHeap(),0,sk2
);
2124 /* must be greater, if we reach this point */
2128 /******************************************************************************
2129 * CompareString32W [KERNEL32.144]
2130 * This implementation ignores the locale
2131 * FIXME : Does only string sort. Should
2132 * be reimplemented the same way as CompareString32A.
2134 UINT32 WINAPI
CompareString32W(DWORD lcid
, DWORD fdwStyle
,
2135 LPCWSTR s1
, DWORD l1
, LPCWSTR s2
,DWORD l2
)
2138 if(fdwStyle
& NORM_IGNORENONSPACE
)
2139 FIXME(ole
,"IGNORENONSPACE not supprted\n");
2140 if(fdwStyle
& NORM_IGNORESYMBOLS
)
2141 FIXME(ole
,"IGNORESYMBOLS not supported\n");
2143 /* Is strcmp defaulting to string sort or to word sort?? */
2144 /* FIXME: Handle NORM_STRINGSORT */
2145 l1
= (l1
==-1)?lstrlen32W(s1
):l1
;
2146 l2
= (l2
==-1)?lstrlen32W(s2
):l2
;
2147 len
= l1
<l2
? l1
:l2
;
2148 ret
= (fdwStyle
& NORM_IGNORECASE
) ?
2149 lstrncmpi32W(s1
,s2
,len
) : lstrncmp32W(s1
,s2
,len
);
2150 /* not equal, return 1 or 3 */
2151 if(ret
!=0) return ret
+2;
2152 /* same len, return 2 */
2153 if(l1
==l2
) return 2;
2154 /* the longer one is lexically greater */
2155 return (l1
<l2
)? 1 : 3;
2158 /******************************************************************************
2159 * OLE_GetFormatA [Internal]
2162 * Why is it WINAPI if internal?
2164 This function implements stuff for GetDateFormat() and
2167 d single-digit (no leading zero) day (of month)
2168 dd two-digit day (of month)
2169 ddd short day-of-week name
2170 dddd long day-of-week name
2171 M single-digit month
2173 MMM short month name
2174 MMMM full month name
2175 y two-digit year, no leading 0
2177 yyyy four-digit year
2179 h hours with no leading zero (12-hour)
2180 hh hours with full two digits
2181 H hours with no leading zero (24-hour)
2182 HH hours with full two digits
2183 m minutes with no leading zero
2184 mm minutes with full two digits
2185 s seconds with no leading zero
2186 ss seconds with full two digits
2187 t time marker (A or P)
2188 tt time marker (AM, PM)
2189 '' used to quote literal characters
2190 '' (within a quoted string) indicates a literal '
2192 These functions REQUIRE valid locale, date, and format.
2194 INT32 WINAPI
OLE_GetFormatA(LCID locale
,
2199 LPSTR date
, INT32 datelen
)
2201 INT32 inpos
, outpos
;
2202 int count
, type
, inquote
, Overflow
;
2208 const char * _dgfmt
[] = { "%d", "%02d" };
2209 const char ** dgfmt
= _dgfmt
- 1;
2211 /* report, for debugging */
2212 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",
2213 locale
, flags
, tflags
,
2214 xtime
->wDay
, xtime
->wHour
, xtime
->wMinute
, xtime
->wSecond
,
2215 format
, format
, date
, date
, datelen
);
2217 /* initalize state variables and output buffer */
2219 count
= 0; inquote
= 0; Overflow
= 0;
2221 date
[0] = buf
[0] = '\0';
2223 strcpy(format
,_format
);
2225 /* alter the formatstring, while it works for all languages now in wine
2226 its possible that it fails when the time looks like ss:mm:hh as example*/
2227 if (tflags
& (TIME_NOMINUTESORSECONDS
))
2228 { if ((pos
= strstr ( format
, ":mm")))
2229 { memcpy ( pos
, pos
+3, strlen(format
)-(pos
-format
)-2 );
2232 if (tflags
& (TIME_NOSECONDS
))
2233 { if ((pos
= strstr ( format
, ":ss")))
2234 { memcpy ( pos
, pos
+3, strlen(format
)-(pos
-format
)-2 );
2238 for (inpos
= 0;; inpos
++) {
2239 /* 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]); */
2241 if (format
[inpos
] == '\'') {
2242 if (format
[inpos
+1] == '\'') {
2244 date
[outpos
++] = '\'';
2247 continue; /* we did nothing to the output */
2249 } else if (format
[inpos
] == '\0') {
2250 date
[outpos
++] = '\0';
2251 if (outpos
> datelen
) Overflow
= 1;
2254 date
[outpos
++] = format
[inpos
];
2255 if (outpos
> datelen
) {
2257 date
[outpos
-1] = '\0'; /* this is the last place where
2258 it's safe to write */
2262 } else if ( (count
&& (format
[inpos
] != type
))
2264 || (count
== 2 && strchr("ghHmst", type
)) )
2268 GetLocaleInfo32A(locale
,
2270 + xtime
->wDayOfWeek
- 1,
2272 } else if (count
== 3) {
2273 GetLocaleInfo32A(locale
,
2274 LOCALE_SABBREVDAYNAME1
2275 + xtime
->wDayOfWeek
- 1,
2278 sprintf(buf
, dgfmt
[count
], xtime
->wDay
);
2280 } else if (type
== 'M') {
2282 GetLocaleInfo32A(locale
,
2283 LOCALE_SABBREVMONTHNAME1
2284 + xtime
->wMonth
- 1,
2286 } else if (count
== 4) {
2287 GetLocaleInfo32A(locale
,
2289 + xtime
->wMonth
- 1,
2292 sprintf(buf
, dgfmt
[count
], xtime
->wMonth
);
2294 } else if (type
== 'y') {
2296 sprintf(buf
, "%d", xtime
->wYear
);
2297 } else if (count
== 3) {
2299 WARN(ole
, "unknown format, c=%c, n=%d\n", type
, count
);
2301 sprintf(buf
, dgfmt
[count
], xtime
->wYear
% 100);
2303 } else if (type
== 'g') {
2305 FIXME(ole
, "LOCALE_ICALENDARTYPE unimp.\n");
2309 WARN(ole
, "unknown format, c=%c, n=%d\n", type
, count
);
2311 } else if (type
== 'h') {
2312 /* gives us hours 1:00 -- 12:00 */
2313 sprintf(buf
, dgfmt
[count
], (xtime
->wHour
-1)%12 +1);
2314 } else if (type
== 'H') {
2316 sprintf(buf
, dgfmt
[count
], xtime
->wHour
);
2317 } else if ( type
== 'm') {
2318 sprintf(buf
, dgfmt
[count
], xtime
->wMinute
);
2319 } else if ( type
== 's') {
2320 sprintf(buf
, dgfmt
[count
], xtime
->wSecond
);
2321 } else if (type
== 't') {
2323 sprintf(buf
, "%c", (xtime
->wHour
< 12) ? 'A' : 'P');
2324 } else if (count
== 2) {
2325 /* sprintf(buf, "%s", (xtime->wHour < 12) ? "AM" : "PM"); */
2326 GetLocaleInfo32A(locale
,
2328 ? LOCALE_S1159
: LOCALE_S2359
,
2333 /* we need to check the next char in the format string
2334 again, no matter what happened */
2337 /* add the contents of buf to the output */
2338 buflen
= strlen(buf
);
2339 if (outpos
+ buflen
< datelen
) {
2340 date
[outpos
] = '\0'; /* for strcat to hook onto */
2344 date
[outpos
] = '\0';
2345 strncat(date
, buf
, datelen
- outpos
);
2346 date
[datelen
- 1] = '\0';
2347 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2348 WARN(ole
, "insufficient buffer\n");
2352 /* reset the variables we used to keep track of this item */
2355 } else if (format
[inpos
] == '\0') {
2356 /* we can't check for this at the loop-head, because
2357 that breaks the printing of the last format-item */
2358 date
[outpos
] = '\0';
2361 /* continuing a code for an item */
2364 } else if (strchr("hHmstyMdg", format
[inpos
])) {
2365 type
= format
[inpos
];
2368 } else if (format
[inpos
] == '\'') {
2372 date
[outpos
++] = format
[inpos
];
2374 /* now deal with a possible buffer overflow */
2375 if (outpos
>= datelen
) {
2376 date
[datelen
- 1] = '\0';
2377 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2383 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2386 /* finish it off with a string terminator */
2389 if (outpos
> datelen
-1) outpos
= datelen
-1;
2390 date
[outpos
] = '\0';
2392 TRACE(ole
, "OLE_GetFormatA returns string '%s', len %d\n",
2397 /**************************************************************
2398 * OLE_GetFormatW [internal]
2400 INT32 WINAPI
OLE_GetFormatW(LCID locale
, DWORD flags
, DWORD tflags
,
2403 LPWSTR output
, INT32 outlen
)
2405 INT32 inpos
, outpos
;
2406 int count
, type
=0, inquote
;
2407 int Overflow
; /* loop check */
2408 int usedate
, usetime
;
2412 WCHAR arg0
[] = {0}, arg1
[] = {'%','d',0};
2413 WCHAR arg2
[] = {'%','0','2','d',0};
2414 WCHAR
*argarr
[] = {arg0
, arg1
, arg2
};
2415 int datevars
=0, timevars
=0;
2417 /* make a debug report */
2418 lstrcpynWtoA(abuf
, format
, sizeof(format
));
2419 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",
2420 locale
, flags
, tflags
,
2421 xtime
->wDay
, xtime
->wHour
, xtime
->wMinute
, xtime
->wSecond
,
2422 abuf
, format
, output
, outlen
);
2425 /* initialize state variables */
2428 inquote
= Overflow
= 0;
2429 /* this is really just a sanity check */
2430 output
[0] = buf
[0] = 0;
2432 /* for compatibility with official Windows behavior */
2433 usedate
= flags
& DATE_DATEVARSONLY
;
2434 usetime
= flags
& TIME_TIMEVARSONLY
;
2436 /* this loop is the core of the function */
2437 for (inpos
= 0; /* we have several break points */ ; inpos
++) {
2439 if (format
[inpos
] == (WCHAR
) '\'') {
2440 if (format
[inpos
+1] == '\'') {
2442 output
[outpos
++] = '\'';
2447 } else if (format
[inpos
] == 0) {
2448 output
[outpos
++] = 0;
2449 if (outpos
> outlen
) Overflow
= 1;
2450 break; /* normal exit (within a quote) */
2452 output
[outpos
++] = format
[inpos
]; /* copy input */
2453 if (outpos
> outlen
) {
2455 output
[outpos
-1] = 0;
2459 } else if ( (count
&& (format
[inpos
] != type
))
2460 || ( (count
==4 && type
=='y') ||
2461 (count
==4 && type
=='M') ||
2462 (count
==4 && type
=='d') ||
2463 (count
==2 && type
=='g') ||
2464 (count
==2 && type
=='h') ||
2465 (count
==2 && type
=='H') ||
2466 (count
==2 && type
=='m') ||
2467 (count
==2 && type
=='s') ||
2468 (count
==2 && type
=='t') ) ) {
2471 GetLocaleInfo32W(locale
,
2472 LOCALE_SDAYNAME1
+ xtime
->wDayOfWeek
-1,
2473 buf
, sizeof(buf
)/sizeof(WCHAR
) );
2474 } else if (count
== 3) {
2475 GetLocaleInfo32W(locale
,
2476 LOCALE_SABBREVDAYNAME1
+
2477 xtime
->wDayOfWeek
-1,
2478 buf
, sizeof(buf
)/sizeof(WCHAR
) );
2480 wsnprintf32W(buf
, 5, argarr
[count
], xtime
->wDay
);
2482 } else if (type
== 'M') {
2484 GetLocaleInfo32W(locale
, LOCALE_SMONTHNAME1
+
2485 xtime
->wMonth
-1, buf
,
2486 sizeof(buf
)/sizeof(WCHAR
) );
2487 } else if (count
== 3) {
2488 GetLocaleInfo32W(locale
, LOCALE_SABBREVMONTHNAME1
+
2489 xtime
->wMonth
-1, buf
,
2490 sizeof(buf
)/sizeof(WCHAR
) );
2492 wsnprintf32W(buf
, 5, argarr
[count
], xtime
->wMonth
);
2494 } else if (type
== 'y') {
2496 wsnprintf32W(buf
, 6, argarr
[1] /* "%d" */,
2498 } else if (count
== 3) {
2499 lstrcpynAtoW(buf
, "yyy", 5);
2501 wsnprintf32W(buf
, 6, argarr
[count
],
2502 xtime
->wYear
% 100);
2504 } else if (type
== 'g') {
2506 FIXME(ole
, "LOCALE_ICALENDARTYPE unimplemented\n");
2507 lstrcpynAtoW(buf
, "AD", 5);
2509 /* Win API sez we copy it verbatim */
2510 lstrcpynAtoW(buf
, "g", 5);
2512 } else if (type
== 'h') {
2513 /* hours 1:00-12:00 --- is this right? */
2514 wsnprintf32W(buf
, 5, argarr
[count
],
2515 (xtime
->wHour
-1)%12 +1);
2516 } else if (type
== 'H') {
2517 wsnprintf32W(buf
, 5, argarr
[count
],
2519 } else if (type
== 'm' ) {
2520 wsnprintf32W(buf
, 5, argarr
[count
],
2522 } else if (type
== 's' ) {
2523 wsnprintf32W(buf
, 5, argarr
[count
],
2525 } else if (type
== 't') {
2526 GetLocaleInfo32W(locale
, (xtime
->wHour
< 12) ?
2527 LOCALE_S1159
: LOCALE_S2359
,
2534 /* no matter what happened, we need to check this next
2535 character the next time we loop through */
2538 /* cat buf onto the output */
2539 outlen
= lstrlen32W(buf
);
2540 if (outpos
+ buflen
< outlen
) {
2541 output
[outpos
] = 0; /* a "hook" for strcat */
2542 lstrcat32W(output
, buf
);
2546 lstrcatn32W(output
, buf
, outlen
- outpos
);
2547 output
[outlen
- 1] = 0;
2549 break; /* Abnormal exit */
2552 /* reset the variables we used this time */
2555 } else if (format
[inpos
] == 0) {
2556 /* we can't check for this at the beginning, because that
2557 would keep us from printing a format spec that ended the
2560 break; /* NORMAL EXIT */
2562 /* how we keep track of the middle of a format spec */
2565 } else if ( (datevars
&& (format
[inpos
]=='d' ||
2566 format
[inpos
]=='M' ||
2567 format
[inpos
]=='y' ||
2568 format
[inpos
]=='g') ) ||
2569 (timevars
&& (format
[inpos
]=='H' ||
2570 format
[inpos
]=='h' ||
2571 format
[inpos
]=='m' ||
2572 format
[inpos
]=='s' ||
2573 format
[inpos
]=='t') ) ) {
2574 type
= format
[inpos
];
2577 } else if (format
[inpos
] == '\'') {
2581 /* unquoted literals */
2582 output
[outpos
++] = format
[inpos
];
2587 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2588 WARN(ole
, " buffer overflow\n");
2591 /* final string terminator and sanity check */
2593 if (outpos
> outlen
-1) outpos
= outlen
-1;
2594 output
[outpos
] = '0';
2596 lstrcpynWtoA(abuf
, output
, sizeof(abuf
) );
2597 TRACE(ole
, " returning string \'%s\'\n", abuf
);
2599 return (!Overflow
) ? outlen
: 0;
2604 /******************************************************************************
2605 * GetDateFormat32A [KERNEL32.310]
2606 * Makes an ASCII string of the date
2608 * This function uses format to format the date, or, if format
2609 * is NULL, uses the default for the locale. format is a string
2610 * of literal fields and characters as follows:
2612 * - d single-digit (no leading zero) day (of month)
2613 * - dd two-digit day (of month)
2614 * - ddd short day-of-week name
2615 * - dddd long day-of-week name
2616 * - M single-digit month
2617 * - MM two-digit month
2618 * - MMM short month name
2619 * - MMMM full month name
2620 * - y two-digit year, no leading 0
2621 * - yy two-digit year
2622 * - yyyy four-digit year
2626 INT32 WINAPI
GetDateFormat32A(LCID locale
,DWORD flags
,
2628 LPCSTR format
, LPSTR date
,INT32 datelen
)
2631 char format_buf
[40];
2634 LPSYSTEMTIME thistime
;
2639 TRACE(ole
,"(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",
2640 locale
,flags
,xtime
,format
,date
,datelen
);
2643 locale
= LOCALE_SYSTEM_DEFAULT
;
2646 if (locale
== LOCALE_SYSTEM_DEFAULT
) {
2647 thislocale
= GetSystemDefaultLCID();
2648 } else if (locale
== LOCALE_USER_DEFAULT
) {
2649 thislocale
= GetUserDefaultLCID();
2651 thislocale
= locale
;
2654 if (xtime
== NULL
) {
2661 if (format
== NULL
) {
2662 GetLocaleInfo32A(thislocale
, ((flags
&DATE_LONGDATE
)
2664 : LOCALE_SSHORTDATE
),
2665 format_buf
, sizeof(format_buf
));
2666 thisformat
= format_buf
;
2668 thisformat
= format
;
2672 ret
= OLE_GetFormatA(thislocale
, flags
, 0, thistime
, thisformat
,
2677 "GetDateFormat32A() returning %d, with data=%s\n",
2682 /******************************************************************************
2683 * GetDateFormat32W [KERNEL32.311]
2684 * Makes a Unicode string of the date
2686 * Acts the same as GetDateFormat32A(), except that it's Unicode.
2687 * Accepts & returns sizes as counts of Unicode characters.
2690 INT32 WINAPI
GetDateFormat32W(LCID locale
,DWORD flags
,
2693 LPWSTR date
, INT32 datelen
)
2695 short datearr
[] = {'1','9','9','4','-','1','-','1',0};
2697 FIXME(ole
, "STUB (should call OLE_GetFormatW)\n");
2698 lstrcpyn32W(date
, datearr
, datelen
);
2699 return ( datelen
< 9) ? datelen
: 9;
2704 /**************************************************************************
2705 * EnumDateFormats32A (KERNEL32.198)
2707 BOOL32 WINAPI
EnumDateFormats32A(
2708 DATEFMT_ENUMPROC32A lpDateFmtEnumProc
, LCID Locale
, DWORD dwFlags
)
2710 FIXME(ole
, "Only US English supported\n");
2712 if(!lpDateFmtEnumProc
)
2714 SetLastError(ERROR_INVALID_PARAMETER
);
2720 case DATE_SHORTDATE
:
2721 if(!(*lpDateFmtEnumProc
)("M/d/yy")) return TRUE
;
2722 if(!(*lpDateFmtEnumProc
)("M/d/yyyy")) return TRUE
;
2723 if(!(*lpDateFmtEnumProc
)("MM/dd/yy")) return TRUE
;
2724 if(!(*lpDateFmtEnumProc
)("MM/dd/yyyy")) return TRUE
;
2725 if(!(*lpDateFmtEnumProc
)("yy/MM/dd")) return TRUE
;
2726 if(!(*lpDateFmtEnumProc
)("dd-MMM-yy")) return TRUE
;
2729 if(!(*lpDateFmtEnumProc
)("dddd, MMMM dd, yyyy")) return TRUE
;
2730 if(!(*lpDateFmtEnumProc
)("MMMM dd, yyyy")) return TRUE
;
2731 if(!(*lpDateFmtEnumProc
)("dddd, dd MMMM, yyyy")) return TRUE
;
2732 if(!(*lpDateFmtEnumProc
)("dd MMMM, yyyy")) return TRUE
;
2735 FIXME(ole
, "Unknown date format (%ld)\n", dwFlags
);
2736 SetLastError(ERROR_INVALID_PARAMETER
);
2741 /**************************************************************************
2742 * EnumDateFormats32W (KERNEL32.199)
2744 BOOL32 WINAPI
EnumDateFormats32W(
2745 DATEFMT_ENUMPROC32W lpDateFmtEnumProc
, LCID Locale
, DWORD dwFlags
)
2747 FIXME(ole
, "(%p, %ld, %ld): stub\n", lpDateFmtEnumProc
, Locale
, dwFlags
);
2748 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
2752 /**************************************************************************
2753 * EnumTimeFormats32A (KERNEL32.210)
2755 BOOL32 WINAPI
EnumTimeFormats32A(
2756 TIMEFMT_ENUMPROC32A lpTimeFmtEnumProc
, LCID Locale
, DWORD dwFlags
)
2758 FIXME(ole
, "Only US English supported\n");
2760 if(!lpTimeFmtEnumProc
)
2762 SetLastError(ERROR_INVALID_PARAMETER
);
2768 FIXME(ole
, "Unknown time format (%ld)\n", dwFlags
);
2771 if(!(*lpTimeFmtEnumProc
)("h:mm:ss tt")) return TRUE
;
2772 if(!(*lpTimeFmtEnumProc
)("hh:mm:ss tt")) return TRUE
;
2773 if(!(*lpTimeFmtEnumProc
)("H:mm:ss")) return TRUE
;
2774 if(!(*lpTimeFmtEnumProc
)("HH:mm:ss")) return TRUE
;
2779 /**************************************************************************
2780 * EnumTimeFormats32W (KERNEL32.211)
2782 BOOL32 WINAPI
EnumTimeFormats32W(
2783 TIMEFMT_ENUMPROC32W lpTimeFmtEnumProc
, LCID Locale
, DWORD dwFlags
)
2785 FIXME(ole
, "(%p,%ld,%ld): stub", lpTimeFmtEnumProc
, Locale
, dwFlags
);
2786 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
2790 /**************************************************************************
2791 * GetNumberFormat32A (KERNEL32.355)
2792 * NOTE: type of lpFormat should be CONST NUMBERFORMAT
2794 INT32 WINAPI
GetNumberFormat32A(LCID locale
, DWORD dwflags
,
2795 LPCSTR lpvalue
, char *lpFormat
,
2796 LPSTR lpNumberStr
, int cchNumber
)
2800 FIXME(file
,"%s: stub, no reformating done\n",lpvalue
);
2802 n
= strlen(lpvalue
);
2804 strncpy(lpNumberStr
,lpvalue
,cchNumber
);
2805 if (cchNumber
<= n
) {
2806 lpNumberStr
[cchNumber
-1] = 0;
2815 /******************************************************************************
2816 * GetTimeFormat32A [KERNEL32.422]
2817 * Makes an ASCII string of the time
2819 * Formats date according to format, or locale default if format is
2820 * NULL. The format consists of literal characters and fields as follows:
2822 * h hours with no leading zero (12-hour)
2823 * hh hours with full two digits
2824 * H hours with no leading zero (24-hour)
2825 * HH hours with full two digits
2826 * m minutes with no leading zero
2827 * mm minutes with full two digits
2828 * s seconds with no leading zero
2829 * ss seconds with full two digits
2830 * t time marker (A or P)
2831 * tt time marker (AM, PM)
2835 GetTimeFormat32A(LCID locale
, /* in */
2836 DWORD flags
, /* in */
2837 LPSYSTEMTIME xtime
, /* in */
2838 LPCSTR format
, /* in */
2839 LPSTR timestr
, /* out */
2840 INT32 timelen
/* in */)
2841 { char format_buf
[40];
2844 LPSYSTEMTIME thistime
;
2846 DWORD thisflags
=LOCALE_STIMEFORMAT
; /* standart timeformat */;
2848 TRACE(ole
,"GetTimeFormat(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",locale
,flags
,xtime
,format
,timestr
,timelen
);
2851 { locale
= LOCALE_SYSTEM_DEFAULT
;
2854 if (locale
== LOCALE_SYSTEM_DEFAULT
)
2855 { thislocale
= GetSystemDefaultLCID();
2857 else if (locale
== LOCALE_USER_DEFAULT
)
2858 { thislocale
= GetUserDefaultLCID();
2861 { thislocale
= locale
;
2864 if ( flags
& (TIME_NOTIMEMARKER
| TIME_FORCE24HOURFORMAT
))
2865 { FIXME(ole
,"TIME_NOTIMEMARKER or TIME_FORCE24HOURFORMAT not implemented\n");
2867 flags
&= (TIME_NOSECONDS
| TIME_NOMINUTESORSECONDS
); /* mask for OLE_GetFormatA*/
2870 { if (flags
& LOCALE_NOUSEROVERRIDE
) /*use system default*/
2871 { thislocale
= GetSystemDefaultLCID();
2873 GetLocaleInfo32A(thislocale
, thisflags
, format_buf
, sizeof(format_buf
));
2874 thisformat
= format_buf
;
2877 { thisformat
= format
;
2880 if (xtime
== NULL
) /* NULL means use the current local time*/
2881 { GetSystemTime(&t
);
2887 return OLE_GetFormatA(thislocale
, thisflags
, flags
, thistime
, thisformat
, timestr
, timelen
);
2891 /******************************************************************************
2892 * GetTimeFormat32W [KERNEL32.423]
2893 * Makes a Unicode string of the time
2896 GetTimeFormat32W(LCID locale
,DWORD flags
,
2899 LPWSTR timestr
,INT32 timelen
)
2903 LPCWSTR realformat
=0;
2905 LPSYSTEMTIME realtime
;
2906 WCHAR
* fmt_buf
= NULL
;
2907 int fmt_buf_size
= 0; /* units of WCHARs */
2910 lstrcpynWtoA(debugbuf
, format
, (sizeof(buf
))/2);
2911 TRACE(ole
, "GetTimeFormatW len %d flags 0x%lX format >%s<\n",
2912 timelen
, flags
, debugbuf
);
2914 /* Enforce the Windows behavior */
2915 flags
|= ~LOCALE_TIMEDATEBOTH
;
2916 flags
|= TIME_TIMEVARSONLY
;
2918 /* take care of the format or locale not being given */
2920 realformat
= format
;
2921 } else if (locale
) {
2922 /* allocate memory */
2923 retval
= ERROR_INSUFFICIENT_BUFFER
;
2924 fmt_buf
= malloc((fmt_buf_size
+=7) * sizeof(WCHAR
));
2928 while(!GetLocaleInfo32W(locale
, LOCALE_STIMEFORMAT
,
2929 fmt_buf
, fmt_buf_size
)) {
2930 retval
= ERROR_OUTOFMEMORY
;
2931 fmt_buf
= realloc(fmt_buf
,
2932 (fmt_buf_size
+= 10) * sizeof(WCHAR
));
2936 realformat
= fmt_buf
;
2938 FIXME(ole
, "caller gave no locale, no format; what should we do?\n");
2939 SetLastError(ERROR_BAD_FORMAT
);
2942 locale
= GetSystemDefaultLCID();
2947 GetSystemTime(realtime
);
2950 retval
= OLE_GetFormatW(locale
, flags
, 0, realtime
, realformat
, timestr
, timelen
);
2956 SetLastError(retval
);
2957 WARN(ole
, "could not allocate %d chars of memory\n", fmt_buf_size
);