Update the modemn status bit that indicates whether the RLSD line is
[wine.git] / ole / ole2nls.c
blob0e6ce188baaaf8fcbfe7641e981c14e356e89da5
1 /*
2 * OLE2NLS library
4 * Copyright 1995 Martin von Loewis
5 * Copyright 1998 David Lee Lambert
6 */
8 #include <string.h>
9 #include <ctype.h>
10 #include <stdlib.h>
11 #include "windows.h"
12 #include "heap.h"
13 #include "ole.h"
14 #include "options.h"
15 #include "winnls.h"
16 #include "winreg.h"
17 #include "winerror.h"
18 #include "debug.h"
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.
25 */
26 #define LOCALE_ENTRY(x) {#x,LOCALE_##x}
27 static struct tagLOCALE_NAME2ID {
28 char *name;
29 DWORD id;
30 } locale_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),
45 LOCALE_ENTRY(SLIST),
46 LOCALE_ENTRY(IMEASURE),
47 LOCALE_ENTRY(SDECIMAL),
48 LOCALE_ENTRY(STHOUSAND),
49 LOCALE_ENTRY(SGROUPING),
50 LOCALE_ENTRY(IDIGITS),
51 LOCALE_ENTRY(ILZERO),
52 LOCALE_ENTRY(INEGNUMBER),
53 LOCALE_ENTRY(SNATIVEDIGITS),
54 LOCALE_ENTRY(SCURRENCY),
55 LOCALE_ENTRY(SINTLSYMBOL),
56 LOCALE_ENTRY(SMONDECIMALSEP),
57 LOCALE_ENTRY(SMONTHOUSANDSEP),
58 LOCALE_ENTRY(SMONGROUPING),
59 LOCALE_ENTRY(ICURRDIGITS),
60 LOCALE_ENTRY(IINTLCURRDIGITS),
61 LOCALE_ENTRY(ICURRENCY),
62 LOCALE_ENTRY(INEGCURR),
63 LOCALE_ENTRY(SDATE),
64 LOCALE_ENTRY(STIME),
65 LOCALE_ENTRY(SSHORTDATE),
66 LOCALE_ENTRY(SLONGDATE),
67 LOCALE_ENTRY(STIMEFORMAT),
68 LOCALE_ENTRY(IDATE),
69 LOCALE_ENTRY(ILDATE),
70 LOCALE_ENTRY(ITIME),
71 LOCALE_ENTRY(ITIMEMARKPOSN),
72 LOCALE_ENTRY(ICENTURY),
73 LOCALE_ENTRY(ITLZERO),
74 LOCALE_ENTRY(IDAYLZERO),
75 LOCALE_ENTRY(IMONLZERO),
76 LOCALE_ENTRY(S1159),
77 LOCALE_ENTRY(S2359),
78 LOCALE_ENTRY(ICALENDARTYPE),
79 LOCALE_ENTRY(IOPTIONALCALENDAR),
80 LOCALE_ENTRY(IFIRSTDAYOFWEEK),
81 LOCALE_ENTRY(IFIRSTWEEKOFYEAR),
82 LOCALE_ENTRY(SDAYNAME1),
83 LOCALE_ENTRY(SDAYNAME2),
84 LOCALE_ENTRY(SDAYNAME3),
85 LOCALE_ENTRY(SDAYNAME4),
86 LOCALE_ENTRY(SDAYNAME5),
87 LOCALE_ENTRY(SDAYNAME6),
88 LOCALE_ENTRY(SDAYNAME7),
89 LOCALE_ENTRY(SABBREVDAYNAME1),
90 LOCALE_ENTRY(SABBREVDAYNAME2),
91 LOCALE_ENTRY(SABBREVDAYNAME3),
92 LOCALE_ENTRY(SABBREVDAYNAME4),
93 LOCALE_ENTRY(SABBREVDAYNAME5),
94 LOCALE_ENTRY(SABBREVDAYNAME6),
95 LOCALE_ENTRY(SABBREVDAYNAME7),
96 LOCALE_ENTRY(SMONTHNAME1),
97 LOCALE_ENTRY(SMONTHNAME2),
98 LOCALE_ENTRY(SMONTHNAME3),
99 LOCALE_ENTRY(SMONTHNAME4),
100 LOCALE_ENTRY(SMONTHNAME5),
101 LOCALE_ENTRY(SMONTHNAME6),
102 LOCALE_ENTRY(SMONTHNAME7),
103 LOCALE_ENTRY(SMONTHNAME8),
104 LOCALE_ENTRY(SMONTHNAME9),
105 LOCALE_ENTRY(SMONTHNAME10),
106 LOCALE_ENTRY(SMONTHNAME11),
107 LOCALE_ENTRY(SMONTHNAME12),
108 LOCALE_ENTRY(SMONTHNAME13),
109 LOCALE_ENTRY(SABBREVMONTHNAME1),
110 LOCALE_ENTRY(SABBREVMONTHNAME2),
111 LOCALE_ENTRY(SABBREVMONTHNAME3),
112 LOCALE_ENTRY(SABBREVMONTHNAME4),
113 LOCALE_ENTRY(SABBREVMONTHNAME5),
114 LOCALE_ENTRY(SABBREVMONTHNAME6),
115 LOCALE_ENTRY(SABBREVMONTHNAME7),
116 LOCALE_ENTRY(SABBREVMONTHNAME8),
117 LOCALE_ENTRY(SABBREVMONTHNAME9),
118 LOCALE_ENTRY(SABBREVMONTHNAME10),
119 LOCALE_ENTRY(SABBREVMONTHNAME11),
120 LOCALE_ENTRY(SABBREVMONTHNAME12),
121 LOCALE_ENTRY(SABBREVMONTHNAME13),
122 LOCALE_ENTRY(SPOSITIVESIGN),
123 LOCALE_ENTRY(SNEGATIVESIGN),
124 LOCALE_ENTRY(IPOSSIGNPOSN),
125 LOCALE_ENTRY(INEGSIGNPOSN),
126 LOCALE_ENTRY(IPOSSYMPRECEDES),
127 LOCALE_ENTRY(IPOSSEPBYSPACE),
128 LOCALE_ENTRY(INEGSYMPRECEDES),
129 LOCALE_ENTRY(INEGSEPBYSPACE),
130 /* LOCALE_ENTRY(FONTSIGNATURE),*/
131 {NULL,0},
134 const struct map_lcid2str {
135 LCID langid;
136 const char *langname;
137 } languages[]={
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"},
155 {0x0403,"Catalan"},
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)"},
161 {0x0405,"Czech"},
162 {0x0406,"Danish"},
163 {0x0407,"German (Germany)"},
164 {0x0807,"German (Switzerland)"},
165 {0x0c07,"German (Austria)"},
166 {0x1007,"German (Luxembourg)"},
167 {0x1407,"German (Liechtenstein)"},
168 {0x0408,"Greek"},
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)"},
202 {0x040b,"Finnish"},
203 {0x040c,"French (France)"},
204 {0x080c,"French (Belgium)"},
205 {0x0c0c,"French (Canada)"},
206 {0x100c,"French (Switzerland)"},
207 {0x140c,"French (Luxembourg)"},
208 {0x180c,"French (Monaco)"},
209 {0x040d,"Hebrew"},
210 {0x040e,"Hungarian"},
211 {0x040f,"Icelandic"},
212 {0x0410,"Italian (Italy)"},
213 {0x0810,"Italian (Switzerland)"},
214 {0x0411,"Japanese"},
215 {0x0412,"Korean (Wansung)"},
216 {0x0812,"Korean (Johab)"},
217 {0x0413,"Dutch (Netherlands)"},
218 {0x0813,"Dutch (Belgium)"},
219 {0x0414,"Norwegian (Bokmal)"},
220 {0x0814,"Norwegian (Nynorsk)"},
221 {0x0415,"Polish"},
222 {0x0416,"Portuguese (Brazil)"},
223 {0x0816,"Portuguese (Portugal)"},
224 {0x0417,"Rhaeto Romanic"},
225 {0x0418,"Romanian"},
226 {0x0818,"Moldavian"},
227 {0x0419,"Russian (Russia)"},
228 {0x0819,"Russian (Moldavia)"},
229 {0x041a,"Croatian"},
230 {0x081a,"Serbian (latin)"},
231 {0x0c1a,"Serbian (cyrillic)"},
232 {0x041b,"Slovak"},
233 {0x041c,"Albanian"},
234 {0x041d,"Swedish (Sweden)"},
235 {0x081d,"Swedish (Finland)"},
236 {0x041e,"Thai"},
237 {0x041f,"Turkish"},
238 {0x0420,"Urdu"},
239 {0x0421,"Indonesian"},
240 {0x0422,"Ukrainian"},
241 {0x0423,"Belarusian"},
242 {0x0424,"Slovene"},
243 {0x0425,"Estonian"},
244 {0x0426,"Latvian"},
245 {0x0427,"Lithuanian (modern)"},
246 {0x0827,"Lithuanian (classic)"},
247 {0x0428,"Maori"},
248 {0x0429,"Farsi"},
249 {0x042a,"Vietnamese"},
250 {0x042b,"Armenian"},
251 {0x042c,"Azeri (latin)"},
252 {0x082c,"Azeri (cyrillic)"},
253 {0x042d,"Basque"},
254 {0x042e,"Sorbian"},
255 {0x042f,"Macedonian"},
256 {0x0430,"Sutu"},
257 {0x0431,"Tsonga"},
258 {0x0432,"Tswana"},
259 {0x0433,"Venda"},
260 {0x0434,"Xhosa"},
261 {0x0435,"Zulu"},
262 {0x0436,"Afrikaans"},
263 {0x0437,"Georgian"},
264 {0x0438,"Faeroese"},
265 {0x0439,"Hindi"},
266 {0x043a,"Maltese"},
267 {0x043b,"Saami"},
268 {0x043c,"Irish gaelic"},
269 {0x083c,"Scottish gaelic"},
270 {0x043e,"Malay (Malaysia)"},
271 {0x083e,"Malay (Brunei Darussalam)"},
272 {0x043f,"Kazak"},
273 {0x0441,"Swahili"},
274 {0x0443,"Uzbek (latin)"},
275 {0x0843,"Uzbek (cyrillic)"},
276 {0x0444,"Tatar"},
277 {0x0445,"Bengali"},
278 {0x0446,"Punjabi"},
279 {0x0447,"Gujarati"},
280 {0x0448,"Oriya"},
281 {0x0449,"Tamil"},
282 {0x044a,"Telugu"},
283 {0x044b,"Kannada"},
284 {0x044c,"Malayalam"},
285 {0x044d,"Assamese"},
286 {0x044e,"Marathi"},
287 {0x044f,"Sanskrit"},
288 {0x0457,"Konkani"},
289 {0x048f,"Esperanto"}, /* Non official */
290 {0x0000,"Unknown"}
291 }, languages_de[]={
292 {0x0401,"Arabic"},
293 {0x0402,"Bulgarisch"},
294 {0x0403,"Katalanisch"},
295 {0x0404,"Traditionales Chinesisch"},
296 {0x0405,"Tschecisch"},
297 {0x0406,"Dänisch"},
298 {0x0407,"Deutsch"},
299 {0x0408,"Griechisch"},
300 {0x0409,"Amerikanisches Englisch"},
301 {0x040A,"Kastilisches Spanisch"},
302 {0x040B,"Finnisch"},
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"},
312 {0x0415,"Polnisch"},
313 {0x0416,"Brasilianisches Portugiesisch"},
314 {0x0417,"Rdtoromanisch"},
315 {0x0418,"Rumdnisch"},
316 {0x0419,"Russisch"},
317 {0x041A,"Kroatoserbisch (lateinisch)"},
318 {0x041B,"Slowenisch"},
319 {0x041C,"Albanisch"},
320 {0x041D,"Schwedisch"},
321 {0x041E,"Thai"},
322 {0x041F,"Türkisch"},
323 {0x0420,"Urdu"},
324 {0x0421,"Bahasa"},
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()
361 char *buf=NULL;
362 char *lang,*country,*charset,*dialect,*next;
363 int ret=0;
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")) {
374 free(buf);
375 return MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT );
378 lang=buf;
380 do {
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);
388 lang=next;
390 } while (lang && !ret);
392 free(buf);
393 return (LANGID)ret;
396 /***********************************************************************
397 * GetSystemDefaultLangID (OLE2NLS.4)
399 LANGID WINAPI GetSystemDefaultLangID()
401 return GetUserDefaultLangID();
404 /***********************************************************************
405 * GetLocaleInfoA (OLE2NLS.5)
406 * Is the last parameter really WORD for Win16?
408 INT16 WINAPI GetLocaleInfo16(LCID lcid,LCTYPE LCType,LPSTR buf,INT16 len)
410 return GetLocaleInfo32A(lcid,LCType,buf,len);
413 INT32 WINAPI GetLocaleInfo32A(LCID lcid,LCTYPE LCType,LPSTR buf,INT32 len)
415 char *retString;
416 int found,i;
417 int lang;
419 TRACE(ole,"(0x%lx,0x%lx,%p,%x)\n",
420 lcid,LCType,buf,len);
422 LCType &= ~(LOCALE_NOUSEROVERRIDE|LOCALE_USE_CP_ACP);
424 /* As an option, we could obtain the value from win.ini.
425 This would not match the Wine compile-time option.
426 Also, not all identifiers are available from win.ini */
427 retString=0;
428 /* If we are through all of this, retLen should not be zero anymore.
429 If it is, the value is not supported */
430 i=0;
431 while (locale_name2id[i].name!=NULL) {
432 if (LCType == locale_name2id[i].id) {
433 retString = locale_name2id[i].name;
434 break;
436 i++;
438 if (!retString) {
439 WARN(ole,"Unkown LC type %lX\n",LCType);
440 return 0;
443 #define LOCVAL(type,value) case type:retString=value;found=1;break;
445 /* Now, the language specific definitions. They don't have to be
446 complete */
447 found=0; i=0;
449 do {
450 if (i=0) lang=Languages[Options.language].langid;
451 if (i=1) lang=MAKELANGID( PRIMARYLANGID(lang), SUBLANG_DEFAULT);
452 i++;
454 switch(lang) {
455 case LANG_De:
456 switch (LCType) {
457 #include "nls/deu.nls"
458 default: found=0; break;
460 break; /* LANG(De) */
462 case LANG_Da:
463 switch (LCType) {
464 #include "nls/dan.nls"
465 default: found=0;break;
467 break; /* LANG(Da) */
469 case LANG_En:
470 switch (LCType) {
471 #include "nls/enu.nls"
472 default: found=0;break;
474 break; /* LANG(En) */
476 case LANG_Eo:
477 switch (LCType) {
478 #include "nls/esperanto.nls"
479 default: found=0;break;
481 break; /* LANG(Eo) */
483 case LANG_Fi:
484 switch (LCType) {
485 #include "nls/fin.nls"
486 default: found=0;break;
488 break; /* LANG(Fi) */
490 case LANG_It:
491 switch (LCType) {
492 #include "nls/ita.nls"
493 default: found=0;break;
495 break; /* LANG(It) */
497 case 0x0809:
498 switch (LCType) {
499 #include "nls/eng.nls"
500 default: found=0;break;
502 break; /* LANG(0x0809) (U.K. English) */
504 case LANG_Ko: /* string using codepage 949 */
505 switch (LCType) {
506 #include "nls/kor.nls"
507 default: found=0;break;
509 break; /* LANG(Ko) */
511 case LANG_Hu:
512 switch (LCType) {
513 #include "nls/hun.nls"
514 default: found=0;break;
516 break; /* LANG(En) */
518 case LANG_Pl:
519 switch (LCType) {
520 #include "nls/plk.nls"
521 default: found=0;break;
523 break; /* LANG(Pl) */
525 case LANG_Pt:
526 switch (LCType) {
527 #include "nls/ptb.nls"
528 default: found=0;break;
530 break; /* LANG(Pt) */
532 case LANG_Sv:
533 switch (LCType) {
534 #include "nls/sve.nls"
535 default: found=0;break;
537 break; /* LANG(Sv) */
539 /*Insert other languages here*/
541 default:
542 found=0;
543 break;
544 } /* switch */
545 } while (!found && i<2);
547 if(!found) {
548 ERR(ole,"'%s' not supported for your language.\n",
549 retString);
550 retString = "<WINE-NLS-unknown>";
551 /*return 0;*/
553 if (buf)
554 lstrcpyn32A(buf,retString,len);
555 return strlen(retString)+1;
558 /***********************************************************************
559 * GetLocaleInfo32W (KERNEL32.230)
560 * Is the last parameter really WORD for Win16?
562 INT32 WINAPI GetLocaleInfo32W(LCID lcid,LCTYPE LCType,LPWSTR wbuf,INT32 len)
564 LPSTR abuf = (LPSTR)HeapAlloc(GetProcessHeap(),0,len);
566 INT32 n = GetLocaleInfo32A(lcid, LCType, abuf, len);
567 if (wbuf)
568 lstrcpynAtoW(wbuf,abuf,len);
569 HeapFree(GetProcessHeap(),0,abuf);
570 return n;
573 /***********************************************************************
574 * SetLocaleInfoA [KERNEL32.499]
576 BOOL16 WINAPI SetLocaleInfoA(DWORD lcid, DWORD lctype, LPCSTR data)
578 FIXME(ole,"(%ld,%ld,%s): stub\n",lcid,lctype,data);
579 return TRUE;
582 /***********************************************************************
583 * IsValidLocale [KERNEL32.361]
585 BOOL32 WINAPI IsValidLocale(LCID lcid,DWORD flags)
587 /* we support ANY language. Well, at least say that...*/
588 return TRUE;
591 /***********************************************************************
592 * EnumSystemLocales32W [KERNEL32.93]
594 BOOL32 WINAPI EnumSystemLocales32W( LOCALE_ENUMPROC32W lpfnLocaleEnum,
595 DWORD flags )
597 int i;
598 BOOL32 ret;
599 WCHAR buffer[200];
600 HKEY xhkey;
602 TRACE(win32,"(%p,%08lx)\n",lpfnLocaleEnum,flags );
603 /* see if we can reuse the Win95 registry entries.... */
604 if (ERROR_SUCCESS==RegOpenKey32A(HKEY_LOCAL_MACHINE,"\\System\\CurrentControlSet\\control\\Nls\\Locale\\",&xhkey)) {
605 i=0;
606 while (1) {
607 if (ERROR_SUCCESS!=RegEnumKey32W(xhkey,i,buffer,sizeof(buffer)))
608 break;
609 if (!lpfnLocaleEnum(buffer))
610 break;
611 i++;
613 RegCloseKey(xhkey);
614 return TRUE;
617 i=0;
618 while (languages[i].langname!=NULL)
620 LPWSTR cp;
621 char xbuffer[10];
623 sprintf(xbuffer,"%08lx",(DWORD)languages[i].langid);
625 cp = HEAP_strdupAtoW( GetProcessHeap(), 0, xbuffer );
626 ret = lpfnLocaleEnum(cp);
627 HeapFree( GetProcessHeap(), 0, cp );
628 if (!ret) break;
629 i++;
631 return TRUE;
634 /***********************************************************************
635 * EnumSystemLocales32A [KERNEL32.92]
637 BOOL32 WINAPI EnumSystemLocales32A(LOCALE_ENUMPROC32A lpfnLocaleEnum,
638 DWORD flags)
640 int i;
641 CHAR buffer[200];
642 HKEY xhkey;
644 TRACE(win32,"(%p,%08lx)\n",
645 lpfnLocaleEnum,flags
647 if (ERROR_SUCCESS==RegOpenKey32A(HKEY_LOCAL_MACHINE,"\\System\\CurrentControlSet\\control\\Nls\\Locale\\",&xhkey)) {
648 i=0;
649 while (1) {
650 if (ERROR_SUCCESS!=RegEnumKey32A(xhkey,i,buffer,sizeof(buffer)))
651 break;
652 if (!lpfnLocaleEnum(buffer))
653 break;
654 i++;
656 RegCloseKey(xhkey);
657 return TRUE;
659 i=0;
660 while (languages[i].langname!=NULL) {
661 sprintf(buffer,"%08lx",(DWORD)languages[i].langid);
662 if (!lpfnLocaleEnum(buffer))
663 break;
664 i++;
666 return TRUE;
669 static const unsigned char CT_CType2_LUT[] = {
670 C2_NOTAPPLICABLE, /* - 0 */
671 C2_NOTAPPLICABLE, /* - 1 */
672 C2_NOTAPPLICABLE, /* - 2 */
673 C2_NOTAPPLICABLE, /* - 3 */
674 C2_NOTAPPLICABLE, /* - 4 */
675 C2_NOTAPPLICABLE, /* - 5 */
676 C2_NOTAPPLICABLE, /* - 6 */
677 C2_NOTAPPLICABLE, /* - 7 */
678 C2_NOTAPPLICABLE, /* - 8 */
679 C2_SEGMENTSEPARATOR, /* - 9 */
680 C2_NOTAPPLICABLE, /* - 10 */
681 C2_NOTAPPLICABLE, /* - 11 */
682 C2_NOTAPPLICABLE, /* - 12 */
683 C2_NOTAPPLICABLE, /* - 13 */
684 C2_NOTAPPLICABLE, /* - 14 */
685 C2_NOTAPPLICABLE, /* - 15 */
686 C2_NOTAPPLICABLE, /* - 16 */
687 C2_NOTAPPLICABLE, /* - 17 */
688 C2_NOTAPPLICABLE, /* - 18 */
689 C2_NOTAPPLICABLE, /* - 19 */
690 C2_NOTAPPLICABLE, /* - 20 */
691 C2_NOTAPPLICABLE, /* - 21 */
692 C2_NOTAPPLICABLE, /* - 22 */
693 C2_NOTAPPLICABLE, /* - 23 */
694 C2_NOTAPPLICABLE, /* - 24 */
695 C2_NOTAPPLICABLE, /* - 25 */
696 C2_NOTAPPLICABLE, /* - 26 */
697 C2_NOTAPPLICABLE, /* - 27 */
698 C2_NOTAPPLICABLE, /* - 28 */
699 C2_NOTAPPLICABLE, /* - 29 */
700 C2_NOTAPPLICABLE, /* - 30 */
701 C2_NOTAPPLICABLE, /* - 31 */
702 C2_WHITESPACE, /* - 32 */
703 C2_OTHERNEUTRAL, /* ! - 33 */
704 C2_OTHERNEUTRAL, /* " - 34 */ /* " */
705 C2_EUROPETERMINATOR, /* # - 35 */
706 C2_EUROPETERMINATOR, /* $ - 36 */
707 C2_EUROPETERMINATOR, /* % - 37 */
708 C2_LEFTTORIGHT, /* & - 38 */
709 C2_OTHERNEUTRAL, /* ' - 39 */
710 C2_OTHERNEUTRAL, /* ( - 40 */
711 C2_OTHERNEUTRAL, /* ) - 41 */
712 C2_OTHERNEUTRAL, /* * - 42 */
713 C2_EUROPETERMINATOR, /* + - 43 */
714 C2_COMMONSEPARATOR, /* , - 44 */
715 C2_EUROPETERMINATOR, /* - - 45 */
716 C2_EUROPESEPARATOR, /* . - 46 */
717 C2_EUROPESEPARATOR, /* / - 47 */
718 C2_EUROPENUMBER, /* 0 - 48 */
719 C2_EUROPENUMBER, /* 1 - 49 */
720 C2_EUROPENUMBER, /* 2 - 50 */
721 C2_EUROPENUMBER, /* 3 - 51 */
722 C2_EUROPENUMBER, /* 4 - 52 */
723 C2_EUROPENUMBER, /* 5 - 53 */
724 C2_EUROPENUMBER, /* 6 - 54 */
725 C2_EUROPENUMBER, /* 7 - 55 */
726 C2_EUROPENUMBER, /* 8 - 56 */
727 C2_EUROPENUMBER, /* 9 - 57 */
728 C2_COMMONSEPARATOR, /* : - 58 */
729 C2_OTHERNEUTRAL, /* ; - 59 */
730 C2_OTHERNEUTRAL, /* < - 60 */
731 C2_OTHERNEUTRAL, /* = - 61 */
732 C2_OTHERNEUTRAL, /* > - 62 */
733 C2_OTHERNEUTRAL, /* ? - 63 */
734 C2_LEFTTORIGHT, /* @ - 64 */
735 C2_LEFTTORIGHT, /* A - 65 */
736 C2_LEFTTORIGHT, /* B - 66 */
737 C2_LEFTTORIGHT, /* C - 67 */
738 C2_LEFTTORIGHT, /* D - 68 */
739 C2_LEFTTORIGHT, /* E - 69 */
740 C2_LEFTTORIGHT, /* F - 70 */
741 C2_LEFTTORIGHT, /* G - 71 */
742 C2_LEFTTORIGHT, /* H - 72 */
743 C2_LEFTTORIGHT, /* I - 73 */
744 C2_LEFTTORIGHT, /* J - 74 */
745 C2_LEFTTORIGHT, /* K - 75 */
746 C2_LEFTTORIGHT, /* L - 76 */
747 C2_LEFTTORIGHT, /* M - 77 */
748 C2_LEFTTORIGHT, /* N - 78 */
749 C2_LEFTTORIGHT, /* O - 79 */
750 C2_LEFTTORIGHT, /* P - 80 */
751 C2_LEFTTORIGHT, /* Q - 81 */
752 C2_LEFTTORIGHT, /* R - 82 */
753 C2_LEFTTORIGHT, /* S - 83 */
754 C2_LEFTTORIGHT, /* T - 84 */
755 C2_LEFTTORIGHT, /* U - 85 */
756 C2_LEFTTORIGHT, /* V - 86 */
757 C2_LEFTTORIGHT, /* W - 87 */
758 C2_LEFTTORIGHT, /* X - 88 */
759 C2_LEFTTORIGHT, /* Y - 89 */
760 C2_LEFTTORIGHT, /* Z - 90 */
761 C2_OTHERNEUTRAL, /* [ - 91 */
762 C2_OTHERNEUTRAL, /* \ - 92 */
763 C2_OTHERNEUTRAL, /* ] - 93 */
764 C2_OTHERNEUTRAL, /* ^ - 94 */
765 C2_OTHERNEUTRAL, /* _ - 95 */
766 C2_OTHERNEUTRAL, /* ` - 96 */
767 C2_LEFTTORIGHT, /* a - 97 */
768 C2_LEFTTORIGHT, /* b - 98 */
769 C2_LEFTTORIGHT, /* c - 99 */
770 C2_LEFTTORIGHT, /* d - 100 */
771 C2_LEFTTORIGHT, /* e - 101 */
772 C2_LEFTTORIGHT, /* f - 102 */
773 C2_LEFTTORIGHT, /* g - 103 */
774 C2_LEFTTORIGHT, /* h - 104 */
775 C2_LEFTTORIGHT, /* i - 105 */
776 C2_LEFTTORIGHT, /* j - 106 */
777 C2_LEFTTORIGHT, /* k - 107 */
778 C2_LEFTTORIGHT, /* l - 108 */
779 C2_LEFTTORIGHT, /* m - 109 */
780 C2_LEFTTORIGHT, /* n - 110 */
781 C2_LEFTTORIGHT, /* o - 111 */
782 C2_LEFTTORIGHT, /* p - 112 */
783 C2_LEFTTORIGHT, /* q - 113 */
784 C2_LEFTTORIGHT, /* r - 114 */
785 C2_LEFTTORIGHT, /* s - 115 */
786 C2_LEFTTORIGHT, /* t - 116 */
787 C2_LEFTTORIGHT, /* u - 117 */
788 C2_LEFTTORIGHT, /* v - 118 */
789 C2_LEFTTORIGHT, /* w - 119 */
790 C2_LEFTTORIGHT, /* x - 120 */
791 C2_LEFTTORIGHT, /* y - 121 */
792 C2_LEFTTORIGHT, /* z - 122 */
793 C2_OTHERNEUTRAL, /* { - 123 */
794 C2_OTHERNEUTRAL, /* | - 124 */
795 C2_OTHERNEUTRAL, /* } - 125 */
796 C2_OTHERNEUTRAL, /* ~ - 126 */
797 C2_NOTAPPLICABLE, /* \x7f - 127 */
798 C2_NOTAPPLICABLE, /* € - 128 */
799 C2_NOTAPPLICABLE, /* � - 129 */
800 C2_OTHERNEUTRAL, /* ‚ - 130 */
801 C2_LEFTTORIGHT, /* ƒ - 131 */
802 C2_OTHERNEUTRAL, /* „ - 132 */
803 C2_OTHERNEUTRAL, /* … - 133 */
804 C2_OTHERNEUTRAL, /* † - 134 */
805 C2_OTHERNEUTRAL, /* ‡ - 135 */
806 C2_LEFTTORIGHT, /* ˆ - 136 */
807 C2_EUROPETERMINATOR, /* ‰ - 137 */
808 C2_LEFTTORIGHT, /* Š - 138 */
809 C2_OTHERNEUTRAL, /* ‹ - 139 */
810 C2_LEFTTORIGHT, /* Π- 140 */
811 C2_NOTAPPLICABLE, /* � - 141 */
812 C2_NOTAPPLICABLE, /* Ž - 142 */
813 C2_NOTAPPLICABLE, /* � - 143 */
814 C2_NOTAPPLICABLE, /* � - 144 */
815 C2_OTHERNEUTRAL, /* ‘ - 145 */
816 C2_OTHERNEUTRAL, /* ’ - 146 */
817 C2_OTHERNEUTRAL, /* “ - 147 */
818 C2_OTHERNEUTRAL, /* ” - 148 */
819 C2_OTHERNEUTRAL, /* • - 149 */
820 C2_OTHERNEUTRAL, /* – - 150 */
821 C2_OTHERNEUTRAL, /* — - 151 */
822 C2_LEFTTORIGHT, /* ˜ - 152 */
823 C2_OTHERNEUTRAL, /* ™ - 153 */
824 C2_LEFTTORIGHT, /* š - 154 */
825 C2_OTHERNEUTRAL, /* › - 155 */
826 C2_LEFTTORIGHT, /* œ - 156 */
827 C2_NOTAPPLICABLE, /* � - 157 */
828 C2_NOTAPPLICABLE, /* ž - 158 */
829 C2_LEFTTORIGHT, /* Ÿ - 159 */
830 C2_WHITESPACE, /*   - 160 */
831 C2_OTHERNEUTRAL, /* ¡ - 161 */
832 C2_EUROPETERMINATOR, /* ¢ - 162 */
833 C2_EUROPETERMINATOR, /* £ - 163 */
834 C2_EUROPETERMINATOR, /* ¤ - 164 */
835 C2_EUROPETERMINATOR, /* ¥ - 165 */
836 C2_OTHERNEUTRAL, /* ¦ - 166 */
837 C2_OTHERNEUTRAL, /* § - 167 */
838 C2_OTHERNEUTRAL, /* ¨ - 168 */
839 C2_OTHERNEUTRAL, /* © - 169 */
840 C2_OTHERNEUTRAL, /* ª - 170 */
841 C2_OTHERNEUTRAL, /* « - 171 */
842 C2_OTHERNEUTRAL, /* ¬ - 172 */
843 C2_OTHERNEUTRAL, /* ­ - 173 */
844 C2_OTHERNEUTRAL, /* ® - 174 */
845 C2_OTHERNEUTRAL, /* ¯ - 175 */
846 C2_EUROPETERMINATOR, /* ° - 176 */
847 C2_EUROPETERMINATOR, /* ± - 177 */
848 C2_EUROPENUMBER, /* ² - 178 */
849 C2_EUROPENUMBER, /* ³ - 179 */
850 C2_OTHERNEUTRAL, /* ´ - 180 */
851 C2_OTHERNEUTRAL, /* µ - 181 */
852 C2_OTHERNEUTRAL, /* ¶ - 182 */
853 C2_OTHERNEUTRAL, /* · - 183 */
854 C2_OTHERNEUTRAL, /* ¸ - 184 */
855 C2_EUROPENUMBER, /* ¹ - 185 */
856 C2_OTHERNEUTRAL, /* º - 186 */
857 C2_OTHERNEUTRAL, /* » - 187 */
858 C2_OTHERNEUTRAL, /* ¼ - 188 */
859 C2_OTHERNEUTRAL, /* ½ - 189 */
860 C2_OTHERNEUTRAL, /* ¾ - 190 */
861 C2_OTHERNEUTRAL, /* ¿ - 191 */
862 C2_LEFTTORIGHT, /* À - 192 */
863 C2_LEFTTORIGHT, /* Á - 193 */
864 C2_LEFTTORIGHT, /* Â - 194 */
865 C2_LEFTTORIGHT, /* Ã - 195 */
866 C2_LEFTTORIGHT, /* Ä - 196 */
867 C2_LEFTTORIGHT, /* Å - 197 */
868 C2_LEFTTORIGHT, /* Æ - 198 */
869 C2_LEFTTORIGHT, /* Ç - 199 */
870 C2_LEFTTORIGHT, /* È - 200 */
871 C2_LEFTTORIGHT, /* É - 201 */
872 C2_LEFTTORIGHT, /* Ê - 202 */
873 C2_LEFTTORIGHT, /* Ë - 203 */
874 C2_LEFTTORIGHT, /* Ì - 204 */
875 C2_LEFTTORIGHT, /* Í - 205 */
876 C2_LEFTTORIGHT, /* Î - 206 */
877 C2_LEFTTORIGHT, /* Ï - 207 */
878 C2_LEFTTORIGHT, /* Ð - 208 */
879 C2_LEFTTORIGHT, /* Ñ - 209 */
880 C2_LEFTTORIGHT, /* Ò - 210 */
881 C2_LEFTTORIGHT, /* Ó - 211 */
882 C2_LEFTTORIGHT, /* Ô - 212 */
883 C2_LEFTTORIGHT, /* Õ - 213 */
884 C2_LEFTTORIGHT, /* Ö - 214 */
885 C2_OTHERNEUTRAL, /* × - 215 */
886 C2_LEFTTORIGHT, /* Ø - 216 */
887 C2_LEFTTORIGHT, /* Ù - 217 */
888 C2_LEFTTORIGHT, /* Ú - 218 */
889 C2_LEFTTORIGHT, /* Û - 219 */
890 C2_LEFTTORIGHT, /* Ü - 220 */
891 C2_LEFTTORIGHT, /* Ý - 221 */
892 C2_LEFTTORIGHT, /* Þ - 222 */
893 C2_LEFTTORIGHT, /* ß - 223 */
894 C2_LEFTTORIGHT, /* à - 224 */
895 C2_LEFTTORIGHT, /* á - 225 */
896 C2_LEFTTORIGHT, /* â - 226 */
897 C2_LEFTTORIGHT, /* ã - 227 */
898 C2_LEFTTORIGHT, /* ä - 228 */
899 C2_LEFTTORIGHT, /* å - 229 */
900 C2_LEFTTORIGHT, /* æ - 230 */
901 C2_LEFTTORIGHT, /* ç - 231 */
902 C2_LEFTTORIGHT, /* è - 232 */
903 C2_LEFTTORIGHT, /* é - 233 */
904 C2_LEFTTORIGHT, /* ê - 234 */
905 C2_LEFTTORIGHT, /* ë - 235 */
906 C2_LEFTTORIGHT, /* ì - 236 */
907 C2_LEFTTORIGHT, /* í - 237 */
908 C2_LEFTTORIGHT, /* î - 238 */
909 C2_LEFTTORIGHT, /* ï - 239 */
910 C2_LEFTTORIGHT, /* ð - 240 */
911 C2_LEFTTORIGHT, /* ñ - 241 */
912 C2_LEFTTORIGHT, /* ò - 242 */
913 C2_LEFTTORIGHT, /* ó - 243 */
914 C2_LEFTTORIGHT, /* ô - 244 */
915 C2_LEFTTORIGHT, /* õ - 245 */
916 C2_LEFTTORIGHT, /* ö - 246 */
917 C2_OTHERNEUTRAL, /* ÷ - 247 */
918 C2_LEFTTORIGHT, /* ø - 248 */
919 C2_LEFTTORIGHT, /* ù - 249 */
920 C2_LEFTTORIGHT, /* ú - 250 */
921 C2_LEFTTORIGHT, /* û - 251 */
922 C2_LEFTTORIGHT, /* ü - 252 */
923 C2_LEFTTORIGHT, /* ý - 253 */
924 C2_LEFTTORIGHT, /* þ - 254 */
925 C2_LEFTTORIGHT /* ÿ - 255 */
928 static const WORD CT_CType3_LUT[] = {
929 0x0000, /* - 0 */
930 0x0000, /* - 1 */
931 0x0000, /* - 2 */
932 0x0000, /* - 3 */
933 0x0000, /* - 4 */
934 0x0000, /* - 5 */
935 0x0000, /* - 6 */
936 0x0000, /* - 7 */
937 0x0000, /* - 8 */
938 0x0008, /* - 9 */
939 0x0008, /* - 10 */
940 0x0008, /* - 11 */
941 0x0008, /* - 12 */
942 0x0008, /* - 13 */
943 0x0000, /* - 14 */
944 0x0000, /* - 15 */
945 0x0000, /* - 16 */
946 0x0000, /* - 17 */
947 0x0000, /* - 18 */
948 0x0000, /* - 19 */
949 0x0000, /* - 20 */
950 0x0000, /* - 21 */
951 0x0000, /* - 22 */
952 0x0000, /* - 23 */
953 0x0000, /* - 24 */
954 0x0000, /* - 25 */
955 0x0000, /* - 26 */
956 0x0000, /* - 27 */
957 0x0000, /* - 28 */
958 0x0000, /* - 29 */
959 0x0000, /* - 30 */
960 0x0000, /* - 31 */
961 0x0048, /* - 32 */
962 0x0048, /* ! - 33 */
963 0x0448, /* " - 34 */ /* " */
964 0x0048, /* # - 35 */
965 0x0448, /* $ - 36 */
966 0x0048, /* % - 37 */
967 0x0048, /* & - 38 */
968 0x0440, /* ' - 39 */
969 0x0048, /* ( - 40 */
970 0x0048, /* ) - 41 */
971 0x0048, /* * - 42 */
972 0x0048, /* + - 43 */
973 0x0048, /* , - 44 */
974 0x0440, /* - - 45 */
975 0x0048, /* . - 46 */
976 0x0448, /* / - 47 */
977 0x0040, /* 0 - 48 */
978 0x0040, /* 1 - 49 */
979 0x0040, /* 2 - 50 */
980 0x0040, /* 3 - 51 */
981 0x0040, /* 4 - 52 */
982 0x0040, /* 5 - 53 */
983 0x0040, /* 6 - 54 */
984 0x0040, /* 7 - 55 */
985 0x0040, /* 8 - 56 */
986 0x0040, /* 9 - 57 */
987 0x0048, /* : - 58 */
988 0x0048, /* ; - 59 */
989 0x0048, /* < - 60 */
990 0x0448, /* = - 61 */
991 0x0048, /* > - 62 */
992 0x0048, /* ? - 63 */
993 0x0448, /* @ - 64 */
994 0x8040, /* A - 65 */
995 0x8040, /* B - 66 */
996 0x8040, /* C - 67 */
997 0x8040, /* D - 68 */
998 0x8040, /* E - 69 */
999 0x8040, /* F - 70 */
1000 0x8040, /* G - 71 */
1001 0x8040, /* H - 72 */
1002 0x8040, /* I - 73 */
1003 0x8040, /* J - 74 */
1004 0x8040, /* K - 75 */
1005 0x8040, /* L - 76 */
1006 0x8040, /* M - 77 */
1007 0x8040, /* N - 78 */
1008 0x8040, /* O - 79 */
1009 0x8040, /* P - 80 */
1010 0x8040, /* Q - 81 */
1011 0x8040, /* R - 82 */
1012 0x8040, /* S - 83 */
1013 0x8040, /* T - 84 */
1014 0x8040, /* U - 85 */
1015 0x8040, /* V - 86 */
1016 0x8040, /* W - 87 */
1017 0x8040, /* X - 88 */
1018 0x8040, /* Y - 89 */
1019 0x8040, /* Z - 90 */
1020 0x0048, /* [ - 91 */
1021 0x0448, /* \ - 92 */
1022 0x0048, /* ] - 93 */
1023 0x0448, /* ^ - 94 */
1024 0x0448, /* _ - 95 */
1025 0x0448, /* ` - 96 */
1026 0x8040, /* a - 97 */
1027 0x8040, /* b - 98 */
1028 0x8040, /* c - 99 */
1029 0x8040, /* d - 100 */
1030 0x8040, /* e - 101 */
1031 0x8040, /* f - 102 */
1032 0x8040, /* g - 103 */
1033 0x8040, /* h - 104 */
1034 0x8040, /* i - 105 */
1035 0x8040, /* j - 106 */
1036 0x8040, /* k - 107 */
1037 0x8040, /* l - 108 */
1038 0x8040, /* m - 109 */
1039 0x8040, /* n - 110 */
1040 0x8040, /* o - 111 */
1041 0x8040, /* p - 112 */
1042 0x8040, /* q - 113 */
1043 0x8040, /* r - 114 */
1044 0x8040, /* s - 115 */
1045 0x8040, /* t - 116 */
1046 0x8040, /* u - 117 */
1047 0x8040, /* v - 118 */
1048 0x8040, /* w - 119 */
1049 0x8040, /* x - 120 */
1050 0x8040, /* y - 121 */
1051 0x8040, /* z - 122 */
1052 0x0048, /* { - 123 */
1053 0x0048, /* | - 124 */
1054 0x0048, /* } - 125 */
1055 0x0448, /* ~ - 126 */
1056 0x0000, /* \x7f - 127 */
1057 0x0000, /* € - 128 */
1058 0x0000, /* � - 129 */
1059 0x0008, /* ‚ - 130 */
1060 0x8000, /* ƒ - 131 */
1061 0x0008, /* „ - 132 */
1062 0x0008, /* … - 133 */
1063 0x0008, /* † - 134 */
1064 0x0008, /* ‡ - 135 */
1065 0x0001, /* ˆ - 136 */
1066 0x0008, /* ‰ - 137 */
1067 0x8003, /* Š - 138 */
1068 0x0008, /* ‹ - 139 */
1069 0x8000, /* Π- 140 */
1070 0x0000, /* � - 141 */
1071 0x0000, /* Ž - 142 */
1072 0x0000, /* � - 143 */
1073 0x0000, /* � - 144 */
1074 0x0088, /* ‘ - 145 */
1075 0x0088, /* ’ - 146 */
1076 0x0088, /* “ - 147 */
1077 0x0088, /* ” - 148 */
1078 0x0008, /* • - 149 */
1079 0x0400, /* – - 150 */
1080 0x0400, /* — - 151 */
1081 0x0408, /* ˜ - 152 */
1082 0x0000, /* ™ - 153 */
1083 0x8003, /* š - 154 */
1084 0x0008, /* › - 155 */
1085 0x8000, /* œ - 156 */
1086 0x0000, /* � - 157 */
1087 0x0000, /* ž - 158 */
1088 0x8003, /* Ÿ - 159 */
1089 0x0008, /*   - 160 */
1090 0x0008, /* ¡ - 161 */
1091 0x0048, /* ¢ - 162 */
1092 0x0048, /* £ - 163 */
1093 0x0008, /* ¤ - 164 */
1094 0x0048, /* ¥ - 165 */
1095 0x0048, /* ¦ - 166 */
1096 0x0008, /* § - 167 */
1097 0x0408, /* ¨ - 168 */
1098 0x0008, /* © - 169 */
1099 0x0400, /* ª - 170 */
1100 0x0008, /* « - 171 */
1101 0x0048, /* ¬ - 172 */
1102 0x0408, /* ­ - 173 */
1103 0x0008, /* ® - 174 */
1104 0x0448, /* ¯ - 175 */
1105 0x0008, /* ° - 176 */
1106 0x0008, /* ± - 177 */
1107 0x0000, /* ² - 178 */
1108 0x0000, /* ³ - 179 */
1109 0x0408, /* ´ - 180 */
1110 0x0008, /* µ - 181 */
1111 0x0008, /* ¶ - 182 */
1112 0x0008, /* · - 183 */
1113 0x0408, /* ¸ - 184 */
1114 0x0000, /* ¹ - 185 */
1115 0x0400, /* º - 186 */
1116 0x0008, /* » - 187 */
1117 0x0000, /* ¼ - 188 */
1118 0x0000, /* ½ - 189 */
1119 0x0000, /* ¾ - 190 */
1120 0x0008, /* ¿ - 191 */
1121 0x8003, /* À - 192 */
1122 0x8003, /* Á - 193 */
1123 0x8003, /* Â - 194 */
1124 0x8003, /* Ã - 195 */
1125 0x8003, /* Ä - 196 */
1126 0x8003, /* Å - 197 */
1127 0x8000, /* Æ - 198 */
1128 0x8003, /* Ç - 199 */
1129 0x8003, /* È - 200 */
1130 0x8003, /* É - 201 */
1131 0x8003, /* Ê - 202 */
1132 0x8003, /* Ë - 203 */
1133 0x8003, /* Ì - 204 */
1134 0x8003, /* Í - 205 */
1135 0x8003, /* Î - 206 */
1136 0x8003, /* Ï - 207 */
1137 0x8000, /* Ð - 208 */
1138 0x8003, /* Ñ - 209 */
1139 0x8003, /* Ò - 210 */
1140 0x8003, /* Ó - 211 */
1141 0x8003, /* Ô - 212 */
1142 0x8003, /* Õ - 213 */
1143 0x8003, /* Ö - 214 */
1144 0x0008, /* × - 215 */
1145 0x8003, /* Ø - 216 */
1146 0x8003, /* Ù - 217 */
1147 0x8003, /* Ú - 218 */
1148 0x8003, /* Û - 219 */
1149 0x8003, /* Ü - 220 */
1150 0x8003, /* Ý - 221 */
1151 0x8000, /* Þ - 222 */
1152 0x8000, /* ß - 223 */
1153 0x8003, /* à - 224 */
1154 0x8003, /* á - 225 */
1155 0x8003, /* â - 226 */
1156 0x8003, /* ã - 227 */
1157 0x8003, /* ä - 228 */
1158 0x8003, /* å - 229 */
1159 0x8000, /* æ - 230 */
1160 0x8003, /* ç - 231 */
1161 0x8003, /* è - 232 */
1162 0x8003, /* é - 233 */
1163 0x8003, /* ê - 234 */
1164 0x8003, /* ë - 235 */
1165 0x8003, /* ì - 236 */
1166 0x8003, /* í - 237 */
1167 0x8003, /* î - 238 */
1168 0x8003, /* ï - 239 */
1169 0x8000, /* ð - 240 */
1170 0x8003, /* ñ - 241 */
1171 0x8003, /* ò - 242 */
1172 0x8003, /* ó - 243 */
1173 0x8003, /* ô - 244 */
1174 0x8003, /* õ - 245 */
1175 0x8003, /* ö - 246 */
1176 0x0008, /* ÷ - 247 */
1177 0x8003, /* ø - 248 */
1178 0x8003, /* ù - 249 */
1179 0x8003, /* ú - 250 */
1180 0x8003, /* û - 251 */
1181 0x8003, /* ü - 252 */
1182 0x8003, /* ý - 253 */
1183 0x8000, /* þ - 254 */
1184 0x8003 /* ÿ - 255 */
1187 /***********************************************************************
1188 * GetStringTypeA [OLE2NLS.7]
1190 BOOL16 WINAPI GetStringType16(LCID locale,DWORD dwInfoType,LPCSTR src,
1191 INT16 cchSrc,LPWORD chartype)
1193 return GetStringTypeEx32A(locale,dwInfoType,src,cchSrc,chartype);
1195 /***********************************************************************
1196 * GetStringTypeA [KERNEL32.277]
1198 BOOL32 WINAPI GetStringType32A(LCID locale,DWORD dwInfoType,LPCSTR src,
1199 INT32 cchSrc,LPWORD chartype)
1201 return GetStringTypeEx32A(locale,dwInfoType,src,cchSrc,chartype);
1204 /***********************************************************************
1205 * GetStringTypeExA [KERNEL32.276]
1207 * FIXME: Ignores the locale.
1209 BOOL32 WINAPI GetStringTypeEx32A(LCID locale,DWORD dwInfoType,LPCSTR src,
1210 INT32 cchSrc,LPWORD chartype)
1212 int i;
1214 if ((src==NULL) || (chartype==NULL) || (src==(LPSTR)chartype))
1216 SetLastError(ERROR_INVALID_PARAMETER);
1217 return FALSE;
1220 if (cchSrc==-1)
1221 cchSrc=lstrlen32A(src)+1;
1223 switch (dwInfoType) {
1224 case CT_CTYPE1:
1225 for (i=0;i<cchSrc;i++)
1227 chartype[i] = 0;
1228 if (isdigit(src[i])) chartype[i]|=C1_DIGIT;
1229 if (isalpha(src[i])) chartype[i]|=C1_ALPHA;
1230 if (islower(src[i])) chartype[i]|=C1_LOWER;
1231 if (isupper(src[i])) chartype[i]|=C1_UPPER;
1232 if (isspace(src[i])) chartype[i]|=C1_SPACE;
1233 if (ispunct(src[i])) chartype[i]|=C1_PUNCT;
1234 if (iscntrl(src[i])) chartype[i]|=C1_CNTRL;
1235 /* FIXME: isblank() is a GNU extension */
1236 /* if (isblank(src[i])) chartype[i]|=C1_BLANK; */
1237 if ((src[i] == ' ') || (src[i] == '\t')) chartype[i]|=C1_BLANK;
1238 /* C1_XDIGIT */
1240 return TRUE;
1242 case CT_CTYPE2:
1243 for (i=0;i<cchSrc;i++)
1245 chartype[i]=(WORD)CT_CType2_LUT[i];
1247 return TRUE;
1249 case CT_CTYPE3:
1250 for (i=0;i<cchSrc;i++)
1252 chartype[i]=CT_CType3_LUT[i];
1254 return TRUE;
1256 default:
1257 ERR(ole,"Unknown dwInfoType:%ld\n",dwInfoType);
1258 return FALSE;
1262 /*********************************************************************
1263 * GetStringTypeW [KERNEL32.279]
1265 * NOTES
1266 * Yes, this is missing LCID locale. MS fault.
1268 BOOL32 WINAPI GetStringType32W(DWORD dwInfoType,LPCWSTR src,INT32 cchSrc,
1269 LPWORD chartype)
1271 return GetStringTypeEx32W(0/*defaultlocale*/,dwInfoType,src,cchSrc,chartype);
1274 /*********************************************************************
1275 * GetStringTypeW [KERNEL32.278]
1276 * FIXME: unicode chars are assumed chars
1278 BOOL32 WINAPI GetStringTypeEx32W(LCID locale,DWORD dwInfoType,LPCWSTR src,
1279 INT32 cchSrc,LPWORD chartype)
1281 int i;
1284 if (cchSrc==-1)
1285 cchSrc=lstrlen32W(src)+1;
1287 switch (dwInfoType) {
1288 case CT_CTYPE2:
1289 FIXME(ole,"CT_CTYPE2 not supported.\n");
1290 return FALSE;
1291 case CT_CTYPE3:
1292 FIXME(ole,"CT_CTYPE3 not supported.\n");
1293 return FALSE;
1294 default:break;
1296 for (i=0;i<cchSrc;i++) {
1297 chartype[i] = 0;
1298 if (isdigit(src[i])) chartype[i]|=C1_DIGIT;
1299 if (isalpha(src[i])) chartype[i]|=C1_ALPHA;
1300 if (islower(src[i])) chartype[i]|=C1_LOWER;
1301 if (isupper(src[i])) chartype[i]|=C1_UPPER;
1302 if (isspace(src[i])) chartype[i]|=C1_SPACE;
1303 if (ispunct(src[i])) chartype[i]|=C1_PUNCT;
1304 if (iscntrl(src[i])) chartype[i]|=C1_CNTRL;
1305 /* FIXME: isblank() is a GNU extension */
1306 /* if (isblank(src[i])) chartype[i]|=C1_BLANK; */
1307 if ((src[i] == ' ') || (src[i] == '\t')) chartype[i]|=C1_BLANK;
1308 /* C1_XDIGIT */
1310 return TRUE;
1313 /*****************************************************************
1314 * VerLanguageName16 [VER.10]
1316 DWORD WINAPI VerLanguageName16(UINT16 langid,LPSTR langname,UINT16 langnamelen)
1318 int i;
1319 DWORD result;
1320 char buffer[80];
1322 TRACE(ver,"(%d,%p,%d)\n",langid,langname,langnamelen);
1323 /* First, check \System\CurrentControlSet\control\Nls\Locale\<langid>
1324 * from the registry.
1326 sprintf(buffer,
1327 "\\System\\CurrentControlSet\\control\\Nls\\Locale\\%08x",
1328 langid);
1329 result = RegQueryValue16(HKEY_LOCAL_MACHINE, buffer, langname,
1330 (LPDWORD)&langnamelen);
1331 if (result == ERROR_SUCCESS) {
1332 langname[langnamelen-1]='\0';
1333 return langnamelen;
1335 /* if that fails, use the internal table */
1336 for (i=0;languages[i].langid!=0;i++)
1337 if (langid==languages[i].langid)
1338 break;
1339 strncpy(langname,languages[i].langname,langnamelen);
1340 langname[langnamelen-1]='\0';
1341 return strlen(languages[i].langname);
1344 /*****************************************************************
1345 * VerLanguageName32A [VERSION.9]
1347 DWORD WINAPI VerLanguageName32A(UINT32 langid,LPSTR langname,
1348 UINT32 langnamelen)
1350 return VerLanguageName16(langid,langname,langnamelen);
1353 /*****************************************************************
1354 * VerLanguageName32W [VERSION.10]
1356 DWORD WINAPI VerLanguageName32W(UINT32 langid,LPWSTR langname,
1357 UINT32 langnamelen)
1359 int i;
1360 LPWSTR keyname;
1361 DWORD result;
1362 char buffer[80];
1364 /* First, check \System\CurrentControlSet\control\Nls\Locale\<langid>
1365 * from the registry.
1367 sprintf(buffer,
1368 "\\System\\CurrentControlSet\\control\\Nls\\Locale\\%08x",
1369 langid);
1370 keyname = HEAP_strdupAtoW( GetProcessHeap(), 0, buffer );
1371 result = RegQueryValue32W(HKEY_LOCAL_MACHINE, keyname, langname,
1372 (LPDWORD)&langnamelen);
1373 HeapFree( GetProcessHeap(), 0, keyname );
1374 if (result != ERROR_SUCCESS) {
1375 /* if that fails, use the internal table */
1376 for (i=0;languages[i].langid!=0;i++)
1377 if (langid==languages[i].langid)
1378 break;
1379 lstrcpyAtoW( langname, languages[i].langname );
1380 langnamelen = strlen(languages[i].langname);
1381 /* same as strlenW(langname); */
1383 return langnamelen;
1386 static const unsigned char LCM_Unicode_LUT[] = {
1387 6 , 3, /* - 1 */
1388 6 , 4, /* - 2 */
1389 6 , 5, /* - 3 */
1390 6 , 6, /* - 4 */
1391 6 , 7, /* - 5 */
1392 6 , 8, /* - 6 */
1393 6 , 9, /* - 7 */
1394 6 , 10, /* - 8 */
1395 7 , 5, /* - 9 */
1396 7 , 6, /* - 10 */
1397 7 , 7, /* - 11 */
1398 7 , 8, /* - 12 */
1399 7 , 9, /* - 13 */
1400 6 , 11, /* - 14 */
1401 6 , 12, /* - 15 */
1402 6 , 13, /* - 16 */
1403 6 , 14, /* - 17 */
1404 6 , 15, /* - 18 */
1405 6 , 16, /* - 19 */
1406 6 , 17, /* - 20 */
1407 6 , 18, /* - 21 */
1408 6 , 19, /* - 22 */
1409 6 , 20, /* - 23 */
1410 6 , 21, /* - 24 */
1411 6 , 22, /* - 25 */
1412 6 , 23, /* - 26 */
1413 6 , 24, /* - 27 */
1414 6 , 25, /* - 28 */
1415 6 , 26, /* - 29 */
1416 6 , 27, /* - 30 */
1417 6 , 28, /* - 31 */
1418 7 , 2, /* - 32 */
1419 7 , 28, /* ! - 33 */
1420 7 , 29, /* " - 34 */ /* " */
1421 7 , 31, /* # - 35 */
1422 7 , 33, /* $ - 36 */
1423 7 , 35, /* % - 37 */
1424 7 , 37, /* & - 38 */
1425 6 , 128, /* ' - 39 */
1426 7 , 39, /* ( - 40 */
1427 7 , 42, /* ) - 41 */
1428 7 , 45, /* * - 42 */
1429 8 , 3, /* + - 43 */
1430 7 , 47, /* , - 44 */
1431 6 , 130, /* - - 45 */
1432 7 , 51, /* . - 46 */
1433 7 , 53, /* / - 47 */
1434 12 , 3, /* 0 - 48 */
1435 12 , 33, /* 1 - 49 */
1436 12 , 51, /* 2 - 50 */
1437 12 , 70, /* 3 - 51 */
1438 12 , 88, /* 4 - 52 */
1439 12 , 106, /* 5 - 53 */
1440 12 , 125, /* 6 - 54 */
1441 12 , 144, /* 7 - 55 */
1442 12 , 162, /* 8 - 56 */
1443 12 , 180, /* 9 - 57 */
1444 7 , 55, /* : - 58 */
1445 7 , 58, /* ; - 59 */
1446 8 , 14, /* < - 60 */
1447 8 , 18, /* = - 61 */
1448 8 , 20, /* > - 62 */
1449 7 , 60, /* ? - 63 */
1450 7 , 62, /* @ - 64 */
1451 14 , 2, /* A - 65 */
1452 14 , 9, /* B - 66 */
1453 14 , 10, /* C - 67 */
1454 14 , 26, /* D - 68 */
1455 14 , 33, /* E - 69 */
1456 14 , 35, /* F - 70 */
1457 14 , 37, /* G - 71 */
1458 14 , 44, /* H - 72 */
1459 14 , 50, /* I - 73 */
1460 14 , 53, /* J - 74 */
1461 14 , 54, /* K - 75 */
1462 14 , 72, /* L - 76 */
1463 14 , 81, /* M - 77 */
1464 14 , 112, /* N - 78 */
1465 14 , 124, /* O - 79 */
1466 14 , 126, /* P - 80 */
1467 14 , 137, /* Q - 81 */
1468 14 , 138, /* R - 82 */
1469 14 , 145, /* S - 83 */
1470 14 , 153, /* T - 84 */
1471 14 , 159, /* U - 85 */
1472 14 , 162, /* V - 86 */
1473 14 , 164, /* W - 87 */
1474 14 , 166, /* X - 88 */
1475 14 , 167, /* Y - 89 */
1476 14 , 169, /* Z - 90 */
1477 7 , 63, /* [ - 91 */
1478 7 , 65, /* \ - 92 */
1479 7 , 66, /* ] - 93 */
1480 7 , 67, /* ^ - 94 */
1481 7 , 68, /* _ - 95 */
1482 7 , 72, /* ` - 96 */
1483 14 , 2, /* a - 97 */
1484 14 , 9, /* b - 98 */
1485 14 , 10, /* c - 99 */
1486 14 , 26, /* d - 100 */
1487 14 , 33, /* e - 101 */
1488 14 , 35, /* f - 102 */
1489 14 , 37, /* g - 103 */
1490 14 , 44, /* h - 104 */
1491 14 , 50, /* i - 105 */
1492 14 , 53, /* j - 106 */
1493 14 , 54, /* k - 107 */
1494 14 , 72, /* l - 108 */
1495 14 , 81, /* m - 109 */
1496 14 , 112, /* n - 110 */
1497 14 , 124, /* o - 111 */
1498 14 , 126, /* p - 112 */
1499 14 , 137, /* q - 113 */
1500 14 , 138, /* r - 114 */
1501 14 , 145, /* s - 115 */
1502 14 , 153, /* t - 116 */
1503 14 , 159, /* u - 117 */
1504 14 , 162, /* v - 118 */
1505 14 , 164, /* w - 119 */
1506 14 , 166, /* x - 120 */
1507 14 , 167, /* y - 121 */
1508 14 , 169, /* z - 122 */
1509 7 , 74, /* { - 123 */
1510 7 , 76, /* | - 124 */
1511 7 , 78, /* } - 125 */
1512 7 , 80, /* ~ - 126 */
1513 6 , 29, /* \x7f - 127 */
1514 6 , 30, /* € - 128 */
1515 6 , 31, /* � - 129 */
1516 7 , 123, /* ‚ - 130 */
1517 14 , 35, /* ƒ - 131 */
1518 7 , 127, /* „ - 132 */
1519 10 , 21, /* … - 133 */
1520 10 , 15, /* † - 134 */
1521 10 , 16, /* ‡ - 135 */
1522 7 , 67, /* ˆ - 136 */
1523 10 , 22, /* ‰ - 137 */
1524 14 , 145, /* Š - 138 */
1525 7 , 136, /* ‹ - 139 */
1526 14 + 16 , 124, /* Π- 140 */
1527 6 , 43, /* � - 141 */
1528 6 , 44, /* Ž - 142 */
1529 6 , 45, /* � - 143 */
1530 6 , 46, /* � - 144 */
1531 7 , 121, /* ‘ - 145 */
1532 7 , 122, /* ’ - 146 */
1533 7 , 125, /* “ - 147 */
1534 7 , 126, /* ” - 148 */
1535 10 , 17, /* • - 149 */
1536 6 , 137, /* – - 150 */
1537 6 , 139, /* — - 151 */
1538 7 , 93, /* ˜ - 152 */
1539 14 , 156, /* ™ - 153 */
1540 14 , 145, /* š - 154 */
1541 7 , 137, /* › - 155 */
1542 14 + 16 , 124, /* œ - 156 */
1543 6 , 59, /* � - 157 */
1544 6 , 60, /* ž - 158 */
1545 14 , 167, /* Ÿ - 159 */
1546 7 , 4, /*   - 160 */
1547 7 , 81, /* ¡ - 161 */
1548 10 , 2, /* ¢ - 162 */
1549 10 , 3, /* £ - 163 */
1550 10 , 4, /* ¤ - 164 */
1551 10 , 5, /* ¥ - 165 */
1552 7 , 82, /* ¦ - 166 */
1553 10 , 6, /* § - 167 */
1554 7 , 83, /* ¨ - 168 */
1555 10 , 7, /* © - 169 */
1556 14 , 2, /* ª - 170 */
1557 8 , 24, /* « - 171 */
1558 10 , 8, /* ¬ - 172 */
1559 6 , 131, /* ­ - 173 */
1560 10 , 9, /* ® - 174 */
1561 7 , 84, /* ¯ - 175 */
1562 10 , 10, /* ° - 176 */
1563 8 , 23, /* ± - 177 */
1564 12 , 51, /* ² - 178 */
1565 12 , 70, /* ³ - 179 */
1566 7 , 85, /* ´ - 180 */
1567 10 , 11, /* µ - 181 */
1568 10 , 12, /* ¶ - 182 */
1569 10 , 13, /* · - 183 */
1570 7 , 86, /* ¸ - 184 */
1571 12 , 33, /* ¹ - 185 */
1572 14 , 124, /* º - 186 */
1573 8 , 26, /* » - 187 */
1574 12 , 21, /* ¼ - 188 */
1575 12 , 25, /* ½ - 189 */
1576 12 , 29, /* ¾ - 190 */
1577 7 , 87, /* ¿ - 191 */
1578 14 , 2, /* À - 192 */
1579 14 , 2, /* Á - 193 */
1580 14 , 2, /* Â - 194 */
1581 14 , 2, /* Ã - 195 */
1582 14 , 2, /* Ä - 196 */
1583 14 , 2, /* Å - 197 */
1584 14 + 16 , 2, /* Æ - 198 */
1585 14 , 10, /* Ç - 199 */
1586 14 , 33, /* È - 200 */
1587 14 , 33, /* É - 201 */
1588 14 , 33, /* Ê - 202 */
1589 14 , 33, /* Ë - 203 */
1590 14 , 50, /* Ì - 204 */
1591 14 , 50, /* Í - 205 */
1592 14 , 50, /* Î - 206 */
1593 14 , 50, /* Ï - 207 */
1594 14 , 26, /* Ð - 208 */
1595 14 , 112, /* Ñ - 209 */
1596 14 , 124, /* Ò - 210 */
1597 14 , 124, /* Ó - 211 */
1598 14 , 124, /* Ô - 212 */
1599 14 , 124, /* Õ - 213 */
1600 14 , 124, /* Ö - 214 */
1601 8 , 28, /* × - 215 */
1602 14 , 124, /* Ø - 216 */
1603 14 , 159, /* Ù - 217 */
1604 14 , 159, /* Ú - 218 */
1605 14 , 159, /* Û - 219 */
1606 14 , 159, /* Ü - 220 */
1607 14 , 167, /* Ý - 221 */
1608 14 + 32 , 153, /* Þ - 222 */
1609 14 + 48 , 145, /* ß - 223 */
1610 14 , 2, /* à - 224 */
1611 14 , 2, /* á - 225 */
1612 14 , 2, /* â - 226 */
1613 14 , 2, /* ã - 227 */
1614 14 , 2, /* ä - 228 */
1615 14 , 2, /* å - 229 */
1616 14 + 16 , 2, /* æ - 230 */
1617 14 , 10, /* ç - 231 */
1618 14 , 33, /* è - 232 */
1619 14 , 33, /* é - 233 */
1620 14 , 33, /* ê - 234 */
1621 14 , 33, /* ë - 235 */
1622 14 , 50, /* ì - 236 */
1623 14 , 50, /* í - 237 */
1624 14 , 50, /* î - 238 */
1625 14 , 50, /* ï - 239 */
1626 14 , 26, /* ð - 240 */
1627 14 , 112, /* ñ - 241 */
1628 14 , 124, /* ò - 242 */
1629 14 , 124, /* ó - 243 */
1630 14 , 124, /* ô - 244 */
1631 14 , 124, /* õ - 245 */
1632 14 , 124, /* ö - 246 */
1633 8 , 29, /* ÷ - 247 */
1634 14 , 124, /* ø - 248 */
1635 14 , 159, /* ù - 249 */
1636 14 , 159, /* ú - 250 */
1637 14 , 159, /* û - 251 */
1638 14 , 159, /* ü - 252 */
1639 14 , 167, /* ý - 253 */
1640 14 + 32 , 153, /* þ - 254 */
1641 14 , 167 /* ÿ - 255 */ };
1643 static const unsigned char LCM_Unicode_LUT_2[] = { 33, 44, 145 };
1645 #define LCM_Diacritic_Start 131
1647 static const unsigned char LCM_Diacritic_LUT[] = {
1648 123, /* ƒ - 131 */
1649 2, /* „ - 132 */
1650 2, /* … - 133 */
1651 2, /* † - 134 */
1652 2, /* ‡ - 135 */
1653 3, /* ˆ - 136 */
1654 2, /* ‰ - 137 */
1655 20, /* Š - 138 */
1656 2, /* ‹ - 139 */
1657 2, /* Π- 140 */
1658 2, /* � - 141 */
1659 2, /* Ž - 142 */
1660 2, /* � - 143 */
1661 2, /* � - 144 */
1662 2, /* ‘ - 145 */
1663 2, /* ’ - 146 */
1664 2, /* “ - 147 */
1665 2, /* ” - 148 */
1666 2, /* • - 149 */
1667 2, /* – - 150 */
1668 2, /* — - 151 */
1669 2, /* ˜ - 152 */
1670 2, /* ™ - 153 */
1671 20, /* š - 154 */
1672 2, /* › - 155 */
1673 2, /* œ - 156 */
1674 2, /* � - 157 */
1675 2, /* ž - 158 */
1676 19, /* Ÿ - 159 */
1677 2, /*   - 160 */
1678 2, /* ¡ - 161 */
1679 2, /* ¢ - 162 */
1680 2, /* £ - 163 */
1681 2, /* ¤ - 164 */
1682 2, /* ¥ - 165 */
1683 2, /* ¦ - 166 */
1684 2, /* § - 167 */
1685 2, /* ¨ - 168 */
1686 2, /* © - 169 */
1687 3, /* ª - 170 */
1688 2, /* « - 171 */
1689 2, /* ¬ - 172 */
1690 2, /* ­ - 173 */
1691 2, /* ® - 174 */
1692 2, /* ¯ - 175 */
1693 2, /* ° - 176 */
1694 2, /* ± - 177 */
1695 2, /* ² - 178 */
1696 2, /* ³ - 179 */
1697 2, /* ´ - 180 */
1698 2, /* µ - 181 */
1699 2, /* ¶ - 182 */
1700 2, /* · - 183 */
1701 2, /* ¸ - 184 */
1702 2, /* ¹ - 185 */
1703 3, /* º - 186 */
1704 2, /* » - 187 */
1705 2, /* ¼ - 188 */
1706 2, /* ½ - 189 */
1707 2, /* ¾ - 190 */
1708 2, /* ¿ - 191 */
1709 15, /* À - 192 */
1710 14, /* Á - 193 */
1711 18, /* Â - 194 */
1712 25, /* Ã - 195 */
1713 19, /* Ä - 196 */
1714 26, /* Å - 197 */
1715 2, /* Æ - 198 */
1716 28, /* Ç - 199 */
1717 15, /* È - 200 */
1718 14, /* É - 201 */
1719 18, /* Ê - 202 */
1720 19, /* Ë - 203 */
1721 15, /* Ì - 204 */
1722 14, /* Í - 205 */
1723 18, /* Î - 206 */
1724 19, /* Ï - 207 */
1725 104, /* Ð - 208 */
1726 25, /* Ñ - 209 */
1727 15, /* Ò - 210 */
1728 14, /* Ó - 211 */
1729 18, /* Ô - 212 */
1730 25, /* Õ - 213 */
1731 19, /* Ö - 214 */
1732 2, /* × - 215 */
1733 33, /* Ø - 216 */
1734 15, /* Ù - 217 */
1735 14, /* Ú - 218 */
1736 18, /* Û - 219 */
1737 19, /* Ü - 220 */
1738 14, /* Ý - 221 */
1739 2, /* Þ - 222 */
1740 2, /* ß - 223 */
1741 15, /* à - 224 */
1742 14, /* á - 225 */
1743 18, /* â - 226 */
1744 25, /* ã - 227 */
1745 19, /* ä - 228 */
1746 26, /* å - 229 */
1747 2, /* æ - 230 */
1748 28, /* ç - 231 */
1749 15, /* è - 232 */
1750 14, /* é - 233 */
1751 18, /* ê - 234 */
1752 19, /* ë - 235 */
1753 15, /* ì - 236 */
1754 14, /* í - 237 */
1755 18, /* î - 238 */
1756 19, /* ï - 239 */
1757 104, /* ð - 240 */
1758 25, /* ñ - 241 */
1759 15, /* ò - 242 */
1760 14, /* ó - 243 */
1761 18, /* ô - 244 */
1762 25, /* õ - 245 */
1763 19, /* ö - 246 */
1764 2, /* ÷ - 247 */
1765 33, /* ø - 248 */
1766 15, /* ù - 249 */
1767 14, /* ú - 250 */
1768 18, /* û - 251 */
1769 19, /* ü - 252 */
1770 14, /* ý - 253 */
1771 2, /* þ - 254 */
1772 19, /* ÿ - 255 */
1775 static int OLE2NLS_isPunctuation(unsigned char c)
1777 /* "punctuation character" in this context is a character which is
1778 considered "less important" during word sort comparison.
1779 See LCMapString implementation for the precise definition
1780 of "less important". */
1782 return (LCM_Unicode_LUT[-2+2*c]==6);
1785 static int identity(int c)
1787 return c;
1790 /*************************************************************************
1791 * LCMapString32A [KERNEL32.492]
1793 * Convert a string, or generate a sort key from it.
1795 * If (mapflags & LCMAP_SORTKEY), the function will generate
1796 * a sort key for the source string. Else, it will convert it
1797 * accordingly to the flags LCMAP_UPPERCASE, LCMAP_LOWERCASE,...
1799 * RETURNS
1800 * Error : 0.
1801 * Success : length of the result string.
1803 * NOTES
1804 * If called with scrlen = -1, the function will compute the length
1805 * of the 0-terminated string strsrc by itself.
1807 * If called with dstlen = 0, returns the buffer length that
1808 * would be required.
1810 * NORM_IGNOREWIDTH means to compare ASCII and Unicode characters
1811 * as if they are equal. Since Wine separates ASCII and Unicode into
1812 * separate functions, we shouldn't have to do anything for this flag.
1813 * I added it to the list of flags that don't need a fixme message
1814 * to make MS Word 95 not print several thousand fixme messages for
1815 * this function.
1817 INT32 WINAPI LCMapString32A(
1818 LCID lcid /* locale identifier created with MAKELCID;
1819 LOCALE_SYSTEM_DEFAULT and LOCALE_USER_DEFAULT are
1820 predefined values. */,
1821 DWORD mapflags /* flags */,
1822 LPCSTR srcstr /* source buffer */,
1823 INT32 srclen /* source length */,
1824 LPSTR dststr /* destination buffer */,
1825 INT32 dstlen /* destination buffer length */)
1827 int i;
1829 TRACE(string,"(0x%04lx,0x%08lx,%s,%d,%p,%d)\n",
1830 lcid,mapflags,srcstr,srclen,dststr,dstlen);
1832 if ( ((dstlen!=0) && (dststr==NULL)) || (srcstr==NULL) )
1834 ERR(ole, "(src=%s,dest=%s): Invalid NULL string\n", srcstr, dststr);
1835 SetLastError(ERROR_INVALID_PARAMETER);
1836 return 0;
1838 if (srclen == -1)
1839 srclen = lstrlen32A(srcstr) + 1 ; /* (include final '\0') */
1841 if (mapflags & ~ ( LCMAP_UPPERCASE | LCMAP_LOWERCASE | LCMAP_SORTKEY |
1842 NORM_IGNORECASE | NORM_IGNORENONSPACE | SORT_STRINGSORT |
1843 NORM_IGNOREWIDTH) )
1845 FIXME(string,"(0x%04lx,0x%08lx,%p,%d,%p,%d): "
1846 "unimplemented flags: 0x%08lx\n",
1847 lcid,mapflags,srcstr,srclen,dststr,dstlen,mapflags);
1850 if ( !(mapflags & LCMAP_SORTKEY) )
1852 int (*f)(int)=identity;
1854 if (dstlen==0)
1855 return srclen; /* dstlen=0 means "do nothing but return required length" */
1856 if (dstlen<srclen)
1857 srclen=dstlen; /* No, this case is not an error under Windows 95.
1858 And no '\0' gets written. */
1859 if (mapflags & LCMAP_UPPERCASE)
1860 f = toupper;
1861 else if (mapflags & LCMAP_LOWERCASE)
1862 f = tolower;
1863 for (i=0; i < srclen; i++)
1864 dststr[i] = (CHAR) f(srcstr[i]);
1865 return srclen;
1868 /* else ... (mapflags & LCMAP_SORTKEY) */
1870 int unicode_len=0;
1871 int case_len=0;
1872 int diacritic_len=0;
1873 int delayed_punctuation_len=0;
1874 char *case_component;
1875 char *diacritic_component;
1876 char *delayed_punctuation_component;
1877 int room,count;
1878 int flag_stringsort = mapflags & SORT_STRINGSORT;
1880 /* compute how much room we will need */
1881 for (i=0;i<srclen;i++)
1883 int ofs;
1884 unsigned char source_char = srcstr[i];
1885 if (source_char!='\0')
1887 if (flag_stringsort || !OLE2NLS_isPunctuation(source_char))
1889 unicode_len++;
1890 if ( LCM_Unicode_LUT[-2+2*source_char] & ~15 )
1891 unicode_len++; /* double letter */
1893 else
1895 delayed_punctuation_len++;
1899 if (isupper(source_char))
1900 case_len=unicode_len;
1902 ofs = source_char - LCM_Diacritic_Start;
1903 if ((ofs>=0) && (LCM_Diacritic_LUT[ofs]!=2))
1904 diacritic_len=unicode_len;
1907 if (mapflags & NORM_IGNORECASE)
1908 case_len=0;
1909 if (mapflags & NORM_IGNORENONSPACE)
1910 diacritic_len=0;
1912 room = 2 * unicode_len /* "unicode" component */
1913 + diacritic_len /* "diacritic" component */
1914 + case_len /* "case" component */
1915 + 4 * delayed_punctuation_len /* punctuation in word sort mode */
1916 + 4 /* four '\1' separators */
1917 + 1 ; /* terminal '\0' */
1918 if (dstlen==0)
1919 return room;
1920 else if (dstlen<room)
1922 SetLastError(ERROR_INSUFFICIENT_BUFFER);
1923 return 0;
1926 /*FIXME the Pointercheck should not be nessesary */
1927 if (IsBadWritePtr32 (dststr,room))
1928 { ERR (string,"bad destination buffer (dststr) : %p,%d\n",dststr,dstlen);
1929 SetLastError(ERROR_INSUFFICIENT_BUFFER);
1930 return 0;
1933 /* locate each component, write separators */
1934 diacritic_component = dststr + 2*unicode_len ;
1935 *diacritic_component++ = '\1';
1936 case_component = diacritic_component + diacritic_len ;
1937 *case_component++ = '\1';
1938 delayed_punctuation_component = case_component + case_len ;
1939 *delayed_punctuation_component++ = '\1';
1940 *delayed_punctuation_component++ = '\1';
1942 /* read source string char by char, write
1943 corresponding weight in each component. */
1944 for (i=0,count=0;i<srclen;i++)
1946 unsigned char source_char=srcstr[i];
1947 if (source_char!='\0')
1949 int type,longcode;
1950 type = LCM_Unicode_LUT[-2+2*source_char];
1951 longcode = type >> 4;
1952 type &= 15;
1953 if (!flag_stringsort && OLE2NLS_isPunctuation(source_char))
1955 UINT16 encrypted_location = (1<<15) + 7 + 4*count;
1956 *delayed_punctuation_component++ = (unsigned char) (encrypted_location>>8);
1957 *delayed_punctuation_component++ = (unsigned char) (encrypted_location&255);
1958 /* big-endian is used here because it lets string comparison be
1959 compatible with numerical comparison */
1961 *delayed_punctuation_component++ = type;
1962 *delayed_punctuation_component++ = LCM_Unicode_LUT[-1+2*source_char];
1963 /* assumption : a punctuation character is never a
1964 double or accented letter */
1966 else
1968 dststr[2*count] = type;
1969 dststr[2*count+1] = LCM_Unicode_LUT[-1+2*source_char];
1970 if (longcode)
1972 if (count<case_len)
1973 case_component[count] = ( isupper(source_char) ? 18 : 2 ) ;
1974 if (count<diacritic_len)
1975 diacritic_component[count] = 2; /* assumption: a double letter
1976 is never accented */
1977 count++;
1979 dststr[2*count] = type;
1980 dststr[2*count+1] = *(LCM_Unicode_LUT_2 - 1 + longcode);
1981 /* 16 in the first column of LCM_Unicode_LUT --> longcode = 1
1982 32 in the first column of LCM_Unicode_LUT --> longcode = 2
1983 48 in the first column of LCM_Unicode_LUT --> longcode = 3 */
1986 if (count<case_len)
1987 case_component[count] = ( isupper(source_char) ? 18 : 2 ) ;
1988 if (count<diacritic_len)
1990 int ofs = source_char - LCM_Diacritic_Start;
1991 diacritic_component[count] = (ofs>=0 ? LCM_Diacritic_LUT[ofs] : 2);
1993 count++;
1997 dststr[room-1] = '\0';
1998 return room;
2002 /*************************************************************************
2003 * LCMapString32W [KERNEL32.493]
2005 * Convert a string, or generate a sort key from it.
2007 * NOTE
2009 * See LCMapString32A for documentation
2011 INT32 WINAPI LCMapString32W(
2012 LCID lcid,DWORD mapflags,LPCWSTR srcstr,INT32 srclen,LPWSTR dststr,
2013 INT32 dstlen)
2015 int i;
2017 TRACE(string,"(0x%04lx,0x%08lx,%p,%d,%p,%d)\n",
2018 lcid,mapflags,srcstr,srclen,dststr,dstlen);
2020 if ( ((dstlen!=0) && (dststr==NULL)) || (srcstr==NULL) )
2022 ERR(ole, "(src=%p,dst=%p): Invalid NULL string\n", srcstr, dststr);
2023 SetLastError(ERROR_INVALID_PARAMETER);
2024 return 0;
2026 if (srclen==-1)
2027 srclen = lstrlen32W(srcstr)+1;
2028 if (mapflags & LCMAP_SORTKEY)
2030 FIXME(string,"(0x%04lx,0x%08lx,%p,%d,%p,%d): "
2031 "unimplemented flags: 0x%08lx\n",
2032 lcid,mapflags,srcstr,srclen,dststr,dstlen,mapflags);
2033 return 0;
2035 else
2037 int (*f)(int)=identity;
2039 if (dstlen==0)
2040 return srclen;
2041 if (dstlen<srclen)
2042 return 0;
2043 if (mapflags & LCMAP_UPPERCASE)
2044 f = toupper;
2045 else if (mapflags & LCMAP_LOWERCASE)
2046 f = tolower;
2047 for (i=0; i < srclen; i++)
2048 dststr[i] = (WCHAR) f(srcstr[i]);
2049 return srclen;
2053 /***********************************************************************
2054 * CompareString16 (OLE2NLS.8)
2056 UINT16 WINAPI CompareString16(DWORD lcid,DWORD fdwStyle,
2057 LPCSTR s1,DWORD l1,LPCSTR s2,DWORD l2)
2059 return (UINT16)CompareString32A(lcid,fdwStyle,s1,l1,s2,l2);
2062 /***********************************************************************
2063 * CompareString32A [KERNEL32.29] Compares two strings using locale
2065 * RETURNS
2067 * success: CSTR_LESS_THAN, CSTR_EQUAL, CSTR_GREATER_THAN
2068 * failure: 0
2070 * NOTES
2072 * Defaults to a word sort, but uses a string sort if
2073 * SORT_STRINGSORT is set.
2074 * Calls SetLastError for ERROR_INVALID_FLAGS, ERROR_INVALID_PARAMETER.
2076 * BUGS
2078 * This implementation ignores the locale
2080 * FIXME
2082 * Quite inefficient.
2084 UINT32 WINAPI CompareString32A(
2085 DWORD lcid, /* locale ID */
2086 DWORD fdwStyle, /* comparison-style options */
2087 LPCSTR s1, /* first string */
2088 DWORD l1, /* length of first string */
2089 LPCSTR s2, /* second string */
2090 DWORD l2) /* length of second string */
2092 int mapstring_flags;
2093 int len1,len2;
2094 int result;
2095 LPSTR sk1,sk2;
2096 TRACE(ole,"%s and %s\n",
2097 debugstr_a (s1), debugstr_a (s2));
2099 if ( (s1==NULL) || (s2==NULL) )
2101 ERR(ole, "(s1=%s,s2=%s): Invalid NULL string\n", s1, s2);
2102 SetLastError(ERROR_INVALID_PARAMETER);
2103 return 0;
2106 if(fdwStyle & NORM_IGNORESYMBOLS)
2107 FIXME(ole, "IGNORESYMBOLS not supported\n");
2109 mapstring_flags = LCMAP_SORTKEY | fdwStyle ;
2110 len1 = LCMapString32A(lcid,mapstring_flags,s1,l1,NULL,0);
2111 len2 = LCMapString32A(lcid,mapstring_flags,s2,l2,NULL,0);
2113 if ((len1==0)||(len2==0))
2114 return 0; /* something wrong happened */
2116 sk1 = (LPSTR)HeapAlloc(GetProcessHeap(),0,len1);
2117 sk2 = (LPSTR)HeapAlloc(GetProcessHeap(),0,len2);
2118 if ( (!LCMapString32A(lcid,mapstring_flags,s1,l1,sk1,len1))
2119 || (!LCMapString32A(lcid,mapstring_flags,s2,l2,sk2,len2)) )
2121 ERR(ole,"Bug in LCmapString32A.\n");
2122 result = 0;
2124 else
2126 /* strcmp doesn't necessarily return -1, 0, or 1 */
2127 result = strcmp(sk1,sk2);
2129 HeapFree(GetProcessHeap(),0,sk1);
2130 HeapFree(GetProcessHeap(),0,sk2);
2132 if (result < 0)
2133 return 1;
2134 if (result == 0)
2135 return 2;
2137 /* must be greater, if we reach this point */
2138 return 3;
2141 /***********************************************************************
2142 * CompareString32W (KERNEL32.30)
2143 * This implementation ignores the locale
2144 * FIXME : Does only string sort. Should
2145 * be reimplemented the same way as CompareString32A.
2147 UINT32 WINAPI CompareString32W(DWORD lcid, DWORD fdwStyle,
2148 LPCWSTR s1, DWORD l1, LPCWSTR s2,DWORD l2)
2150 int len,ret;
2151 if(fdwStyle & NORM_IGNORENONSPACE)
2152 FIXME(ole,"IGNORENONSPACE not supprted\n");
2153 if(fdwStyle & NORM_IGNORESYMBOLS)
2154 FIXME(ole,"IGNORESYMBOLS not supported\n");
2156 /* Is strcmp defaulting to string sort or to word sort?? */
2157 /* FIXME: Handle NORM_STRINGSORT */
2158 l1 = (l1==-1)?lstrlen32W(s1):l1;
2159 l2 = (l2==-1)?lstrlen32W(s2):l2;
2160 len = l1<l2 ? l1:l2;
2161 ret = (fdwStyle & NORM_IGNORECASE) ?
2162 lstrncmpi32W(s1,s2,len) : lstrncmp32W(s1,s2,len);
2163 /* not equal, return 1 or 3 */
2164 if(ret!=0) return ret+2;
2165 /* same len, return 2 */
2166 if(l1==l2) return 2;
2167 /* the longer one is lexically greater */
2168 return (l1<l2)? 1 : 3;
2171 /*****************************************************************
2173 * OLE_GetFormatA() [internal]
2176 This function implements stuff for GetDateFormat() and
2177 GetTimeFormat().
2179 d single-digit (no leading zero) day (of month)
2180 dd two-digit day (of month)
2181 ddd short day-of-week name
2182 dddd long day-of-week name
2183 M single-digit month
2184 MM two-digit month
2185 MMM short month name
2186 MMMM full month name
2187 y two-digit year, no leading 0
2188 yy two-digit year
2189 yyyy four-digit year
2190 gg era string
2191 h hours with no leading zero (12-hour)
2192 hh hours with full two digits
2193 H hours with no leading zero (24-hour)
2194 HH hours with full two digits
2195 m minutes with no leading zero
2196 mm minutes with full two digits
2197 s seconds with no leading zero
2198 ss seconds with full two digits
2199 t time marker (A or P)
2200 tt time marker (AM, PM)
2201 '' used to quote literal characters
2202 '' (within a quoted string) indicates a literal '
2204 These functions REQUIRE valid locale, date, and format.
2208 INT32 WINAPI OLE_GetFormatA(LCID locale,
2209 DWORD flags,
2210 DWORD tflags,
2211 LPSYSTEMTIME xtime,
2212 LPCSTR _format,
2213 LPSTR date, INT32 datelen)
2215 INT32 inpos, outpos;
2216 int count, type, inquote, Overflow;
2217 char buf[40];
2218 char format[40];
2219 char * pos;
2220 int buflen;
2222 const char * _dgfmt[] = { "%d", "%02d" };
2223 const char ** dgfmt = _dgfmt - 1;
2225 /* report, for debugging */
2226 TRACE(ole, "(0x%lx,0x%lx, 0x%lx, time(d=%d,h=%d,m=%d,s=%d), fmt:\'%s\' (at %p), %p (%s), len=%d)\n",
2227 locale, flags, tflags,
2228 xtime->wDay, xtime->wHour, xtime->wMinute, xtime->wSecond,
2229 format, format, date, date, datelen);
2231 /* initalize state variables and output buffer */
2232 inpos = outpos = 0;
2233 count = 0; inquote = 0; Overflow = 0;
2234 type = '\0';
2235 date[0] = buf[0] = '\0';
2237 strcpy(format,_format);
2239 /* alter the formatstring, while it works for all languages now in wine
2240 its possible that it fails when the time looks like ss:mm:hh as example*/
2241 if (tflags & (TIME_NOMINUTESORSECONDS))
2242 { if ((pos = strstr ( format, ":mm")))
2243 { memcpy ( pos, pos+3, strlen(format)-(pos-format)-2 );
2246 if (tflags & (TIME_NOSECONDS))
2247 { if ((pos = strstr ( format, ":ss")))
2248 { memcpy ( pos, pos+3, strlen(format)-(pos-format)-2 );
2252 for (inpos = 0;; inpos++) {
2253 /* TRACE(ole, "STATE inpos=%2d outpos=%2d count=%d inquote=%d type=%c buf,date = %c,%c\n", inpos, outpos, count, inquote, type, buf[inpos], date[outpos]); */
2254 if (inquote) {
2255 if (format[inpos] == '\'') {
2256 if (format[inpos+1] == '\'') {
2257 inpos += 1;
2258 date[outpos++] = '\'';
2259 } else {
2260 inquote = 0;
2261 continue; /* we did nothing to the output */
2263 } else if (format[inpos] == '\0') {
2264 date[outpos++] = '\0';
2265 if (outpos > datelen) Overflow = 1;
2266 break;
2267 } else {
2268 date[outpos++] = format[inpos];
2269 if (outpos > datelen) {
2270 Overflow = 1;
2271 date[outpos-1] = '\0'; /* this is the last place where
2272 it's safe to write */
2273 break;
2276 } else if ( (count && (format[inpos] != type))
2277 || count == 4
2278 || (count == 2 && strchr("ghHmst", type)) )
2280 if (type == 'd') {
2281 if (count == 4) {
2282 GetLocaleInfo32A(locale,
2283 LOCALE_SDAYNAME1
2284 + xtime->wDayOfWeek - 1,
2285 buf, sizeof(buf));
2286 } else if (count == 3) {
2287 GetLocaleInfo32A(locale,
2288 LOCALE_SABBREVDAYNAME1
2289 + xtime->wDayOfWeek - 1,
2290 buf, sizeof(buf));
2291 } else {
2292 sprintf(buf, dgfmt[count], xtime->wDay);
2294 } else if (type == 'M') {
2295 if (count == 3) {
2296 GetLocaleInfo32A(locale,
2297 LOCALE_SABBREVMONTHNAME1
2298 + xtime->wMonth - 1,
2299 buf, sizeof(buf));
2300 } else if (count == 4) {
2301 GetLocaleInfo32A(locale,
2302 LOCALE_SMONTHNAME1
2303 + xtime->wMonth - 1,
2304 buf, sizeof(buf));
2305 } else {
2306 sprintf(buf, dgfmt[count], xtime->wMonth);
2308 } else if (type == 'y') {
2309 if (count == 4) {
2310 sprintf(buf, "%d", xtime->wYear);
2311 } else if (count == 3) {
2312 strcpy(buf, "yyy");
2313 WARN(ole, "unknown format, c=%c, n=%d\n", type, count);
2314 } else {
2315 sprintf(buf, dgfmt[count], xtime->wYear % 100);
2317 } else if (type == 'g') {
2318 if (count == 2) {
2319 FIXME(ole, "LOCALE_ICALENDARTYPE unimp.\n");
2320 strcpy(buf, "AD");
2321 } else {
2322 strcpy(buf, "g");
2323 WARN(ole, "unknown format, c=%c, n=%d\n", type, count);
2325 } else if (type == 'h') {
2326 /* gives us hours 1:00 -- 12:00 */
2327 sprintf(buf, dgfmt[count], (xtime->wHour-1)%12 +1);
2328 } else if (type == 'H') {
2329 /* 24-hour time */
2330 sprintf(buf, dgfmt[count], xtime->wHour);
2331 } else if ( type == 'm') {
2332 sprintf(buf, dgfmt[count], xtime->wMinute);
2333 } else if ( type == 's') {
2334 sprintf(buf, dgfmt[count], xtime->wSecond);
2335 } else if (type == 't') {
2336 if (count == 1) {
2337 sprintf(buf, "%c", (xtime->wHour < 12) ? 'A' : 'P');
2338 } else if (count == 2) {
2339 /* sprintf(buf, "%s", (xtime->wHour < 12) ? "AM" : "PM"); */
2340 GetLocaleInfo32A(locale,
2341 (xtime->wHour<12)
2342 ? LOCALE_S1159 : LOCALE_S2359,
2343 buf, sizeof(buf));
2347 /* we need to check the next char in the format string
2348 again, no matter what happened */
2349 inpos--;
2351 /* add the contents of buf to the output */
2352 buflen = strlen(buf);
2353 if (outpos + buflen < datelen) {
2354 date[outpos] = '\0'; /* for strcat to hook onto */
2355 strcat(date, buf);
2356 outpos += buflen;
2357 } else {
2358 date[outpos] = '\0';
2359 strncat(date, buf, datelen - outpos);
2360 date[datelen - 1] = '\0';
2361 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2362 WARN(ole, "insufficient buffer\n");
2363 return 0;
2366 /* reset the variables we used to keep track of this item */
2367 count = 0;
2368 type = '\0';
2369 } else if (format[inpos] == '\0') {
2370 /* we can't check for this at the loop-head, because
2371 that breaks the printing of the last format-item */
2372 date[outpos] = '\0';
2373 break;
2374 } else if (count) {
2375 /* continuing a code for an item */
2376 count +=1;
2377 continue;
2378 } else if (strchr("hHmstyMdg", format[inpos])) {
2379 type = format[inpos];
2380 count = 1;
2381 continue;
2382 } else if (format[inpos] == '\'') {
2383 inquote = 1;
2384 continue;
2385 } else {
2386 date[outpos++] = format[inpos];
2388 /* now deal with a possible buffer overflow */
2389 if (outpos >= datelen) {
2390 date[datelen - 1] = '\0';
2391 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2392 return 0;
2396 if (Overflow) {
2397 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2400 /* finish it off with a string terminator */
2401 outpos++;
2402 /* sanity check */
2403 if (outpos > datelen-1) outpos = datelen-1;
2404 date[outpos] = '\0';
2406 TRACE(ole, "OLE_GetFormatA returns string '%s', len %d\n",
2407 date, outpos);
2408 return outpos;
2411 /**************************************************************
2412 * OLE_GetFormatW [internal]
2414 INT32 WINAPI OLE_GetFormatW(LCID locale, DWORD flags, DWORD tflags,
2415 LPSYSTEMTIME xtime,
2416 LPCWSTR format,
2417 LPWSTR output, INT32 outlen)
2419 INT32 inpos, outpos;
2420 int count, type=0, inquote;
2421 int Overflow; /* loop check */
2422 int usedate, usetime;
2423 WCHAR buf[40];
2424 int buflen=0;
2425 char abuf[40];
2426 WCHAR arg0[] = {0}, arg1[] = {'%','d',0};
2427 WCHAR arg2[] = {'%','0','2','d',0};
2428 WCHAR *argarr[] = {arg0, arg1, arg2};
2429 int datevars=0, timevars=0;
2431 /* make a debug report */
2432 lstrcpynWtoA(abuf, format, sizeof(format));
2433 TRACE(ole, "args: 0x%lx, 0x%lx, 0x%lx, time(d=%d,h=%d,m=%d,s=%d), fmt:\'%s\' (at %p), %p with max len %d\n",
2434 locale, flags, tflags,
2435 xtime->wDay, xtime->wHour, xtime->wMinute, xtime->wSecond,
2436 abuf, format, output, outlen);
2439 /* initialize state variables */
2440 inpos = outpos = 0;
2441 count = 0;
2442 inquote = Overflow = 0;
2443 /* this is really just a sanity check */
2444 output[0] = buf[0] = 0;
2445 abuf[0] = '\0';
2446 /* for compatibility with official Windows behavior */
2447 usedate = flags & DATE_DATEVARSONLY;
2448 usetime = flags & TIME_TIMEVARSONLY;
2450 /* this loop is the core of the function */
2451 for (inpos = 0; /* we have several break points */ ; inpos++) {
2452 if (inquote) {
2453 if (format[inpos] == (WCHAR) '\'') {
2454 if (format[inpos+1] == '\'') {
2455 inpos++;
2456 output[outpos++] = '\'';
2457 } else {
2458 inquote = 0;
2459 continue;
2461 } else if (format[inpos] == 0) {
2462 output[outpos++] = 0;
2463 if (outpos > outlen) Overflow = 1;
2464 break; /* normal exit (within a quote) */
2465 } else {
2466 output[outpos++] = format[inpos]; /* copy input */
2467 if (outpos > outlen) {
2468 Overflow = 1;
2469 output[outpos-1] = 0;
2470 break;
2473 } else if ( (count && (format[inpos] != type))
2474 || ( (count==4 && type =='y') ||
2475 (count==4 && type =='M') ||
2476 (count==4 && type =='d') ||
2477 (count==2 && type =='g') ||
2478 (count==2 && type =='h') ||
2479 (count==2 && type =='H') ||
2480 (count==2 && type =='m') ||
2481 (count==2 && type =='s') ||
2482 (count==2 && type =='t') ) ) {
2483 if (type == 'd') {
2484 if (count == 3) {
2485 GetLocaleInfo32W(locale,
2486 LOCALE_SDAYNAME1 + xtime->wDayOfWeek -1,
2487 buf, sizeof(buf)/sizeof(WCHAR) );
2488 } else if (count == 3) {
2489 GetLocaleInfo32W(locale,
2490 LOCALE_SABBREVDAYNAME1 +
2491 xtime->wDayOfWeek -1,
2492 buf, sizeof(buf)/sizeof(WCHAR) );
2493 } else {
2494 wsnprintf32W(buf, 5, argarr[count], xtime->wDay );
2496 } else if (type == 'M') {
2497 if (count == 4) {
2498 GetLocaleInfo32W(locale, LOCALE_SMONTHNAME1 +
2499 xtime->wMonth -1, buf,
2500 sizeof(buf)/sizeof(WCHAR) );
2501 } else if (count == 3) {
2502 GetLocaleInfo32W(locale, LOCALE_SABBREVMONTHNAME1 +
2503 xtime->wMonth -1, buf,
2504 sizeof(buf)/sizeof(WCHAR) );
2505 } else {
2506 wsnprintf32W(buf, 5, argarr[count], xtime->wMonth);
2508 } else if (type == 'y') {
2509 if (count == 4) {
2510 wsnprintf32W(buf, 6, argarr[1] /* "%d" */,
2511 xtime->wYear);
2512 } else if (count == 3) {
2513 lstrcpynAtoW(buf, "yyy", 5);
2514 } else {
2515 wsnprintf32W(buf, 6, argarr[count],
2516 xtime->wYear % 100);
2518 } else if (type == 'g') {
2519 if (count == 2) {
2520 FIXME(ole, "LOCALE_ICALENDARTYPE unimplemented\n");
2521 lstrcpynAtoW(buf, "AD", 5);
2522 } else {
2523 /* Win API sez we copy it verbatim */
2524 lstrcpynAtoW(buf, "g", 5);
2526 } else if (type == 'h') {
2527 /* hours 1:00-12:00 --- is this right? */
2528 wsnprintf32W(buf, 5, argarr[count],
2529 (xtime->wHour-1)%12 +1);
2530 } else if (type == 'H') {
2531 wsnprintf32W(buf, 5, argarr[count],
2532 xtime->wHour);
2533 } else if (type == 'm' ) {
2534 wsnprintf32W(buf, 5, argarr[count],
2535 xtime->wMinute);
2536 } else if (type == 's' ) {
2537 wsnprintf32W(buf, 5, argarr[count],
2538 xtime->wSecond);
2539 } else if (type == 't') {
2540 GetLocaleInfo32W(locale, (xtime->wHour < 12) ?
2541 LOCALE_S1159 : LOCALE_S2359,
2542 buf, sizeof(buf) );
2543 if (count == 1) {
2544 buf[1] = 0;
2548 /* no matter what happened, we need to check this next
2549 character the next time we loop through */
2550 inpos--;
2552 /* cat buf onto the output */
2553 outlen = lstrlen32W(buf);
2554 if (outpos + buflen < outlen) {
2555 output[outpos] = 0; /* a "hook" for strcat */
2556 lstrcat32W(output, buf);
2557 outpos += buflen;
2558 } else {
2559 output[outpos] = 0;
2560 lstrcatn32W(output, buf, outlen - outpos);
2561 output[outlen - 1] = 0;
2562 Overflow = 1;
2563 break; /* Abnormal exit */
2566 /* reset the variables we used this time */
2567 count = 0;
2568 type = '\0';
2569 } else if (format[inpos] == 0) {
2570 /* we can't check for this at the beginning, because that
2571 would keep us from printing a format spec that ended the
2572 string */
2573 output[outpos] = 0;
2574 break; /* NORMAL EXIT */
2575 } else if (count) {
2576 /* how we keep track of the middle of a format spec */
2577 count++;
2578 continue;
2579 } else if ( (datevars && (format[inpos]=='d' ||
2580 format[inpos]=='M' ||
2581 format[inpos]=='y' ||
2582 format[inpos]=='g') ) ||
2583 (timevars && (format[inpos]=='H' ||
2584 format[inpos]=='h' ||
2585 format[inpos]=='m' ||
2586 format[inpos]=='s' ||
2587 format[inpos]=='t') ) ) {
2588 type = format[inpos];
2589 count = 1;
2590 continue;
2591 } else if (format[inpos] == '\'') {
2592 inquote = 1;
2593 continue;
2594 } else {
2595 /* unquoted literals */
2596 output[outpos++] = format[inpos];
2600 if (Overflow) {
2601 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2602 WARN(ole, " buffer overflow\n");
2605 /* final string terminator and sanity check */
2606 outpos++;
2607 if (outpos > outlen-1) outpos = outlen-1;
2608 output[outpos] = '0';
2610 lstrcpynWtoA(abuf, output, sizeof(abuf) );
2611 TRACE(ole, " returning string \'%s\'\n", abuf);
2613 return (!Overflow) ? outlen : 0;
2618 /*****************************************************************
2619 * GetDateFormat32A() [KERNEL32.310] Makes an ASCII string of the date
2621 * This function uses format to format the date, or, if format
2622 * is NULL, uses the default for the locale. format is a string
2623 * of literal fields and characters as follows:
2625 * - d single-digit (no leading zero) day (of month)
2626 * - dd two-digit day (of month)
2627 * - ddd short day-of-week name
2628 * - dddd long day-of-week name
2629 * - M single-digit month
2630 * - MM two-digit month
2631 * - MMM short month name
2632 * - MMMM full month name
2633 * - y two-digit year, no leading 0
2634 * - yy two-digit year
2635 * - yyyy four-digit year
2636 * - gg era string
2640 INT32 WINAPI GetDateFormat32A(LCID locale,DWORD flags,
2641 LPSYSTEMTIME xtime,
2642 LPCSTR format, LPSTR date,INT32 datelen)
2645 char format_buf[40];
2646 LPCSTR thisformat;
2647 SYSTEMTIME t;
2648 LPSYSTEMTIME thistime;
2649 LCID thislocale;
2651 INT32 ret;
2653 TRACE(ole,"(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",
2654 locale,flags,xtime,format,date,datelen);
2656 if (!locale) {
2657 locale = LOCALE_SYSTEM_DEFAULT;
2660 if (locale == LOCALE_SYSTEM_DEFAULT) {
2661 thislocale = GetSystemDefaultLCID();
2662 } else if (locale == LOCALE_USER_DEFAULT) {
2663 thislocale = GetUserDefaultLCID();
2664 } else {
2665 thislocale = locale;
2668 if (xtime == NULL) {
2669 GetSystemTime(&t);
2670 thistime = &t;
2671 } else {
2672 thistime = xtime;
2675 if (format == NULL) {
2676 GetLocaleInfo32A(thislocale, ((flags&DATE_LONGDATE)
2677 ? LOCALE_SLONGDATE
2678 : LOCALE_SSHORTDATE),
2679 format_buf, sizeof(format_buf));
2680 thisformat = format_buf;
2681 } else {
2682 thisformat = format;
2686 ret = OLE_GetFormatA(thislocale, flags, 0, thistime, thisformat,
2687 date, datelen);
2690 TRACE(ole,
2691 "GetDateFormat32A() returning %d, with data=%s\n",
2692 ret, date);
2693 return ret;
2696 /* ****************************************************************
2697 * GetDateFormat32W() [KERNEL32.311] Makes a Unicode string of the date
2699 * Acts the same as GetDateFormat32A(), except that it's Unicode.
2700 * Accepts & returns sizes as counts of Unicode characters.
2703 INT32 WINAPI GetDateFormat32W(LCID locale,DWORD flags,
2704 LPSYSTEMTIME xtime,
2705 LPCWSTR format,
2706 LPWSTR date, INT32 datelen)
2708 short datearr[] = {'1','9','9','4','-','1','-','1',0};
2710 FIXME(ole, "STUB (should call OLE_GetFormatW)\n");
2711 lstrcpyn32W(date, datearr, datelen);
2712 return ( datelen < 9) ? datelen : 9;
2717 /**************************************************************************
2718 * EnumDateFormats32A (KERNEL32.198)
2720 BOOL32 WINAPI EnumDateFormats32A(
2721 DATEFMT_ENUMPROC32A lpDateFmtEnumProc, LCID Locale, DWORD dwFlags)
2723 FIXME(ole, "Only US English supported\n");
2725 if(!lpDateFmtEnumProc)
2727 SetLastError(ERROR_INVALID_PARAMETER);
2728 return FALSE;
2731 switch(dwFlags)
2733 case DATE_SHORTDATE:
2734 if(!(*lpDateFmtEnumProc)("M/d/yy")) return TRUE;
2735 if(!(*lpDateFmtEnumProc)("M/d/yyyy")) return TRUE;
2736 if(!(*lpDateFmtEnumProc)("MM/dd/yy")) return TRUE;
2737 if(!(*lpDateFmtEnumProc)("MM/dd/yyyy")) return TRUE;
2738 if(!(*lpDateFmtEnumProc)("yy/MM/dd")) return TRUE;
2739 if(!(*lpDateFmtEnumProc)("dd-MMM-yy")) return TRUE;
2740 return TRUE;
2741 case DATE_LONGDATE:
2742 if(!(*lpDateFmtEnumProc)("dddd, MMMM dd, yyyy")) return TRUE;
2743 if(!(*lpDateFmtEnumProc)("MMMM dd, yyyy")) return TRUE;
2744 if(!(*lpDateFmtEnumProc)("dddd, dd MMMM, yyyy")) return TRUE;
2745 if(!(*lpDateFmtEnumProc)("dd MMMM, yyyy")) return TRUE;
2746 return TRUE;
2747 default:
2748 FIXME(ole, "Unknown date format (%ld)\n", dwFlags);
2749 SetLastError(ERROR_INVALID_PARAMETER);
2750 return FALSE;
2754 /**************************************************************************
2755 * EnumDateFormats32W (KERNEL32.199)
2757 BOOL32 WINAPI EnumDateFormats32W(
2758 DATEFMT_ENUMPROC32W lpDateFmtEnumProc, LCID Locale, DWORD dwFlags)
2760 FIXME(ole, "(%p, %ld, %ld): stub\n", lpDateFmtEnumProc, Locale, dwFlags);
2761 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
2762 return FALSE;
2765 /**************************************************************************
2766 * EnumTimeFormats32A (KERNEL32.210)
2768 BOOL32 WINAPI EnumTimeFormats32A(
2769 TIMEFMT_ENUMPROC32A lpTimeFmtEnumProc, LCID Locale, DWORD dwFlags)
2771 FIXME(ole, "Only US English supported\n");
2773 if(!lpTimeFmtEnumProc)
2775 SetLastError(ERROR_INVALID_PARAMETER);
2776 return FALSE;
2779 if(dwFlags)
2781 FIXME(ole, "Unknown time format (%ld)\n", dwFlags);
2784 if(!(*lpTimeFmtEnumProc)("h:mm:ss tt")) return TRUE;
2785 if(!(*lpTimeFmtEnumProc)("hh:mm:ss tt")) return TRUE;
2786 if(!(*lpTimeFmtEnumProc)("H:mm:ss")) return TRUE;
2787 if(!(*lpTimeFmtEnumProc)("HH:mm:ss")) return TRUE;
2789 return TRUE;
2792 /**************************************************************************
2793 * EnumTimeFormats32W (KERNEL32.211)
2795 BOOL32 WINAPI EnumTimeFormats32W(
2796 TIMEFMT_ENUMPROC32W lpTimeFmtEnumProc, LCID Locale, DWORD dwFlags)
2798 FIXME(ole, "(%p,%ld,%ld): stub", lpTimeFmtEnumProc, Locale, dwFlags);
2799 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
2800 return FALSE;
2803 /**************************************************************************
2804 * GetNumberFormat32A (KERNEL32.355)
2805 * NOTE: type of lpFormat should be CONST NUMBERFORMAT
2807 INT32 WINAPI GetNumberFormat32A(LCID locale, DWORD dwflags,
2808 LPCSTR lpvalue, char *lpFormat,
2809 LPSTR lpNumberStr, int cchNumber)
2811 int n;
2813 FIXME(file,"%s: stub, no reformating done\n",lpvalue);
2815 n = strlen(lpvalue);
2816 if (cchNumber) {
2817 strncpy(lpNumberStr,lpvalue,cchNumber);
2818 if (cchNumber <= n) {
2819 lpNumberStr[cchNumber-1] = 0;
2820 n = cchNumber-1;
2823 return n;
2828 /*****************************************************************
2830 * GetTimeFormat32A() [KERNEL32.422] Makes an ASCII string of the time
2832 * Formats date according to format, or locale default if format is
2833 * NULL. The format consists of literal characters and fields as follows:
2835 * h hours with no leading zero (12-hour)
2836 * hh hours with full two digits
2837 * H hours with no leading zero (24-hour)
2838 * HH hours with full two digits
2839 * m minutes with no leading zero
2840 * mm minutes with full two digits
2841 * s seconds with no leading zero
2842 * ss seconds with full two digits
2843 * t time marker (A or P)
2844 * tt time marker (AM, PM)
2848 INT32 WINAPI
2849 GetTimeFormat32A(LCID locale, /* in */
2850 DWORD flags, /* in */
2851 LPSYSTEMTIME xtime, /* in */
2852 LPCSTR format, /* in */
2853 LPSTR timestr, /* out */
2854 INT32 timelen /* in */)
2855 { char format_buf[40];
2856 LPCSTR thisformat;
2857 SYSTEMTIME t;
2858 LPSYSTEMTIME thistime;
2859 LCID thislocale=0;
2860 DWORD thisflags=LOCALE_STIMEFORMAT; /* standart timeformat */;
2862 TRACE(ole,"GetTimeFormat(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",locale,flags,xtime,format,timestr,timelen);
2864 if (!locale)
2865 { locale = LOCALE_SYSTEM_DEFAULT;
2868 if (locale == LOCALE_SYSTEM_DEFAULT)
2869 { thislocale = GetSystemDefaultLCID();
2871 else if (locale == LOCALE_USER_DEFAULT)
2872 { thislocale = GetUserDefaultLCID();
2874 else
2875 { thislocale = locale;
2878 if ( flags & (TIME_NOTIMEMARKER | TIME_FORCE24HOURFORMAT ))
2879 { FIXME(ole,"TIME_NOTIMEMARKER or TIME_FORCE24HOURFORMAT not implemented\n");
2881 flags &= (TIME_NOSECONDS | TIME_NOMINUTESORSECONDS); /* mask for OLE_GetFormatA*/
2883 if (format == NULL)
2884 { if (flags & LOCALE_NOUSEROVERRIDE) /*use system default*/
2885 { thislocale = GetSystemDefaultLCID();
2887 GetLocaleInfo32A(thislocale, thisflags, format_buf, sizeof(format_buf));
2888 thisformat = format_buf;
2890 else
2891 { thisformat = format;
2894 if (xtime == NULL) /* NULL means use the current local time*/
2895 { GetSystemTime(&t);
2896 thistime = &t;
2898 else
2899 { thistime = xtime;
2901 return OLE_GetFormatA(thislocale, thisflags, flags, thistime, thisformat, timestr, timelen);
2905 /* ****************************************************************
2906 * GetTimeFormat32W() [KERNEL32.423] Makes a Unicode string of the time
2911 INT32 WINAPI
2912 GetTimeFormat32W(LCID locale,DWORD flags,
2913 LPSYSTEMTIME xtime,
2914 LPCWSTR format,
2915 LPWSTR timestr,INT32 timelen)
2917 char debugbuf[40];
2918 WCHAR buf[20];
2919 LPCWSTR realformat=0;
2920 SYSTEMTIME t;
2921 LPSYSTEMTIME realtime;
2922 WCHAR * fmt_buf = NULL;
2923 int fmt_buf_size = 0; /* units of WCHARs */
2924 INT32 retval;
2926 lstrcpynWtoA(debugbuf, format, (sizeof(buf))/2);
2927 TRACE(ole, "GetTimeFormatW len %d flags 0x%lX format >%s<\n",
2928 timelen, flags, debugbuf);
2930 /* Enforce the Windows behavior */
2931 flags |= ~LOCALE_TIMEDATEBOTH;
2932 flags |= TIME_TIMEVARSONLY;
2934 /* take care of the format or locale not being given */
2935 if (format) {
2936 realformat = format;
2937 } else if (locale) {
2938 /* allocate memory */
2939 retval = ERROR_INSUFFICIENT_BUFFER;
2940 fmt_buf = malloc((fmt_buf_size+=7) * sizeof(WCHAR));
2941 if (!fmt_buf)
2942 goto out_nomem;
2944 while(!GetLocaleInfo32W(locale, LOCALE_STIMEFORMAT,
2945 fmt_buf, fmt_buf_size)) {
2946 retval = ERROR_OUTOFMEMORY;
2947 fmt_buf = realloc(fmt_buf,
2948 (fmt_buf_size += 10) * sizeof(WCHAR));
2949 if (!fmt_buf)
2950 goto out_nomem;
2952 realformat = fmt_buf;
2953 } else {
2954 FIXME(ole, "caller gave no locale, no format; what should we do?\n");
2955 SetLastError(ERROR_BAD_FORMAT);
2957 if (!locale)
2958 locale = GetSystemDefaultLCID();
2960 realtime = xtime;
2961 if (!realtime) {
2962 realtime = &t;
2963 GetSystemTime(realtime);
2966 retval = OLE_GetFormatW(locale, flags, 0, realtime, realformat, timestr, timelen);
2967 if (fmt_buf)
2968 free(fmt_buf);
2969 return retval;
2971 out_nomem:
2972 SetLastError(retval);
2973 WARN(ole, "could not allocate %d chars of memory\n", fmt_buf_size);
2974 return 0;