4 * Copyright 1995 Martin von Loewis
5 * Copyright 1998 David Lee Lambert
13 #define _KERNEL32_INCLUDE_LANG_
14 #include <kernel32/winnls.h>
17 //#include "options.h"
20 //#include "winerror.h"
31 typedef BOOL32 (*LOCALE_ENUMPROC32W)(WCHAR*);
32 typedef BOOL16 (*LOCALE_ENUMPROC32A)(CHAR*);
34 typedef BOOL32 (*DATEFMT_ENUMPROC32W)(WCHAR*);
35 typedef BOOL16 (*DATEFMT_ENUMPROC32A)(CHAR*);
37 typedef BOOL32 (*TIMEFMT_ENUMPROC32W)(WCHAR*);
38 typedef BOOL16 (*TIMEFMT_ENUMPROC32A)(CHAR*);
40 #define NUMBERFMT32W int
41 #define NUMBERFMT32A int
43 BOOL32 WINAPI GetStringTypeEx32A(LCID locale,DWORD dwInfoType,LPCSTR src,
44 ULONG cchSrc,LPWORD chartype);
45 BOOL32 WINAPI GetStringTypeEx32W(LCID locale,DWORD dwInfoType,LPCWSTR src,
46 ULONG cchSrc,LPWORD chartype);
49 struct NLS_langlocale {
51 struct NLS_localevar {
57 #define LANG_BEGIN(l,s) { MAKELANGID(l,s), {
59 #define LOCVAL(type,value) {type,value},
63 static const struct NLS_langlocale langlocales[] = {
64 /* add languages in numerical order of main language (last two digits)
65 * it is much easier to find the missing holes that way */
67 LANG_BEGIN (LANG_CATALAN, SUBLANG_DEFAULT) /*0x0403*/
68 #include "nls/cat.nls"
71 LANG_BEGIN (LANG_CZECH, SUBLANG_DEFAULT) /*0x0405*/
72 #include "nls/cze.nls"
75 LANG_BEGIN (LANG_DANISH, SUBLANG_DEFAULT) /*0x0406*/
76 #include "nls/dan.nls"
79 LANG_BEGIN (LANG_GERMAN, SUBLANG_GERMAN) /*0x0407*/
80 #include "nls/deu.nls"
82 LANG_BEGIN (LANG_GERMAN, SUBLANG_GERMAN_SWISS) /*0x0807*/
83 #include "nls/des.nls"
85 LANG_BEGIN (LANG_GERMAN, SUBLANG_GERMAN_AUSTRIAN) /*0x0C07*/
86 #include "nls/dea.nls"
88 LANG_BEGIN (LANG_GERMAN, SUBLANG_GERMAN_LUXEMBOURG) /*0x1007*/
89 #include "nls/del.nls"
91 LANG_BEGIN (LANG_GERMAN, SUBLANG_GERMAN_LIECHTENSTEIN) /*0x1407*/
92 #include "nls/dec.nls"
95 LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_US) /*0x0409*/
96 #include "nls/enu.nls"
98 LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_UK) /*0x0809*/
99 #include "nls/eng.nls"
101 LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_AUS) /*0x0C09*/
102 #include "nls/ena.nls"
104 LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_CAN) /*0x1009*/
105 #include "nls/enc.nls"
107 LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_NZ) /*0x1409*/
108 #include "nls/enz.nls"
110 LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_EIRE) /*0x1809*/
111 #include "nls/irl.nls"
113 LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_SAFRICA) /*0x1C09*/
114 #include "nls/ens.nls"
116 LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_JAMAICA) /*0x2009*/
117 #include "nls/enj.nls"
119 LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_CARRIBEAN) /*0x2409*/
120 #include "nls/enb.nls"
122 LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_BELIZE) /*0x2809*/
123 #include "nls/enl.nls"
125 LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_TRINIDAD) /*0x2C09*/
126 #include "nls/ent.nls"
129 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH) /*0x040a*/
130 #include "nls/esp.nls"
132 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_MEXICAN) /*0x080a*/
133 #include "nls/esm.nls"
135 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_MODERN) /*0x0C0a*/
136 #include "nls/esn.nls"
138 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_GUATEMALA) /*0x100a*/
139 #include "nls/esg.nls"
141 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_COSTARICA) /*0x140a*/
142 #include "nls/esc.nls"
144 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_PANAMA) /*0x180a*/
145 #include "nls/esa.nls"
147 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_DOMINICAN) /*0x1C0A*/
148 #include "nls/esd.nls"
150 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_VENEZUELA) /*0x200a*/
151 #include "nls/esv.nls"
153 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_COLOMBIA) /*0x240a*/
154 #include "nls/eso.nls"
156 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_PERU) /*0x280a*/
157 #include "nls/esr.nls"
159 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_ARGENTINA) /*0x2c0a*/
160 #include "nls/ess.nls"
162 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_ECUADOR) /*0x300a*/
163 #include "nls/esf.nls"
165 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_CHILE) /*0x340a*/
166 #include "nls/esl.nls"
168 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_URUGUAY) /*0x380a*/
169 #include "nls/esy.nls"
171 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_PARAGUAY) /*0x3c0a*/
172 #include "nls/esz.nls"
174 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_BOLIVIA) /*0x400a*/
175 #include "nls/esb.nls"
177 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_EL_SALVADOR) /*0x440a*/
178 #include "nls/ese.nls"
180 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_HONDURAS) /*0x480a*/
181 #include "nls/esh.nls"
183 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_NICARAGUA) /*0x4c0a*/
184 #include "nls/esi.nls"
186 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_PUERTO_RICO) /*0x500a*/
187 #include "nls/esu.nls"
190 LANG_BEGIN (LANG_FINNISH, SUBLANG_DEFAULT) /*0x040B*/
191 #include "nls/fin.nls"
194 LANG_BEGIN (LANG_FRENCH, SUBLANG_FRENCH) /*0x040C*/
195 #include "nls/fra.nls"
197 LANG_BEGIN (LANG_FRENCH, SUBLANG_FRENCH_BELGIAN) /*0x080C*/
198 #include "nls/frb.nls"
200 LANG_BEGIN (LANG_FRENCH, SUBLANG_FRENCH_CANADIAN) /*0x0C0C*/
201 #include "nls/frc.nls"
203 LANG_BEGIN (LANG_FRENCH, SUBLANG_FRENCH_SWISS) /*0x100C*/
204 #include "nls/frs.nls"
206 LANG_BEGIN (LANG_FRENCH, SUBLANG_FRENCH_LUXEMBOURG) /*0x140C*/
207 #include "nls/frl.nls"
210 LANG_BEGIN (LANG_HUNGARIAN, SUBLANG_DEFAULT) /*0x040e*/
211 #include "nls/hun.nls"
214 LANG_BEGIN (LANG_ITALIAN, SUBLANG_ITALIAN) /*0x0410*/
215 #include "nls/ita.nls"
217 LANG_BEGIN (LANG_ITALIAN, SUBLANG_ITALIAN_SWISS) /*0x0810*/
218 #include "nls/its.nls"
221 LANG_BEGIN (LANG_KOREAN, SUBLANG_KOREAN) /*0x0412*/
222 #include "nls/kor.nls"
225 LANG_BEGIN (LANG_NORWEGIAN, SUBLANG_NORWEGIAN_BOKMAL) /*0x0414*/
226 #include "nls/nor.nls"
228 LANG_BEGIN (LANG_NORWEGIAN, SUBLANG_NORWEGIAN_NYNORSK) /*0x0814*/
229 #include "nls/non.nls"
232 LANG_BEGIN (LANG_POLISH, SUBLANG_DEFAULT) /*0x0415*/
233 #include "nls/plk.nls"
236 LANG_BEGIN (LANG_PORTUGUESE ,SUBLANG_PORTUGUESE_BRAZILIAN) /*0x0416*/
237 #include "nls/ptb.nls"
239 LANG_BEGIN (LANG_PORTUGUESE ,SUBLANG_PORTUGUESE) /*0x0816*/
240 #include "nls/ptg.nls"
243 LANG_BEGIN (LANG_SLOVAK, SUBLANG_DEFAULT) /*0x041b*/
244 #include "nls/sky.nls"
247 LANG_BEGIN (LANG_SWEDISH, SUBLANG_SWEDISH) /*0x041d*/
248 #include "nls/sve.nls"
250 LANG_BEGIN (LANG_SWEDISH, SUBLANG_SWEDISH_FINLAND) /*0x081d*/
251 #include "nls/svf.nls"
254 LANG_BEGIN (LANG_THAI, SUBLANG_DEFAULT) /*0x41e*/
255 #include "nls/tha.nls"
258 LANG_BEGIN (LANG_ESPERANTO, SUBLANG_DEFAULT) /*0x048f*/
259 #include "nls/esperanto.nls"
264 /* Locale name to id map. used by EnumSystemLocales, GetLocalInfoA
265 * MUST contain all #defines from winnls.h
266 * last entry has NULL name, 0 id.
268 #define LOCALE_ENTRY(x) {#x,LOCALE_##x}
269 static struct tagLOCALE_NAME2ID {
272 } locale_name2id[]= {
273 LOCALE_ENTRY(ILANGUAGE),
274 LOCALE_ENTRY(SLANGUAGE),
275 LOCALE_ENTRY(SENGLANGUAGE),
276 LOCALE_ENTRY(SABBREVLANGNAME),
277 LOCALE_ENTRY(SNATIVELANGNAME),
278 LOCALE_ENTRY(ICOUNTRY),
279 LOCALE_ENTRY(SCOUNTRY),
280 LOCALE_ENTRY(SENGCOUNTRY),
281 LOCALE_ENTRY(SABBREVCTRYNAME),
282 LOCALE_ENTRY(SNATIVECTRYNAME),
283 LOCALE_ENTRY(IDEFAULTLANGUAGE),
284 LOCALE_ENTRY(IDEFAULTCOUNTRY),
285 LOCALE_ENTRY(IDEFAULTCODEPAGE),
286 LOCALE_ENTRY(IDEFAULTANSICODEPAGE),
287 LOCALE_ENTRY(IDEFAULTMACCODEPAGE),
289 LOCALE_ENTRY(IMEASURE),
290 LOCALE_ENTRY(SDECIMAL),
291 LOCALE_ENTRY(STHOUSAND),
292 LOCALE_ENTRY(SGROUPING),
293 LOCALE_ENTRY(IDIGITS),
294 LOCALE_ENTRY(ILZERO),
295 LOCALE_ENTRY(INEGNUMBER),
296 LOCALE_ENTRY(SNATIVEDIGITS),
297 LOCALE_ENTRY(SCURRENCY),
298 LOCALE_ENTRY(SINTLSYMBOL),
299 LOCALE_ENTRY(SMONDECIMALSEP),
300 LOCALE_ENTRY(SMONTHOUSANDSEP),
301 LOCALE_ENTRY(SMONGROUPING),
302 LOCALE_ENTRY(ICURRDIGITS),
303 LOCALE_ENTRY(IINTLCURRDIGITS),
304 LOCALE_ENTRY(ICURRENCY),
305 LOCALE_ENTRY(INEGCURR),
308 LOCALE_ENTRY(SSHORTDATE),
309 LOCALE_ENTRY(SLONGDATE),
310 LOCALE_ENTRY(STIMEFORMAT),
312 LOCALE_ENTRY(ILDATE),
314 LOCALE_ENTRY(ITIMEMARKPOSN),
315 LOCALE_ENTRY(ICENTURY),
316 LOCALE_ENTRY(ITLZERO),
317 LOCALE_ENTRY(IDAYLZERO),
318 LOCALE_ENTRY(IMONLZERO),
321 LOCALE_ENTRY(ICALENDARTYPE),
322 LOCALE_ENTRY(IOPTIONALCALENDAR),
323 LOCALE_ENTRY(IFIRSTDAYOFWEEK),
324 LOCALE_ENTRY(IFIRSTWEEKOFYEAR),
325 LOCALE_ENTRY(SDAYNAME1),
326 LOCALE_ENTRY(SDAYNAME2),
327 LOCALE_ENTRY(SDAYNAME3),
328 LOCALE_ENTRY(SDAYNAME4),
329 LOCALE_ENTRY(SDAYNAME5),
330 LOCALE_ENTRY(SDAYNAME6),
331 LOCALE_ENTRY(SDAYNAME7),
332 LOCALE_ENTRY(SABBREVDAYNAME1),
333 LOCALE_ENTRY(SABBREVDAYNAME2),
334 LOCALE_ENTRY(SABBREVDAYNAME3),
335 LOCALE_ENTRY(SABBREVDAYNAME4),
336 LOCALE_ENTRY(SABBREVDAYNAME5),
337 LOCALE_ENTRY(SABBREVDAYNAME6),
338 LOCALE_ENTRY(SABBREVDAYNAME7),
339 LOCALE_ENTRY(SMONTHNAME1),
340 LOCALE_ENTRY(SMONTHNAME2),
341 LOCALE_ENTRY(SMONTHNAME3),
342 LOCALE_ENTRY(SMONTHNAME4),
343 LOCALE_ENTRY(SMONTHNAME5),
344 LOCALE_ENTRY(SMONTHNAME6),
345 LOCALE_ENTRY(SMONTHNAME7),
346 LOCALE_ENTRY(SMONTHNAME8),
347 LOCALE_ENTRY(SMONTHNAME9),
348 LOCALE_ENTRY(SMONTHNAME10),
349 LOCALE_ENTRY(SMONTHNAME11),
350 LOCALE_ENTRY(SMONTHNAME12),
351 LOCALE_ENTRY(SMONTHNAME13),
352 LOCALE_ENTRY(SABBREVMONTHNAME1),
353 LOCALE_ENTRY(SABBREVMONTHNAME2),
354 LOCALE_ENTRY(SABBREVMONTHNAME3),
355 LOCALE_ENTRY(SABBREVMONTHNAME4),
356 LOCALE_ENTRY(SABBREVMONTHNAME5),
357 LOCALE_ENTRY(SABBREVMONTHNAME6),
358 LOCALE_ENTRY(SABBREVMONTHNAME7),
359 LOCALE_ENTRY(SABBREVMONTHNAME8),
360 LOCALE_ENTRY(SABBREVMONTHNAME9),
361 LOCALE_ENTRY(SABBREVMONTHNAME10),
362 LOCALE_ENTRY(SABBREVMONTHNAME11),
363 LOCALE_ENTRY(SABBREVMONTHNAME12),
364 LOCALE_ENTRY(SABBREVMONTHNAME13),
365 LOCALE_ENTRY(SPOSITIVESIGN),
366 LOCALE_ENTRY(SNEGATIVESIGN),
367 LOCALE_ENTRY(IPOSSIGNPOSN),
368 LOCALE_ENTRY(INEGSIGNPOSN),
369 LOCALE_ENTRY(IPOSSYMPRECEDES),
370 LOCALE_ENTRY(IPOSSEPBYSPACE),
371 LOCALE_ENTRY(INEGSYMPRECEDES),
372 LOCALE_ENTRY(INEGSEPBYSPACE),
373 LOCALE_ENTRY(FONTSIGNATURE),
374 LOCALE_ENTRY(SISO639LANGNAME),
375 LOCALE_ENTRY(SISO3166CTRYNAME),
379 const struct map_lcid2str {
381 const char *langname;
382 } static languages[]={
383 {0x0401,"Arabic (Saudi Arabia)"},
384 {0x0801,"Arabic (Iraq)"},
385 {0x0c01,"Arabic (Egypt)"},
386 {0x1001,"Arabic (Libya)"},
387 {0x1401,"Arabic (Algeria)"},
388 {0x1801,"Arabic (Morocco)"},
389 {0x1c01,"Arabic (Tunisia)"},
390 {0x2001,"Arabic (Oman)"},
391 {0x2401,"Arabic (Yemen)"},
392 {0x2801,"Arabic (Syria)"},
393 {0x2c01,"Arabic (Jordan)"},
394 {0x3001,"Arabic (Lebanon)"},
395 {0x3401,"Arabic (Kuwait)"},
396 {0x3801,"Arabic (United Arab Emirates)"},
397 {0x3c01,"Arabic (Bahrain)"},
398 {0x4001,"Arabic (Qatar)"},
399 {0x0402,"Bulgarian"},
401 {0x0404,"Chinese (Taiwan)"},
402 {0x0804,"Chinese (People's Republic of China)"},
403 {0x0c04,"Chinese (Hong Kong)"},
404 {0x1004,"Chinese (Singapore)"},
405 {0x1404,"Chinese (Macau)"},
408 {0x0407,"German (Germany)"},
409 {0x0807,"German (Switzerland)"},
410 {0x0c07,"German (Austria)"},
411 {0x1007,"German (Luxembourg)"},
412 {0x1407,"German (Liechtenstein)"},
414 {0x0409,"English (United States)"},
415 {0x0809,"English (United Kingdom)"},
416 {0x0c09,"English (Australia)"},
417 {0x1009,"English (Canada)"},
418 {0x1409,"English (New Zealand)"},
419 {0x1809,"English (Ireland)"},
420 {0x1c09,"English (South Africa)"},
421 {0x2009,"English (Jamaica)"},
422 {0x2409,"English (Caribbean)"},
423 {0x2809,"English (Belize)"},
424 {0x2c09,"English (Trinidad)"},
425 {0x3009,"English (Zimbabwe)"},
426 {0x3409,"English (Philippines)"},
427 {0x040a,"Spanish (Spain, traditional sorting)"},
428 {0x080a,"Spanish (Mexico)"},
429 {0x0c0a,"Spanish (Spain, international sorting)"},
430 {0x100a,"Spanish (Guatemala)"},
431 {0x140a,"Spanish (Costa Rica)"},
432 {0x180a,"Spanish (Panama)"},
433 {0x1c0a,"Spanish (Dominican Republic)"},
434 {0x200a,"Spanish (Venezuela)"},
435 {0x240a,"Spanish (Colombia)"},
436 {0x280a,"Spanish (Peru)"},
437 {0x2c0a,"Spanish (Argentina)"},
438 {0x300a,"Spanish (Ecuador)"},
439 {0x340a,"Spanish (Chile)"},
440 {0x380a,"Spanish (Uruguay)"},
441 {0x3c0a,"Spanish (Paraguay)"},
442 {0x400a,"Spanish (Bolivia)"},
443 {0x440a,"Spanish (El Salvador)"},
444 {0x480a,"Spanish (Honduras)"},
445 {0x4c0a,"Spanish (Nicaragua)"},
446 {0x500a,"Spanish (Puerto Rico)"},
448 {0x040c,"French (France)"},
449 {0x080c,"French (Belgium)"},
450 {0x0c0c,"French (Canada)"},
451 {0x100c,"French (Switzerland)"},
452 {0x140c,"French (Luxembourg)"},
453 {0x180c,"French (Monaco)"},
455 {0x040e,"Hungarian"},
456 {0x040f,"Icelandic"},
457 {0x0410,"Italian (Italy)"},
458 {0x0810,"Italian (Switzerland)"},
460 {0x0412,"Korean (Wansung)"},
461 {0x0812,"Korean (Johab)"},
462 {0x0413,"Dutch (Netherlands)"},
463 {0x0813,"Dutch (Belgium)"},
464 {0x0414,"Norwegian (Bokmal)"},
465 {0x0814,"Norwegian (Nynorsk)"},
467 {0x0416,"Portuguese (Brazil)"},
468 {0x0816,"Portuguese (Portugal)"},
469 {0x0417,"Rhaeto Romanic"},
471 {0x0818,"Moldavian"},
472 {0x0419,"Russian (Russia)"},
473 {0x0819,"Russian (Moldavia)"},
475 {0x081a,"Serbian (latin)"},
476 {0x0c1a,"Serbian (cyrillic)"},
479 {0x041d,"Swedish (Sweden)"},
480 {0x081d,"Swedish (Finland)"},
484 {0x0421,"Indonesian"},
485 {0x0422,"Ukrainian"},
486 {0x0423,"Belarusian"},
490 {0x0427,"Lithuanian (modern)"},
491 {0x0827,"Lithuanian (classic)"},
494 {0x042a,"Vietnamese"},
496 {0x042c,"Azeri (latin)"},
497 {0x082c,"Azeri (cyrillic)"},
500 {0x042f,"Macedonian"},
507 {0x0436,"Afrikaans"},
513 {0x043c,"Irish gaelic"},
514 {0x083c,"Scottish gaelic"},
515 {0x043e,"Malay (Malaysia)"},
516 {0x083e,"Malay (Brunei Darussalam)"},
519 {0x0443,"Uzbek (latin)"},
520 {0x0843,"Uzbek (cyrillic)"},
529 {0x044c,"Malayalam"},
534 {0x048f,"Esperanto"}, /* Non official */
538 {0x0402,"Bulgarisch"},
539 {0x0403,"Katalanisch"},
540 {0x0404,"Traditionales Chinesisch"},
541 {0x0405,"Tschecisch"},
544 {0x0408,"Griechisch"},
545 {0x0409,"Amerikanisches Englisch"},
546 {0x040A,"Kastilisches Spanisch"},
548 {0x040C,"Franzvsisch"},
549 {0x040D,"Hebrdisch"},
550 {0x040E,"Ungarisch"},
551 {0x040F,"Isldndisch"},
552 {0x0410,"Italienisch"},
553 {0x0411,"Japanisch"},
554 {0x0412,"Koreanisch"},
555 {0x0413,"Niederldndisch"},
556 {0x0414,"Norwegisch-Bokmal"},
558 {0x0416,"Brasilianisches Portugiesisch"},
559 {0x0417,"Rdtoromanisch"},
560 {0x0418,"Rumdnisch"},
562 {0x041A,"Kroatoserbisch (lateinisch)"},
563 {0x041B,"Slowenisch"},
564 {0x041C,"Albanisch"},
565 {0x041D,"Schwedisch"},
570 {0x0804,"Vereinfachtes Chinesisch"},
571 {0x0807,"Schweizerdeutsch"},
572 {0x0809,"Britisches Englisch"},
573 {0x080A,"Mexikanisches Spanisch"},
574 {0x080C,"Belgisches Franzvsisch"},
575 {0x0810,"Schweizerisches Italienisch"},
576 {0x0813,"Belgisches Niederldndisch"},
577 {0x0814,"Norgwegisch-Nynorsk"},
578 {0x0816,"Portugiesisch"},
579 {0x081A,"Serbokratisch (kyrillisch)"},
580 {0x0C1C,"Kanadisches Franzvsisch"},
581 {0x100C,"Schweizerisches Franzvsisch"},
582 {0x0000,"Unbekannt"},
585 /***********************************************************************
586 * GetUserDefaultLCID (OLE2NLS.1)
588 LCID WINAPI GetUserDefaultLCID()
590 return MAKELCID( GetUserDefaultLangID() , SORT_DEFAULT );
593 /***********************************************************************
594 * GetSystemDefaultLCID (OLE2NLS.2)
596 LCID WINAPI GetSystemDefaultLCID()
598 return GetUserDefaultLCID();
601 /***********************************************************************
602 * GetUserDefaultLangID (OLE2NLS.3)
605 LANGID WINAPI GetUserDefaultLangID()
607 /* caching result, if defined from environment, which should (?) not change during a WINE session */
608 static LANGID userLCID = 0;
609 if (Options.language) {
610 return Languages[Options.language].langid;
615 char *lang,*country,*charset,*dialect,*next;
618 buf=getenv("LANGUAGE");
619 if (!buf) buf=getenv("LANG");
620 if (!buf) buf=getenv("LC_ALL");
621 if (!buf) buf=getenv("LC_MESSAGES");
622 if (!buf) buf=getenv("LC_CTYPE");
623 if (!buf) return userLCID = MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT );
625 if (!strcmp(buf,"POSIX") || !strcmp(buf,"C")) {
626 return MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT );
632 next=strchr(lang,':'); if (next) *next++='\0';
633 dialect=strchr(lang,'@'); if (dialect) *dialect++='\0';
634 charset=strchr(lang,'.'); if (charset) *charset++='\0';
635 country=strchr(lang,'_'); if (country) *country++='\0';
637 ret=MAIN_GetLanguageID(lang, country, charset, dialect);
641 } while (lang && !ret);
643 /* FIXME : are strings returned by getenv() to be free()'ed ? */
644 userLCID = (LANGID)ret;
650 /***********************************************************************
651 * GetSystemDefaultLangID (OLE2NLS.4)
653 LANGID WINAPI GetSystemDefaultLangID()
655 return GetUserDefaultLangID();
658 /******************************************************************************
659 * GetLocaleInfo32A [KERNEL32.342]
662 * LANG_NEUTRAL is equal to LOCALE_SYSTEM_DEFAULT
664 ULONG WINAPI GetLocaleInfo32A(LCID lcid,LCTYPE LCType,LPSTR buf,ULONG len)
670 DPRINT("(lcid=0x%lx,lctype=0x%lx,%p,%x)\n",lcid,LCType,buf,len);
672 if (len && (! buf) ) {
673 SetLastError(ERROR_INSUFFICIENT_BUFFER);
677 if (lcid ==0 || lcid == LANG_SYSTEM_DEFAULT || (LCType & LOCALE_NOUSEROVERRIDE) ) /* 0x00, 0x400 */
679 lcid = GetSystemDefaultLCID();
681 else if (lcid == LANG_USER_DEFAULT) /*0x800*/
683 lcid = GetUserDefaultLCID();
685 LCType &= ~(LOCALE_NOUSEROVERRIDE|LOCALE_USE_CP_ACP);
687 /* As an option, we could obtain the value from win.ini.
688 This would not match the Wine compile-time option.
689 Also, not all identifiers are available from win.ini */
691 /* If we are through all of this, retLen should not be zero anymore.
692 If it is, the value is not supported */
694 while (locale_name2id[i].name!=NULL) {
695 if (LCType == locale_name2id[i].id) {
696 retString = locale_name2id[i].name;
702 FIXME(ole,"Unkown LC type %lX\n",LCType);
707 for (i=0;(i<3 && !found);i++) {
710 for (j=0;j<sizeof(langlocales)/sizeof(langlocales[0]);j++) {
711 if (langlocales[j].lang == lang) {
714 for (k=0;k<sizeof(langlocales[j].locvars)/sizeof(langlocales[j].locvars[0]) && (langlocales[j].locvars[k].type);k++) {
715 if (langlocales[j].locvars[k].type == LCType) {
717 retString = langlocales[j].locvars[k].val;
725 /* language not found, try without a sublanguage*/
726 if (i==1) lang=MAKELANGID( PRIMARYLANGID(lang), SUBLANG_DEFAULT);
727 /* mask the LC Value */
728 if (i==2) LCType &= 0xfff;
732 ERR(ole,"'%s' not supported for your language (%04X).\n",
733 retString,(WORD)lcid);
734 SetLastError(ERROR_INVALID_PARAMETER);
737 /* if len=0 return only the length, don't touch the buffer*/
739 lstrcpyn32A(buf,retString,len);
741 return strlen(retString)+1;
744 /******************************************************************************
745 * GetLocaleInfo32W [KERNEL32.343]
748 ULONG WINAPI GetLocaleInfo32W(LCID lcid,LCTYPE LCType,LPWSTR wbuf,ULONG len)
752 if (len && (! wbuf) )
753 { SetLastError(ERROR_INSUFFICIENT_BUFFER);
757 abuf = (LPSTR)HeapAlloc(GetProcessHeap(),0,len);
758 wlen = 2 * GetLocaleInfo32A(lcid, LCType, abuf, len);
760 if (wlen && len) /* if len=0 return only the length*/
761 lstrcpynAtoW(wbuf,abuf,len/2);
763 HeapFree(GetProcessHeap(),0,abuf);
767 /******************************************************************************
768 * SetLocaleInfoA [KERNEL32.656]
770 BOOL16 WINAPI SetLocaleInfoA(DWORD lcid, DWORD lctype, LPCSTR data)
772 FIXME(ole,"(%ld,%ld,%s): stub\n",lcid,lctype,data);
776 /******************************************************************************
777 * IsValidLocale [KERNEL32.489]
780 BOOL32 WINAPI IsValidLocale(LCID lcid,DWORD flags)
782 /* we support ANY language. Well, at least say that...*/
787 /******************************************************************************
788 * EnumSystemLocales32W [KERNEL32.209]
790 BOOL32 WINAPI EnumSystemLocales32W( LOCALE_ENUMPROC32W lpfnLocaleEnum,
798 TRACE(win32,"(%p,%08lx)\n",lpfnLocaleEnum,flags );
799 /* see if we can reuse the Win95 registry entries.... */
800 if (ERROR_SUCCESS==RegOpenKey32A(HKEY_LOCAL_MACHINE,"System\\CurrentControlSet\\control\\Nls\\Locale\\",&xhkey)) {
803 if (ERROR_SUCCESS!=RegEnumKey32W(xhkey,i,buffer,sizeof(buffer)))
805 if (!lpfnLocaleEnum(buffer))
814 while (languages[i].langid!=0)
819 sprintf(xbuffer,"%08lx",(DWORD)languages[i].langid);
821 cp = HEAP_strdupAtoW( GetProcessHeap(), 0, xbuffer );
822 ret = lpfnLocaleEnum(cp);
823 HeapFree( GetProcessHeap(), 0, cp );
830 /******************************************************************************
831 * EnumSystemLocales32A [KERNEL32.208]
833 BOOL32 WINAPI EnumSystemLocales32A(LOCALE_ENUMPROC32A lpfnLocaleEnum,
840 TRACE(win32,"(%p,%08lx)\n",
843 if (ERROR_SUCCESS==RegOpenKey32A(HKEY_LOCAL_MACHINE,"System\\CurrentControlSet\\control\\Nls\\Locale\\",&xhkey)) {
846 if (ERROR_SUCCESS!=RegEnumKey32A(xhkey,i,buffer,sizeof(buffer)))
848 if (!lpfnLocaleEnum(buffer))
856 while (languages[i].langid!=0) {
857 sprintf(buffer,"%08lx",(DWORD)languages[i].langid);
858 if (!lpfnLocaleEnum(buffer))
865 static const unsigned char CT_CType2_LUT[] = {
866 C2_NOTAPPLICABLE, /* - 0 */
867 C2_NOTAPPLICABLE, /* - 1 */
868 C2_NOTAPPLICABLE, /* - 2 */
869 C2_NOTAPPLICABLE, /* - 3 */
870 C2_NOTAPPLICABLE, /* - 4 */
871 C2_NOTAPPLICABLE, /* - 5 */
872 C2_NOTAPPLICABLE, /* - 6 */
873 C2_NOTAPPLICABLE, /* - 7 */
874 C2_NOTAPPLICABLE, /* - 8 */
875 C2_SEGMENTSEPARATOR, /* - 9 */
876 C2_NOTAPPLICABLE, /* - 10 */
877 C2_NOTAPPLICABLE, /* - 11 */
878 C2_NOTAPPLICABLE, /* - 12 */
879 C2_NOTAPPLICABLE, /* - 13 */
880 C2_NOTAPPLICABLE, /* - 14 */
881 C2_NOTAPPLICABLE, /* - 15 */
882 C2_NOTAPPLICABLE, /* - 16 */
883 C2_NOTAPPLICABLE, /* - 17 */
884 C2_NOTAPPLICABLE, /* - 18 */
885 C2_NOTAPPLICABLE, /* - 19 */
886 C2_NOTAPPLICABLE, /* - 20 */
887 C2_NOTAPPLICABLE, /* - 21 */
888 C2_NOTAPPLICABLE, /* - 22 */
889 C2_NOTAPPLICABLE, /* - 23 */
890 C2_NOTAPPLICABLE, /* - 24 */
891 C2_NOTAPPLICABLE, /* - 25 */
892 C2_NOTAPPLICABLE, /* - 26 */
893 C2_NOTAPPLICABLE, /* - 27 */
894 C2_NOTAPPLICABLE, /* - 28 */
895 C2_NOTAPPLICABLE, /* - 29 */
896 C2_NOTAPPLICABLE, /* - 30 */
897 C2_NOTAPPLICABLE, /* - 31 */
898 C2_WHITESPACE, /* - 32 */
899 C2_OTHERNEUTRAL, /* ! - 33 */
900 C2_OTHERNEUTRAL, /* " - 34 */ /* " */
901 C2_EUROPETERMINATOR, /* # - 35 */
902 C2_EUROPETERMINATOR, /* $ - 36 */
903 C2_EUROPETERMINATOR, /* % - 37 */
904 C2_LEFTTORIGHT, /* & - 38 */
905 C2_OTHERNEUTRAL, /* ' - 39 */
906 C2_OTHERNEUTRAL, /* ( - 40 */
907 C2_OTHERNEUTRAL, /* ) - 41 */
908 C2_OTHERNEUTRAL, /* * - 42 */
909 C2_EUROPETERMINATOR, /* + - 43 */
910 C2_COMMONSEPARATOR, /* , - 44 */
911 C2_EUROPETERMINATOR, /* - - 45 */
912 C2_EUROPESEPARATOR, /* . - 46 */
913 C2_EUROPESEPARATOR, /* / - 47 */
914 C2_EUROPENUMBER, /* 0 - 48 */
915 C2_EUROPENUMBER, /* 1 - 49 */
916 C2_EUROPENUMBER, /* 2 - 50 */
917 C2_EUROPENUMBER, /* 3 - 51 */
918 C2_EUROPENUMBER, /* 4 - 52 */
919 C2_EUROPENUMBER, /* 5 - 53 */
920 C2_EUROPENUMBER, /* 6 - 54 */
921 C2_EUROPENUMBER, /* 7 - 55 */
922 C2_EUROPENUMBER, /* 8 - 56 */
923 C2_EUROPENUMBER, /* 9 - 57 */
924 C2_COMMONSEPARATOR, /* : - 58 */
925 C2_OTHERNEUTRAL, /* ; - 59 */
926 C2_OTHERNEUTRAL, /* < - 60 */
927 C2_OTHERNEUTRAL, /* = - 61 */
928 C2_OTHERNEUTRAL, /* > - 62 */
929 C2_OTHERNEUTRAL, /* ? - 63 */
930 C2_LEFTTORIGHT, /* @ - 64 */
931 C2_LEFTTORIGHT, /* A - 65 */
932 C2_LEFTTORIGHT, /* B - 66 */
933 C2_LEFTTORIGHT, /* C - 67 */
934 C2_LEFTTORIGHT, /* D - 68 */
935 C2_LEFTTORIGHT, /* E - 69 */
936 C2_LEFTTORIGHT, /* F - 70 */
937 C2_LEFTTORIGHT, /* G - 71 */
938 C2_LEFTTORIGHT, /* H - 72 */
939 C2_LEFTTORIGHT, /* I - 73 */
940 C2_LEFTTORIGHT, /* J - 74 */
941 C2_LEFTTORIGHT, /* K - 75 */
942 C2_LEFTTORIGHT, /* L - 76 */
943 C2_LEFTTORIGHT, /* M - 77 */
944 C2_LEFTTORIGHT, /* N - 78 */
945 C2_LEFTTORIGHT, /* O - 79 */
946 C2_LEFTTORIGHT, /* P - 80 */
947 C2_LEFTTORIGHT, /* Q - 81 */
948 C2_LEFTTORIGHT, /* R - 82 */
949 C2_LEFTTORIGHT, /* S - 83 */
950 C2_LEFTTORIGHT, /* T - 84 */
951 C2_LEFTTORIGHT, /* U - 85 */
952 C2_LEFTTORIGHT, /* V - 86 */
953 C2_LEFTTORIGHT, /* W - 87 */
954 C2_LEFTTORIGHT, /* X - 88 */
955 C2_LEFTTORIGHT, /* Y - 89 */
956 C2_LEFTTORIGHT, /* Z - 90 */
957 C2_OTHERNEUTRAL, /* [ - 91 */
958 C2_OTHERNEUTRAL, /* \ - 92 */
959 C2_OTHERNEUTRAL, /* ] - 93 */
960 C2_OTHERNEUTRAL, /* ^ - 94 */
961 C2_OTHERNEUTRAL, /* _ - 95 */
962 C2_OTHERNEUTRAL, /* ` - 96 */
963 C2_LEFTTORIGHT, /* a - 97 */
964 C2_LEFTTORIGHT, /* b - 98 */
965 C2_LEFTTORIGHT, /* c - 99 */
966 C2_LEFTTORIGHT, /* d - 100 */
967 C2_LEFTTORIGHT, /* e - 101 */
968 C2_LEFTTORIGHT, /* f - 102 */
969 C2_LEFTTORIGHT, /* g - 103 */
970 C2_LEFTTORIGHT, /* h - 104 */
971 C2_LEFTTORIGHT, /* i - 105 */
972 C2_LEFTTORIGHT, /* j - 106 */
973 C2_LEFTTORIGHT, /* k - 107 */
974 C2_LEFTTORIGHT, /* l - 108 */
975 C2_LEFTTORIGHT, /* m - 109 */
976 C2_LEFTTORIGHT, /* n - 110 */
977 C2_LEFTTORIGHT, /* o - 111 */
978 C2_LEFTTORIGHT, /* p - 112 */
979 C2_LEFTTORIGHT, /* q - 113 */
980 C2_LEFTTORIGHT, /* r - 114 */
981 C2_LEFTTORIGHT, /* s - 115 */
982 C2_LEFTTORIGHT, /* t - 116 */
983 C2_LEFTTORIGHT, /* u - 117 */
984 C2_LEFTTORIGHT, /* v - 118 */
985 C2_LEFTTORIGHT, /* w - 119 */
986 C2_LEFTTORIGHT, /* x - 120 */
987 C2_LEFTTORIGHT, /* y - 121 */
988 C2_LEFTTORIGHT, /* z - 122 */
989 C2_OTHERNEUTRAL, /* { - 123 */
990 C2_OTHERNEUTRAL, /* | - 124 */
991 C2_OTHERNEUTRAL, /* } - 125 */
992 C2_OTHERNEUTRAL, /* ~ - 126 */
993 C2_NOTAPPLICABLE, /*
\7f - 127 */
994 C2_NOTAPPLICABLE, /*
\80 - 128 */
995 C2_NOTAPPLICABLE, /*
\81 - 129 */
996 C2_OTHERNEUTRAL, /*
\82 - 130 */
997 C2_LEFTTORIGHT, /*
\83 - 131 */
998 C2_OTHERNEUTRAL, /*
\84 - 132 */
999 C2_OTHERNEUTRAL, /*
\85 - 133 */
1000 C2_OTHERNEUTRAL, /*
\86 - 134 */
1001 C2_OTHERNEUTRAL, /*
\87 - 135 */
1002 C2_LEFTTORIGHT, /*
\88 - 136 */
1003 C2_EUROPETERMINATOR, /*
\89 - 137 */
1004 C2_LEFTTORIGHT, /*
\8a - 138 */
1005 C2_OTHERNEUTRAL, /*
\8b - 139 */
1006 C2_LEFTTORIGHT, /*
\8c - 140 */
1007 C2_NOTAPPLICABLE, /*
\8d - 141 */
1008 C2_NOTAPPLICABLE, /*
\8e - 142 */
1009 C2_NOTAPPLICABLE, /*
\8f - 143 */
1010 C2_NOTAPPLICABLE, /*
\90 - 144 */
1011 C2_OTHERNEUTRAL, /*
\91 - 145 */
1012 C2_OTHERNEUTRAL, /*
\92 - 146 */
1013 C2_OTHERNEUTRAL, /*
\93 - 147 */
1014 C2_OTHERNEUTRAL, /*
\94 - 148 */
1015 C2_OTHERNEUTRAL, /*
\95 - 149 */
1016 C2_OTHERNEUTRAL, /*
\96 - 150 */
1017 C2_OTHERNEUTRAL, /*
\97 - 151 */
1018 C2_LEFTTORIGHT, /*
\98 - 152 */
1019 C2_OTHERNEUTRAL, /*
\99 - 153 */
1020 C2_LEFTTORIGHT, /*
\9a - 154 */
1021 C2_OTHERNEUTRAL, /*
\9b - 155 */
1022 C2_LEFTTORIGHT, /*
\9c - 156 */
1023 C2_NOTAPPLICABLE, /*
\9d - 157 */
1024 C2_NOTAPPLICABLE, /*
\9e - 158 */
1025 C2_LEFTTORIGHT, /*
\9f - 159 */
1026 C2_WHITESPACE, /* - 160 */
1027 C2_OTHERNEUTRAL, /* ¡ - 161 */
1028 C2_EUROPETERMINATOR, /* ¢ - 162 */
1029 C2_EUROPETERMINATOR, /* £ - 163 */
1030 C2_EUROPETERMINATOR, /* ¤ - 164 */
1031 C2_EUROPETERMINATOR, /* ¥ - 165 */
1032 C2_OTHERNEUTRAL, /* ¦ - 166 */
1033 C2_OTHERNEUTRAL, /* § - 167 */
1034 C2_OTHERNEUTRAL, /* ¨ - 168 */
1035 C2_OTHERNEUTRAL, /* © - 169 */
1036 C2_OTHERNEUTRAL, /* ª - 170 */
1037 C2_OTHERNEUTRAL, /* « - 171 */
1038 C2_OTHERNEUTRAL, /* ¬ - 172 */
1039 C2_OTHERNEUTRAL, /* - 173 */
1040 C2_OTHERNEUTRAL, /* ® - 174 */
1041 C2_OTHERNEUTRAL, /* ¯ - 175 */
1042 C2_EUROPETERMINATOR, /* ° - 176 */
1043 C2_EUROPETERMINATOR, /* ± - 177 */
1044 C2_EUROPENUMBER, /* ² - 178 */
1045 C2_EUROPENUMBER, /* ³ - 179 */
1046 C2_OTHERNEUTRAL, /* ´ - 180 */
1047 C2_OTHERNEUTRAL, /* µ - 181 */
1048 C2_OTHERNEUTRAL, /* ¶ - 182 */
1049 C2_OTHERNEUTRAL, /* · - 183 */
1050 C2_OTHERNEUTRAL, /* ¸ - 184 */
1051 C2_EUROPENUMBER, /* ¹ - 185 */
1052 C2_OTHERNEUTRAL, /* º - 186 */
1053 C2_OTHERNEUTRAL, /* » - 187 */
1054 C2_OTHERNEUTRAL, /* ¼ - 188 */
1055 C2_OTHERNEUTRAL, /* ½ - 189 */
1056 C2_OTHERNEUTRAL, /* ¾ - 190 */
1057 C2_OTHERNEUTRAL, /* ¿ - 191 */
1058 C2_LEFTTORIGHT, /* À - 192 */
1059 C2_LEFTTORIGHT, /* Á - 193 */
1060 C2_LEFTTORIGHT, /* Â - 194 */
1061 C2_LEFTTORIGHT, /* Ã - 195 */
1062 C2_LEFTTORIGHT, /* Ä - 196 */
1063 C2_LEFTTORIGHT, /* Å - 197 */
1064 C2_LEFTTORIGHT, /* Æ - 198 */
1065 C2_LEFTTORIGHT, /* Ç - 199 */
1066 C2_LEFTTORIGHT, /* È - 200 */
1067 C2_LEFTTORIGHT, /* É - 201 */
1068 C2_LEFTTORIGHT, /* Ê - 202 */
1069 C2_LEFTTORIGHT, /* Ë - 203 */
1070 C2_LEFTTORIGHT, /* Ì - 204 */
1071 C2_LEFTTORIGHT, /* Í - 205 */
1072 C2_LEFTTORIGHT, /* Î - 206 */
1073 C2_LEFTTORIGHT, /* Ï - 207 */
1074 C2_LEFTTORIGHT, /* Ð - 208 */
1075 C2_LEFTTORIGHT, /* Ñ - 209 */
1076 C2_LEFTTORIGHT, /* Ò - 210 */
1077 C2_LEFTTORIGHT, /* Ó - 211 */
1078 C2_LEFTTORIGHT, /* Ô - 212 */
1079 C2_LEFTTORIGHT, /* Õ - 213 */
1080 C2_LEFTTORIGHT, /* Ö - 214 */
1081 C2_OTHERNEUTRAL, /* × - 215 */
1082 C2_LEFTTORIGHT, /* Ø - 216 */
1083 C2_LEFTTORIGHT, /* Ù - 217 */
1084 C2_LEFTTORIGHT, /* Ú - 218 */
1085 C2_LEFTTORIGHT, /* Û - 219 */
1086 C2_LEFTTORIGHT, /* Ü - 220 */
1087 C2_LEFTTORIGHT, /* Ý - 221 */
1088 C2_LEFTTORIGHT, /* Þ - 222 */
1089 C2_LEFTTORIGHT, /* ß - 223 */
1090 C2_LEFTTORIGHT, /* à - 224 */
1091 C2_LEFTTORIGHT, /* á - 225 */
1092 C2_LEFTTORIGHT, /* â - 226 */
1093 C2_LEFTTORIGHT, /* ã - 227 */
1094 C2_LEFTTORIGHT, /* ä - 228 */
1095 C2_LEFTTORIGHT, /* å - 229 */
1096 C2_LEFTTORIGHT, /* æ - 230 */
1097 C2_LEFTTORIGHT, /* ç - 231 */
1098 C2_LEFTTORIGHT, /* è - 232 */
1099 C2_LEFTTORIGHT, /* é - 233 */
1100 C2_LEFTTORIGHT, /* ê - 234 */
1101 C2_LEFTTORIGHT, /* ë - 235 */
1102 C2_LEFTTORIGHT, /* ì - 236 */
1103 C2_LEFTTORIGHT, /* í - 237 */
1104 C2_LEFTTORIGHT, /* î - 238 */
1105 C2_LEFTTORIGHT, /* ï - 239 */
1106 C2_LEFTTORIGHT, /* ð - 240 */
1107 C2_LEFTTORIGHT, /* ñ - 241 */
1108 C2_LEFTTORIGHT, /* ò - 242 */
1109 C2_LEFTTORIGHT, /* ó - 243 */
1110 C2_LEFTTORIGHT, /* ô - 244 */
1111 C2_LEFTTORIGHT, /* õ - 245 */
1112 C2_LEFTTORIGHT, /* ö - 246 */
1113 C2_OTHERNEUTRAL, /* ÷ - 247 */
1114 C2_LEFTTORIGHT, /* ø - 248 */
1115 C2_LEFTTORIGHT, /* ù - 249 */
1116 C2_LEFTTORIGHT, /* ú - 250 */
1117 C2_LEFTTORIGHT, /* û - 251 */
1118 C2_LEFTTORIGHT, /* ü - 252 */
1119 C2_LEFTTORIGHT, /* ý - 253 */
1120 C2_LEFTTORIGHT, /* þ - 254 */
1121 C2_LEFTTORIGHT /* ÿ - 255 */
1124 static const WORD CT_CType3_LUT[] = {
1158 0x0048, /* ! - 33 */
1159 0x0448, /* " - 34 */ /* " */
1160 0x0048, /* # - 35 */
1161 0x0448, /* $ - 36 */
1162 0x0048, /* % - 37 */
1163 0x0048, /* & - 38 */
1164 0x0440, /* ' - 39 */
1165 0x0048, /* ( - 40 */
1166 0x0048, /* ) - 41 */
1167 0x0048, /* * - 42 */
1168 0x0048, /* + - 43 */
1169 0x0048, /* , - 44 */
1170 0x0440, /* - - 45 */
1171 0x0048, /* . - 46 */
1172 0x0448, /* / - 47 */
1173 0x0040, /* 0 - 48 */
1174 0x0040, /* 1 - 49 */
1175 0x0040, /* 2 - 50 */
1176 0x0040, /* 3 - 51 */
1177 0x0040, /* 4 - 52 */
1178 0x0040, /* 5 - 53 */
1179 0x0040, /* 6 - 54 */
1180 0x0040, /* 7 - 55 */
1181 0x0040, /* 8 - 56 */
1182 0x0040, /* 9 - 57 */
1183 0x0048, /* : - 58 */
1184 0x0048, /* ; - 59 */
1185 0x0048, /* < - 60 */
1186 0x0448, /* = - 61 */
1187 0x0048, /* > - 62 */
1188 0x0048, /* ? - 63 */
1189 0x0448, /* @ - 64 */
1190 0x8040, /* A - 65 */
1191 0x8040, /* B - 66 */
1192 0x8040, /* C - 67 */
1193 0x8040, /* D - 68 */
1194 0x8040, /* E - 69 */
1195 0x8040, /* F - 70 */
1196 0x8040, /* G - 71 */
1197 0x8040, /* H - 72 */
1198 0x8040, /* I - 73 */
1199 0x8040, /* J - 74 */
1200 0x8040, /* K - 75 */
1201 0x8040, /* L - 76 */
1202 0x8040, /* M - 77 */
1203 0x8040, /* N - 78 */
1204 0x8040, /* O - 79 */
1205 0x8040, /* P - 80 */
1206 0x8040, /* Q - 81 */
1207 0x8040, /* R - 82 */
1208 0x8040, /* S - 83 */
1209 0x8040, /* T - 84 */
1210 0x8040, /* U - 85 */
1211 0x8040, /* V - 86 */
1212 0x8040, /* W - 87 */
1213 0x8040, /* X - 88 */
1214 0x8040, /* Y - 89 */
1215 0x8040, /* Z - 90 */
1216 0x0048, /* [ - 91 */
1217 0x0448, /* \ - 92 */
1218 0x0048, /* ] - 93 */
1219 0x0448, /* ^ - 94 */
1220 0x0448, /* _ - 95 */
1221 0x0448, /* ` - 96 */
1222 0x8040, /* a - 97 */
1223 0x8040, /* b - 98 */
1224 0x8040, /* c - 99 */
1225 0x8040, /* d - 100 */
1226 0x8040, /* e - 101 */
1227 0x8040, /* f - 102 */
1228 0x8040, /* g - 103 */
1229 0x8040, /* h - 104 */
1230 0x8040, /* i - 105 */
1231 0x8040, /* j - 106 */
1232 0x8040, /* k - 107 */
1233 0x8040, /* l - 108 */
1234 0x8040, /* m - 109 */
1235 0x8040, /* n - 110 */
1236 0x8040, /* o - 111 */
1237 0x8040, /* p - 112 */
1238 0x8040, /* q - 113 */
1239 0x8040, /* r - 114 */
1240 0x8040, /* s - 115 */
1241 0x8040, /* t - 116 */
1242 0x8040, /* u - 117 */
1243 0x8040, /* v - 118 */
1244 0x8040, /* w - 119 */
1245 0x8040, /* x - 120 */
1246 0x8040, /* y - 121 */
1247 0x8040, /* z - 122 */
1248 0x0048, /* { - 123 */
1249 0x0048, /* | - 124 */
1250 0x0048, /* } - 125 */
1251 0x0448, /* ~ - 126 */
1252 0x0000, /*
\7f - 127 */
1253 0x0000, /*
\80 - 128 */
1254 0x0000, /*
\81 - 129 */
1255 0x0008, /*
\82 - 130 */
1256 0x8000, /*
\83 - 131 */
1257 0x0008, /*
\84 - 132 */
1258 0x0008, /*
\85 - 133 */
1259 0x0008, /*
\86 - 134 */
1260 0x0008, /*
\87 - 135 */
1261 0x0001, /*
\88 - 136 */
1262 0x0008, /*
\89 - 137 */
1263 0x8003, /*
\8a - 138 */
1264 0x0008, /*
\8b - 139 */
1265 0x8000, /*
\8c - 140 */
1266 0x0000, /*
\8d - 141 */
1267 0x0000, /*
\8e - 142 */
1268 0x0000, /*
\8f - 143 */
1269 0x0000, /*
\90 - 144 */
1270 0x0088, /*
\91 - 145 */
1271 0x0088, /*
\92 - 146 */
1272 0x0088, /*
\93 - 147 */
1273 0x0088, /*
\94 - 148 */
1274 0x0008, /*
\95 - 149 */
1275 0x0400, /*
\96 - 150 */
1276 0x0400, /*
\97 - 151 */
1277 0x0408, /*
\98 - 152 */
1278 0x0000, /*
\99 - 153 */
1279 0x8003, /*
\9a - 154 */
1280 0x0008, /*
\9b - 155 */
1281 0x8000, /*
\9c - 156 */
1282 0x0000, /*
\9d - 157 */
1283 0x0000, /*
\9e - 158 */
1284 0x8003, /*
\9f - 159 */
1286 0x0008, /* ¡ - 161 */
1287 0x0048, /* ¢ - 162 */
1288 0x0048, /* £ - 163 */
1289 0x0008, /* ¤ - 164 */
1290 0x0048, /* ¥ - 165 */
1291 0x0048, /* ¦ - 166 */
1292 0x0008, /* § - 167 */
1293 0x0408, /* ¨ - 168 */
1294 0x0008, /* © - 169 */
1295 0x0400, /* ª - 170 */
1296 0x0008, /* « - 171 */
1297 0x0048, /* ¬ - 172 */
1298 0x0408, /* - 173 */
1299 0x0008, /* ® - 174 */
1300 0x0448, /* ¯ - 175 */
1301 0x0008, /* ° - 176 */
1302 0x0008, /* ± - 177 */
1303 0x0000, /* ² - 178 */
1304 0x0000, /* ³ - 179 */
1305 0x0408, /* ´ - 180 */
1306 0x0008, /* µ - 181 */
1307 0x0008, /* ¶ - 182 */
1308 0x0008, /* · - 183 */
1309 0x0408, /* ¸ - 184 */
1310 0x0000, /* ¹ - 185 */
1311 0x0400, /* º - 186 */
1312 0x0008, /* » - 187 */
1313 0x0000, /* ¼ - 188 */
1314 0x0000, /* ½ - 189 */
1315 0x0000, /* ¾ - 190 */
1316 0x0008, /* ¿ - 191 */
1317 0x8003, /* À - 192 */
1318 0x8003, /* Á - 193 */
1319 0x8003, /* Â - 194 */
1320 0x8003, /* Ã - 195 */
1321 0x8003, /* Ä - 196 */
1322 0x8003, /* Å - 197 */
1323 0x8000, /* Æ - 198 */
1324 0x8003, /* Ç - 199 */
1325 0x8003, /* È - 200 */
1326 0x8003, /* É - 201 */
1327 0x8003, /* Ê - 202 */
1328 0x8003, /* Ë - 203 */
1329 0x8003, /* Ì - 204 */
1330 0x8003, /* Í - 205 */
1331 0x8003, /* Î - 206 */
1332 0x8003, /* Ï - 207 */
1333 0x8000, /* Ð - 208 */
1334 0x8003, /* Ñ - 209 */
1335 0x8003, /* Ò - 210 */
1336 0x8003, /* Ó - 211 */
1337 0x8003, /* Ô - 212 */
1338 0x8003, /* Õ - 213 */
1339 0x8003, /* Ö - 214 */
1340 0x0008, /* × - 215 */
1341 0x8003, /* Ø - 216 */
1342 0x8003, /* Ù - 217 */
1343 0x8003, /* Ú - 218 */
1344 0x8003, /* Û - 219 */
1345 0x8003, /* Ü - 220 */
1346 0x8003, /* Ý - 221 */
1347 0x8000, /* Þ - 222 */
1348 0x8000, /* ß - 223 */
1349 0x8003, /* à - 224 */
1350 0x8003, /* á - 225 */
1351 0x8003, /* â - 226 */
1352 0x8003, /* ã - 227 */
1353 0x8003, /* ä - 228 */
1354 0x8003, /* å - 229 */
1355 0x8000, /* æ - 230 */
1356 0x8003, /* ç - 231 */
1357 0x8003, /* è - 232 */
1358 0x8003, /* é - 233 */
1359 0x8003, /* ê - 234 */
1360 0x8003, /* ë - 235 */
1361 0x8003, /* ì - 236 */
1362 0x8003, /* í - 237 */
1363 0x8003, /* î - 238 */
1364 0x8003, /* ï - 239 */
1365 0x8000, /* ð - 240 */
1366 0x8003, /* ñ - 241 */
1367 0x8003, /* ò - 242 */
1368 0x8003, /* ó - 243 */
1369 0x8003, /* ô - 244 */
1370 0x8003, /* õ - 245 */
1371 0x8003, /* ö - 246 */
1372 0x0008, /* ÷ - 247 */
1373 0x8003, /* ø - 248 */
1374 0x8003, /* ù - 249 */
1375 0x8003, /* ú - 250 */
1376 0x8003, /* û - 251 */
1377 0x8003, /* ü - 252 */
1378 0x8003, /* ý - 253 */
1379 0x8000, /* þ - 254 */
1380 0x8003 /* ÿ - 255 */
1383 /******************************************************************************
1384 * GetStringType32A [KERNEL32.396]
1386 BOOL32 WINAPI GetStringType32A(LCID locale,DWORD dwInfoType,LPCSTR src,
1387 ULONG cchSrc,LPWORD chartype)
1389 return GetStringTypeEx32A(locale,dwInfoType,src,cchSrc,chartype);
1392 /******************************************************************************
1393 * GetStringTypeEx32A [KERNEL32.397]
1395 * FIXME: Ignores the locale.
1397 BOOL32 WINAPI GetStringTypeEx32A(LCID locale,DWORD dwInfoType,LPCSTR src,
1398 ULONG cchSrc,LPWORD chartype)
1402 if ((src==NULL) || (chartype==NULL) || (src==(LPSTR)chartype))
1404 SetLastError(ERROR_INVALID_PARAMETER);
1409 cchSrc=lstrlen32A(src)+1;
1411 switch (dwInfoType) {
1413 for (i=0;i<cchSrc;i++)
1416 if (isdigit(src[i])) chartype[i]|=C1_DIGIT;
1417 if (isalpha(src[i])) chartype[i]|=C1_ALPHA;
1418 if (islower(src[i])) chartype[i]|=C1_LOWER;
1419 if (isupper(src[i])) chartype[i]|=C1_UPPER;
1420 if (isspace(src[i])) chartype[i]|=C1_SPACE;
1421 if (ispunct(src[i])) chartype[i]|=C1_PUNCT;
1422 if (iscntrl(src[i])) chartype[i]|=C1_CNTRL;
1423 /* FIXME: isblank() is a GNU extension */
1424 /* if (isblank(src[i])) chartype[i]|=C1_BLANK; */
1425 if ((src[i] == ' ') || (src[i] == '\t')) chartype[i]|=C1_BLANK;
1431 for (i=0;i<cchSrc;i++)
1433 chartype[i]=(WORD)CT_CType2_LUT[i];
1438 for (i=0;i<cchSrc;i++)
1440 chartype[i]=CT_CType3_LUT[i];
1445 ERR(ole,"Unknown dwInfoType:%ld\n",dwInfoType);
1450 /******************************************************************************
1451 * GetStringType32W [KERNEL32.399]
1454 * Yes, this is missing LCID locale. MS fault.
1456 BOOL32 WINAPI GetStringType32W(DWORD dwInfoType,LPCWSTR src,ULONG cchSrc,
1459 return GetStringTypeEx32W(0/*defaultlocale*/,dwInfoType,src,cchSrc,chartype);
1462 /******************************************************************************
1463 * GetStringTypeEx32W [KERNEL32.398]
1465 * FIXME: unicode chars are assumed chars
1467 BOOL32 WINAPI GetStringTypeEx32W(LCID locale,DWORD dwInfoType,LPCWSTR src,
1468 ULONG cchSrc,LPWORD chartype)
1474 cchSrc=lstrlen32W(src)+1;
1476 switch (dwInfoType) {
1478 FIXME(ole,"CT_CTYPE2 not supported.\n");
1481 FIXME(ole,"CT_CTYPE3 not supported.\n");
1485 for (i=0;i<cchSrc;i++) {
1487 if (isdigit(src[i])) chartype[i]|=C1_DIGIT;
1488 if (isalpha(src[i])) chartype[i]|=C1_ALPHA;
1489 if (islower(src[i])) chartype[i]|=C1_LOWER;
1490 if (isupper(src[i])) chartype[i]|=C1_UPPER;
1491 if (isspace(src[i])) chartype[i]|=C1_SPACE;
1492 if (ispunct(src[i])) chartype[i]|=C1_PUNCT;
1493 if (iscntrl(src[i])) chartype[i]|=C1_CNTRL;
1494 /* FIXME: isblank() is a GNU extension */
1495 /* if (isblank(src[i])) chartype[i]|=C1_BLANK; */
1496 if ((src[i] == ' ') || (src[i] == '\t')) chartype[i]|=C1_BLANK;
1502 /*****************************************************************
1503 * VerLanguageName32A [VERSION.9]
1505 DWORD WINAPI VerLanguageName32A(ULONG langid,LPSTR langname,
1508 return VerLanguageName16(langid,langname,langnamelen);
1511 /*****************************************************************
1512 * VerLanguageName32W [VERSION.10]
1514 DWORD WINAPI VerLanguageName32W(ULONG langid,LPWSTR langname,
1522 /* First, check \System\CurrentControlSet\control\Nls\Locale\<langid>
1523 * from the registry.
1526 "\\System\\CurrentControlSet\\control\\Nls\\Locale\\%08x",
1528 keyname = HEAP_strdupAtoW( GetProcessHeap(), 0, buffer );
1529 result = RegQueryValue32W(HKEY_LOCAL_MACHINE, keyname, langname,
1530 (LPDWORD)&langnamelen);
1531 HeapFree( GetProcessHeap(), 0, keyname );
1532 if (result != ERROR_SUCCESS) {
1533 /* if that fails, use the internal table */
1534 for (i=0;languages[i].langid!=0;i++)
1535 if (langid==languages[i].langid)
1537 lstrcpyAtoW( langname, languages[i].langname );
1538 langnamelen = strlen(languages[i].langname);
1539 /* same as strlenW(langname); */
1544 static const unsigned char LCM_Unicode_LUT[] = {
1577 7 , 28, /* ! - 33 */
1578 7 , 29, /* " - 34 */ /* " */
1579 7 , 31, /* # - 35 */
1580 7 , 33, /* $ - 36 */
1581 7 , 35, /* % - 37 */
1582 7 , 37, /* & - 38 */
1583 6 , 128, /* ' - 39 */
1584 7 , 39, /* ( - 40 */
1585 7 , 42, /* ) - 41 */
1586 7 , 45, /* * - 42 */
1588 7 , 47, /* , - 44 */
1589 6 , 130, /* - - 45 */
1590 7 , 51, /* . - 46 */
1591 7 , 53, /* / - 47 */
1592 12 , 3, /* 0 - 48 */
1593 12 , 33, /* 1 - 49 */
1594 12 , 51, /* 2 - 50 */
1595 12 , 70, /* 3 - 51 */
1596 12 , 88, /* 4 - 52 */
1597 12 , 106, /* 5 - 53 */
1598 12 , 125, /* 6 - 54 */
1599 12 , 144, /* 7 - 55 */
1600 12 , 162, /* 8 - 56 */
1601 12 , 180, /* 9 - 57 */
1602 7 , 55, /* : - 58 */
1603 7 , 58, /* ; - 59 */
1604 8 , 14, /* < - 60 */
1605 8 , 18, /* = - 61 */
1606 8 , 20, /* > - 62 */
1607 7 , 60, /* ? - 63 */
1608 7 , 62, /* @ - 64 */
1609 14 , 2, /* A - 65 */
1610 14 , 9, /* B - 66 */
1611 14 , 10, /* C - 67 */
1612 14 , 26, /* D - 68 */
1613 14 , 33, /* E - 69 */
1614 14 , 35, /* F - 70 */
1615 14 , 37, /* G - 71 */
1616 14 , 44, /* H - 72 */
1617 14 , 50, /* I - 73 */
1618 14 , 53, /* J - 74 */
1619 14 , 54, /* K - 75 */
1620 14 , 72, /* L - 76 */
1621 14 , 81, /* M - 77 */
1622 14 , 112, /* N - 78 */
1623 14 , 124, /* O - 79 */
1624 14 , 126, /* P - 80 */
1625 14 , 137, /* Q - 81 */
1626 14 , 138, /* R - 82 */
1627 14 , 145, /* S - 83 */
1628 14 , 153, /* T - 84 */
1629 14 , 159, /* U - 85 */
1630 14 , 162, /* V - 86 */
1631 14 , 164, /* W - 87 */
1632 14 , 166, /* X - 88 */
1633 14 , 167, /* Y - 89 */
1634 14 , 169, /* Z - 90 */
1635 7 , 63, /* [ - 91 */
1636 7 , 65, /* \ - 92 */
1637 7 , 66, /* ] - 93 */
1638 7 , 67, /* ^ - 94 */
1639 7 , 68, /* _ - 95 */
1640 7 , 72, /* ` - 96 */
1641 14 , 2, /* a - 97 */
1642 14 , 9, /* b - 98 */
1643 14 , 10, /* c - 99 */
1644 14 , 26, /* d - 100 */
1645 14 , 33, /* e - 101 */
1646 14 , 35, /* f - 102 */
1647 14 , 37, /* g - 103 */
1648 14 , 44, /* h - 104 */
1649 14 , 50, /* i - 105 */
1650 14 , 53, /* j - 106 */
1651 14 , 54, /* k - 107 */
1652 14 , 72, /* l - 108 */
1653 14 , 81, /* m - 109 */
1654 14 , 112, /* n - 110 */
1655 14 , 124, /* o - 111 */
1656 14 , 126, /* p - 112 */
1657 14 , 137, /* q - 113 */
1658 14 , 138, /* r - 114 */
1659 14 , 145, /* s - 115 */
1660 14 , 153, /* t - 116 */
1661 14 , 159, /* u - 117 */
1662 14 , 162, /* v - 118 */
1663 14 , 164, /* w - 119 */
1664 14 , 166, /* x - 120 */
1665 14 , 167, /* y - 121 */
1666 14 , 169, /* z - 122 */
1667 7 , 74, /* { - 123 */
1668 7 , 76, /* | - 124 */
1669 7 , 78, /* } - 125 */
1670 7 , 80, /* ~ - 126 */
1671 6 , 29, /*
\7f - 127 */
1672 6 , 30, /*
\80 - 128 */
1673 6 , 31, /*
\81 - 129 */
1674 7 , 123, /*
\82 - 130 */
1675 14 , 35, /*
\83 - 131 */
1676 7 , 127, /*
\84 - 132 */
1677 10 , 21, /*
\85 - 133 */
1678 10 , 15, /*
\86 - 134 */
1679 10 , 16, /*
\87 - 135 */
1680 7 , 67, /*
\88 - 136 */
1681 10 , 22, /*
\89 - 137 */
1682 14 , 145, /*
\8a - 138 */
1683 7 , 136, /*
\8b - 139 */
1684 14 + 16 , 124, /*
\8c - 140 */
1685 6 , 43, /*
\8d - 141 */
1686 6 , 44, /*
\8e - 142 */
1687 6 , 45, /*
\8f - 143 */
1688 6 , 46, /*
\90 - 144 */
1689 7 , 121, /*
\91 - 145 */
1690 7 , 122, /*
\92 - 146 */
1691 7 , 125, /*
\93 - 147 */
1692 7 , 126, /*
\94 - 148 */
1693 10 , 17, /*
\95 - 149 */
1694 6 , 137, /*
\96 - 150 */
1695 6 , 139, /*
\97 - 151 */
1696 7 , 93, /*
\98 - 152 */
1697 14 , 156, /*
\99 - 153 */
1698 14 , 145, /*
\9a - 154 */
1699 7 , 137, /*
\9b - 155 */
1700 14 + 16 , 124, /*
\9c - 156 */
1701 6 , 59, /*
\9d - 157 */
1702 6 , 60, /*
\9e - 158 */
1703 14 , 167, /*
\9f - 159 */
1705 7 , 81, /* ¡ - 161 */
1706 10 , 2, /* ¢ - 162 */
1707 10 , 3, /* £ - 163 */
1708 10 , 4, /* ¤ - 164 */
1709 10 , 5, /* ¥ - 165 */
1710 7 , 82, /* ¦ - 166 */
1711 10 , 6, /* § - 167 */
1712 7 , 83, /* ¨ - 168 */
1713 10 , 7, /* © - 169 */
1714 14 , 2, /* ª - 170 */
1715 8 , 24, /* « - 171 */
1716 10 , 8, /* ¬ - 172 */
1717 6 , 131, /* - 173 */
1718 10 , 9, /* ® - 174 */
1719 7 , 84, /* ¯ - 175 */
1720 10 , 10, /* ° - 176 */
1721 8 , 23, /* ± - 177 */
1722 12 , 51, /* ² - 178 */
1723 12 , 70, /* ³ - 179 */
1724 7 , 85, /* ´ - 180 */
1725 10 , 11, /* µ - 181 */
1726 10 , 12, /* ¶ - 182 */
1727 10 , 13, /* · - 183 */
1728 7 , 86, /* ¸ - 184 */
1729 12 , 33, /* ¹ - 185 */
1730 14 , 124, /* º - 186 */
1731 8 , 26, /* » - 187 */
1732 12 , 21, /* ¼ - 188 */
1733 12 , 25, /* ½ - 189 */
1734 12 , 29, /* ¾ - 190 */
1735 7 , 87, /* ¿ - 191 */
1736 14 , 2, /* À - 192 */
1737 14 , 2, /* Á - 193 */
1738 14 , 2, /* Â - 194 */
1739 14 , 2, /* Ã - 195 */
1740 14 , 2, /* Ä - 196 */
1741 14 , 2, /* Å - 197 */
1742 14 + 16 , 2, /* Æ - 198 */
1743 14 , 10, /* Ç - 199 */
1744 14 , 33, /* È - 200 */
1745 14 , 33, /* É - 201 */
1746 14 , 33, /* Ê - 202 */
1747 14 , 33, /* Ë - 203 */
1748 14 , 50, /* Ì - 204 */
1749 14 , 50, /* Í - 205 */
1750 14 , 50, /* Î - 206 */
1751 14 , 50, /* Ï - 207 */
1752 14 , 26, /* Ð - 208 */
1753 14 , 112, /* Ñ - 209 */
1754 14 , 124, /* Ò - 210 */
1755 14 , 124, /* Ó - 211 */
1756 14 , 124, /* Ô - 212 */
1757 14 , 124, /* Õ - 213 */
1758 14 , 124, /* Ö - 214 */
1759 8 , 28, /* × - 215 */
1760 14 , 124, /* Ø - 216 */
1761 14 , 159, /* Ù - 217 */
1762 14 , 159, /* Ú - 218 */
1763 14 , 159, /* Û - 219 */
1764 14 , 159, /* Ü - 220 */
1765 14 , 167, /* Ý - 221 */
1766 14 + 32 , 153, /* Þ - 222 */
1767 14 + 48 , 145, /* ß - 223 */
1768 14 , 2, /* à - 224 */
1769 14 , 2, /* á - 225 */
1770 14 , 2, /* â - 226 */
1771 14 , 2, /* ã - 227 */
1772 14 , 2, /* ä - 228 */
1773 14 , 2, /* å - 229 */
1774 14 + 16 , 2, /* æ - 230 */
1775 14 , 10, /* ç - 231 */
1776 14 , 33, /* è - 232 */
1777 14 , 33, /* é - 233 */
1778 14 , 33, /* ê - 234 */
1779 14 , 33, /* ë - 235 */
1780 14 , 50, /* ì - 236 */
1781 14 , 50, /* í - 237 */
1782 14 , 50, /* î - 238 */
1783 14 , 50, /* ï - 239 */
1784 14 , 26, /* ð - 240 */
1785 14 , 112, /* ñ - 241 */
1786 14 , 124, /* ò - 242 */
1787 14 , 124, /* ó - 243 */
1788 14 , 124, /* ô - 244 */
1789 14 , 124, /* õ - 245 */
1790 14 , 124, /* ö - 246 */
1791 8 , 29, /* ÷ - 247 */
1792 14 , 124, /* ø - 248 */
1793 14 , 159, /* ù - 249 */
1794 14 , 159, /* ú - 250 */
1795 14 , 159, /* û - 251 */
1796 14 , 159, /* ü - 252 */
1797 14 , 167, /* ý - 253 */
1798 14 + 32 , 153, /* þ - 254 */
1799 14 , 167 /* ÿ - 255 */ };
1801 static const unsigned char LCM_Unicode_LUT_2[] = { 33, 44, 145 };
1803 #define LCM_Diacritic_Start 131
1805 static const unsigned char LCM_Diacritic_LUT[] = {
1806 123, /*
\83 - 131 */
1933 /******************************************************************************
1934 * OLE2NLS_isPunctuation [INTERNAL]
1936 static int OLE2NLS_isPunctuation(unsigned char c)
1938 /* "punctuation character" in this context is a character which is
1939 considered "less important" during word sort comparison.
1940 See LCMapString implementation for the precise definition
1941 of "less important". */
1943 return (LCM_Unicode_LUT[-2+2*c]==6);
1946 /******************************************************************************
1947 * identity [Internal]
1949 static int identity(int c)
1954 /*************************************************************************
1955 * LCMapString32A [KERNEL32.492]
1957 * Convert a string, or generate a sort key from it.
1959 * If (mapflags & LCMAP_SORTKEY), the function will generate
1960 * a sort key for the source string. Else, it will convert it
1961 * accordingly to the flags LCMAP_UPPERCASE, LCMAP_LOWERCASE,...
1965 * Success : length of the result string.
1968 * If called with scrlen = -1, the function will compute the length
1969 * of the 0-terminated string strsrc by itself.
1971 * If called with dstlen = 0, returns the buffer length that
1972 * would be required.
1974 * NORM_IGNOREWIDTH means to compare ASCII and Unicode characters
1975 * as if they are equal. Since Wine separates ASCII and Unicode into
1976 * separate functions, we shouldn't have to do anything for this flag.
1977 * I added it to the list of flags that don't need a fixme message
1978 * to make MS Word 95 not print several thousand fixme messages for
1981 ULONG WINAPI LCMapString32A(
1982 LCID lcid /* locale identifier created with MAKELCID;
1983 LOCALE_SYSTEM_DEFAULT and LOCALE_USER_DEFAULT are
1984 predefined values. */,
1985 DWORD mapflags /* flags */,
1986 LPCSTR srcstr /* source buffer */,
1987 ULONG srclen /* source length */,
1988 LPSTR dststr /* destination buffer */,
1989 ULONG dstlen /* destination buffer length */)
1993 TRACE(string,"(0x%04lx,0x%08lx,%s,%d,%p,%d)\n",
1994 lcid,mapflags,srcstr,srclen,dststr,dstlen);
1996 if ( ((dstlen!=0) && (dststr==NULL)) || (srcstr==NULL) )
1998 ERR(ole, "(src=%s,dest=%s): Invalid NULL string\n", srcstr, dststr);
1999 SetLastError(ERROR_INVALID_PARAMETER);
2003 srclen = lstrlen32A(srcstr) + 1 ; /* (include final '\0') */
2005 if (mapflags & ~ ( LCMAP_UPPERCASE | LCMAP_LOWERCASE | LCMAP_SORTKEY |
2006 NORM_IGNORECASE | NORM_IGNORENONSPACE | SORT_STRINGSORT |
2009 FIXME(string,"(0x%04lx,0x%08lx,%p,%d,%p,%d): "
2010 "unimplemented flags: 0x%08lx\n",
2012 mapflags&~(LCMAP_UPPERCASE | LCMAP_LOWERCASE | LCMAP_SORTKEY |
2013 NORM_IGNORECASE | NORM_IGNORENONSPACE | SORT_STRINGSORT |
2023 if ( !(mapflags & LCMAP_SORTKEY) )
2025 int (*f)(int)=identity;
2028 return srclen; /* dstlen=0 means "do nothing but return required length" */
2030 srclen=dstlen; /* No, this case is not an error under Windows 95.
2031 And no '\0' gets written. */
2032 if (mapflags & LCMAP_UPPERCASE)
2034 else if (mapflags & LCMAP_LOWERCASE)
2036 for (i=0; i < srclen; i++)
2037 dststr[i] = (CHAR) f(srcstr[i]);
2041 /* else ... (mapflags & LCMAP_SORTKEY) */
2045 int diacritic_len=0;
2046 int delayed_punctuation_len=0;
2047 char *case_component;
2048 char *diacritic_component;
2049 char *delayed_punctuation_component;
2051 int flag_stringsort = mapflags & SORT_STRINGSORT;
2053 /* compute how much room we will need */
2054 for (i=0;i<srclen;i++)
2057 unsigned char source_char = srcstr[i];
2058 if (source_char!='\0')
2060 if (flag_stringsort || !OLE2NLS_isPunctuation(source_char))
2063 if ( LCM_Unicode_LUT[-2+2*source_char] & ~15 )
2064 unicode_len++; /* double letter */
2068 delayed_punctuation_len++;
2072 if (isupper(source_char))
2073 case_len=unicode_len;
2075 ofs = source_char - LCM_Diacritic_Start;
2076 if ((ofs>=0) && (LCM_Diacritic_LUT[ofs]!=2))
2077 diacritic_len=unicode_len;
2080 if (mapflags & NORM_IGNORECASE)
2082 if (mapflags & NORM_IGNORENONSPACE)
2085 room = 2 * unicode_len /* "unicode" component */
2086 + diacritic_len /* "diacritic" component */
2087 + case_len /* "case" component */
2088 + 4 * delayed_punctuation_len /* punctuation in word sort mode */
2089 + 4 /* four '\1' separators */
2090 + 1 ; /* terminal '\0' */
2093 else if (dstlen<room)
2095 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2099 /*FIXME the Pointercheck should not be nessesary */
2100 if (IsBadWritePtr32 (dststr,room))
2101 { ERR (string,"bad destination buffer (dststr) : %p,%d\n",dststr,dstlen);
2102 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2106 /* locate each component, write separators */
2107 diacritic_component = dststr + 2*unicode_len ;
2108 *diacritic_component++ = '\1';
2109 case_component = diacritic_component + diacritic_len ;
2110 *case_component++ = '\1';
2111 delayed_punctuation_component = case_component + case_len ;
2112 *delayed_punctuation_component++ = '\1';
2113 *delayed_punctuation_component++ = '\1';
2115 /* read source string char by char, write
2116 corresponding weight in each component. */
2117 for (i=0,count=0;i<srclen;i++)
2119 unsigned char source_char=srcstr[i];
2120 if (source_char!='\0')
2123 type = LCM_Unicode_LUT[-2+2*source_char];
2124 longcode = type >> 4;
2126 if (!flag_stringsort && OLE2NLS_isPunctuation(source_char))
2128 UINT16 encrypted_location = (1<<15) + 7 + 4*count;
2129 *delayed_punctuation_component++ = (unsigned char) (encrypted_location>>8);
2130 *delayed_punctuation_component++ = (unsigned char) (encrypted_location&255);
2131 /* big-endian is used here because it lets string comparison be
2132 compatible with numerical comparison */
2134 *delayed_punctuation_component++ = type;
2135 *delayed_punctuation_component++ = LCM_Unicode_LUT[-1+2*source_char];
2136 /* assumption : a punctuation character is never a
2137 double or accented letter */
2141 dststr[2*count] = type;
2142 dststr[2*count+1] = LCM_Unicode_LUT[-1+2*source_char];
2146 case_component[count] = ( isupper(source_char) ? 18 : 2 ) ;
2147 if (count<diacritic_len)
2148 diacritic_component[count] = 2; /* assumption: a double letter
2149 is never accented */
2152 dststr[2*count] = type;
2153 dststr[2*count+1] = *(LCM_Unicode_LUT_2 - 1 + longcode);
2154 /* 16 in the first column of LCM_Unicode_LUT --> longcode = 1
2155 32 in the first column of LCM_Unicode_LUT --> longcode = 2
2156 48 in the first column of LCM_Unicode_LUT --> longcode = 3 */
2160 case_component[count] = ( isupper(source_char) ? 18 : 2 ) ;
2161 if (count<diacritic_len)
2163 int ofs = source_char - LCM_Diacritic_Start;
2164 diacritic_component[count] = (ofs>=0 ? LCM_Diacritic_LUT[ofs] : 2);
2170 dststr[room-1] = '\0';
2175 /*************************************************************************
2176 * LCMapString32W [KERNEL32.493]
2178 * Convert a string, or generate a sort key from it.
2182 * See LCMapString32A for documentation
2184 ULONG WINAPI LCMapString32W(
2185 LCID lcid,DWORD mapflags,LPCWSTR srcstr,ULONG srclen,LPWSTR dststr,
2190 TRACE(string,"(0x%04lx,0x%08lx,%p,%d,%p,%d)\n",
2191 lcid,mapflags,srcstr,srclen,dststr,dstlen);
2193 if ( ((dstlen!=0) && (dststr==NULL)) || (srcstr==NULL) )
2195 ERR(ole, "(src=%p,dst=%p): Invalid NULL string\n", srcstr, dststr);
2196 SetLastError(ERROR_INVALID_PARAMETER);
2200 srclen = lstrlen32W(srcstr)+1;
2201 if (mapflags & LCMAP_SORTKEY)
2203 FIXME(string,"(0x%04lx,0x%08lx,%p,%d,%p,%d): "
2204 "unimplemented flags: 0x%08lx\n",
2205 lcid,mapflags,srcstr,srclen,dststr,dstlen,mapflags);
2210 int (*f)(int)=identity;
2216 if (mapflags & LCMAP_UPPERCASE)
2218 else if (mapflags & LCMAP_LOWERCASE)
2220 for (i=0; i < srclen; i++)
2221 dststr[i] = (WCHAR) f(srcstr[i]);
2226 /***********************************************************************
2227 * CompareString16 (OLE2NLS.8)
2229 UINT16 WINAPI CompareString16(DWORD lcid,DWORD fdwStyle,
2230 LPCSTR s1,DWORD l1,LPCSTR s2,DWORD l2)
2232 return (UINT16)CompareString32A(lcid,fdwStyle,s1,l1,s2,l2);
2235 /******************************************************************************
2236 * CompareString32A [KERNEL32.143]
2237 * Compares two strings using locale
2241 * success: CSTR_LESS_THAN, CSTR_EQUAL, CSTR_GREATER_THAN
2246 * Defaults to a word sort, but uses a string sort if
2247 * SORT_STRINGSORT is set.
2248 * Calls SetLastError for ERROR_INVALID_FLAGS, ERROR_INVALID_PARAMETER.
2252 * This implementation ignores the locale
2256 * Quite inefficient.
2259 ULONG WINAPI CompareStringA(
2260 DWORD lcid, /* locale ID */
2261 DWORD fdwStyle, /* comparison-style options */
2262 LPCSTR s1, /* first string */
2263 DWORD l1, /* length of first string */
2264 LPCSTR s2, /* second string */
2265 DWORD l2) /* length of second string */
2267 int mapstring_flags;
2271 TRACE(ole,"%s and %s\n",
2272 debugstr_a (s1), debugstr_a (s2));
2274 if ( (s1==NULL) || (s2==NULL) )
2276 ERR(ole, "(s1=%s,s2=%s): Invalid NULL string\n", s1, s2);
2277 SetLastError(ERROR_INVALID_PARAMETER);
2281 if(fdwStyle & NORM_IGNORESYMBOLS)
2282 FIXME(ole, "IGNORESYMBOLS not supported\n");
2284 mapstring_flags = LCMAP_SORTKEY | fdwStyle ;
2285 len1 = LCMapString32A(lcid,mapstring_flags,s1,l1,NULL,0);
2286 len2 = LCMapString32A(lcid,mapstring_flags,s2,l2,NULL,0);
2288 if ((len1==0)||(len2==0))
2289 return 0; /* something wrong happened */
2291 sk1 = (LPSTR)HeapAlloc(GetProcessHeap(),0,len1);
2292 sk2 = (LPSTR)HeapAlloc(GetProcessHeap(),0,len2);
2293 if ( (!LCMapString32A(lcid,mapstring_flags,s1,l1,sk1,len1))
2294 || (!LCMapString32A(lcid,mapstring_flags,s2,l2,sk2,len2)) )
2296 ERR(ole,"Bug in LCmapString32A.\n");
2301 /* strcmp doesn't necessarily return -1, 0, or 1 */
2302 result = strcmp(sk1,sk2);
2304 HeapFree(GetProcessHeap(),0,sk1);
2305 HeapFree(GetProcessHeap(),0,sk2);
2312 /* must be greater, if we reach this point */
2316 /******************************************************************************
2317 * CompareString32W [KERNEL32.144]
2318 * This implementation ignores the locale
2319 * FIXME : Does only string sort. Should
2320 * be reimplemented the same way as CompareString32A.
2322 ULONG WINAPI CompareStringW(DWORD lcid, DWORD fdwStyle,
2323 LPCWSTR s1, DWORD l1, LPCWSTR s2,DWORD l2)
2326 if(fdwStyle & NORM_IGNORENONSPACE)
2327 FIXME(ole,"IGNORENONSPACE not supprted\n");
2328 if(fdwStyle & NORM_IGNORESYMBOLS)
2329 FIXME(ole,"IGNORESYMBOLS not supported\n");
2331 /* Is strcmp defaulting to string sort or to word sort?? */
2332 /* FIXME: Handle NORM_STRINGSORT */
2333 l1 = (l1==-1)?lstrlen32W(s1):l1;
2334 l2 = (l2==-1)?lstrlen32W(s2):l2;
2335 len = l1<l2 ? l1:l2;
2336 ret = (fdwStyle & NORM_IGNORECASE) ?
2337 lstrncmpi32W(s1,s2,len) : lstrncmp32W(s1,s2,len);
2338 /* not equal, return 1 or 3 */
2339 if(ret!=0) return ret+2;
2340 /* same len, return 2 */
2341 if(l1==l2) return 2;
2342 /* the longer one is lexically greater */
2343 return (l1<l2)? 1 : 3;
2347 /******************************************************************************
2348 * OLE_GetFormatA [Internal]
2351 * If datelen == 0, it should return the reguired string length.
2353 This function implements stuff for GetDateFormat() and
2356 d single-digit (no leading zero) day (of month)
2357 dd two-digit day (of month)
2358 ddd short day-of-week name
2359 dddd long day-of-week name
2360 M single-digit month
2362 MMM short month name
2363 MMMM full month name
2364 y two-digit year, no leading 0
2366 yyyy four-digit year
2368 h hours with no leading zero (12-hour)
2369 hh hours with full two digits
2370 H hours with no leading zero (24-hour)
2371 HH hours with full two digits
2372 m minutes with no leading zero
2373 mm minutes with full two digits
2374 s seconds with no leading zero
2375 ss seconds with full two digits
2376 t time marker (A or P)
2377 tt time marker (AM, PM)
2378 '' used to quote literal characters
2379 '' (within a quoted string) indicates a literal '
2381 These functions REQUIRE valid locale, date, and format.
2383 static ULONG OLE_GetFormatA(LCID locale,
2387 LPCSTR _format, /*in*/
2391 ULONG inpos, outpos;
2392 int count, type, inquote, Overflow;
2398 const char * _dgfmt[] = { "%d", "%02d" };
2399 const char ** dgfmt = _dgfmt - 1;
2401 /* report, for debugging */
2402 TRACE(ole, "(0x%lx,0x%lx, 0x%lx, time(d=%d,h=%d,m=%d,s=%d), fmt=%p \'%s\' , %p, len=%d)\n",
2403 locale, flags, tflags,
2404 xtime->wDay, xtime->wHour, xtime->wMinute, xtime->wSecond,
2405 _format, _format, date, datelen);
2408 FIXME(ole, "datelen = 0, returning 255\n");
2412 /* initalize state variables and output buffer */
2414 count = 0; inquote = 0; Overflow = 0;
2416 date[0] = buf[0] = '\0';
2418 strcpy(format,_format);
2420 /* alter the formatstring, while it works for all languages now in wine
2421 its possible that it fails when the time looks like ss:mm:hh as example*/
2422 if (tflags & (TIME_NOMINUTESORSECONDS))
2423 { if ((pos = strstr ( format, ":mm")))
2424 { memcpy ( pos, pos+3, strlen(format)-(pos-format)-2 );
2427 if (tflags & (TIME_NOSECONDS))
2428 { if ((pos = strstr ( format, ":ss")))
2429 { memcpy ( pos, pos+3, strlen(format)-(pos-format)-2 );
2433 for (inpos = 0;; inpos++) {
2434 /* 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]); */
2436 if (format[inpos] == '\'') {
2437 if (format[inpos+1] == '\'') {
2439 date[outpos++] = '\'';
2442 continue; /* we did nothing to the output */
2444 } else if (format[inpos] == '\0') {
2445 date[outpos++] = '\0';
2446 if (outpos > datelen) Overflow = 1;
2449 date[outpos++] = format[inpos];
2450 if (outpos > datelen) {
2452 date[outpos-1] = '\0'; /* this is the last place where
2453 it's safe to write */
2457 } else if ( (count && (format[inpos] != type))
2459 || (count == 2 && strchr("ghHmst", type)) )
2463 GetLocaleInfo32A(locale,
2465 + xtime->wDayOfWeek - 1,
2467 } else if (count == 3) {
2468 GetLocaleInfo32A(locale,
2469 LOCALE_SABBREVDAYNAME1
2470 + xtime->wDayOfWeek - 1,
2473 sprintf(buf, dgfmt[count], xtime->wDay);
2475 } else if (type == 'M') {
2477 GetLocaleInfo32A(locale,
2478 LOCALE_SABBREVMONTHNAME1
2479 + xtime->wMonth - 1,
2481 } else if (count == 4) {
2482 GetLocaleInfo32A(locale,
2484 + xtime->wMonth - 1,
2487 sprintf(buf, dgfmt[count], xtime->wMonth);
2489 } else if (type == 'y') {
2491 sprintf(buf, "%d", xtime->wYear);
2492 } else if (count == 3) {
2494 WARN(ole, "unknown format, c=%c, n=%d\n", type, count);
2496 sprintf(buf, dgfmt[count], xtime->wYear % 100);
2498 } else if (type == 'g') {
2500 FIXME(ole, "LOCALE_ICALENDARTYPE unimp.\n");
2504 WARN(ole, "unknown format, c=%c, n=%d\n", type, count);
2506 } else if (type == 'h') {
2507 /* gives us hours 1:00 -- 12:00 */
2508 sprintf(buf, dgfmt[count], (xtime->wHour-1)%12 +1);
2509 } else if (type == 'H') {
2511 sprintf(buf, dgfmt[count], xtime->wHour);
2512 } else if ( type == 'm') {
2513 sprintf(buf, dgfmt[count], xtime->wMinute);
2514 } else if ( type == 's') {
2515 sprintf(buf, dgfmt[count], xtime->wSecond);
2516 } else if (type == 't') {
2518 sprintf(buf, "%c", (xtime->wHour < 12) ? 'A' : 'P');
2519 } else if (count == 2) {
2520 /* sprintf(buf, "%s", (xtime->wHour < 12) ? "AM" : "PM"); */
2521 GetLocaleInfo32A(locale,
2523 ? LOCALE_S1159 : LOCALE_S2359,
2528 /* we need to check the next char in the format string
2529 again, no matter what happened */
2532 /* add the contents of buf to the output */
2533 buflen = strlen(buf);
2534 if (outpos + buflen < datelen) {
2535 date[outpos] = '\0'; /* for strcat to hook onto */
2539 date[outpos] = '\0';
2540 strncat(date, buf, datelen - outpos);
2541 date[datelen - 1] = '\0';
2542 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2543 WARN(ole, "insufficient buffer\n");
2547 /* reset the variables we used to keep track of this item */
2550 } else if (format[inpos] == '\0') {
2551 /* we can't check for this at the loop-head, because
2552 that breaks the printing of the last format-item */
2553 date[outpos] = '\0';
2556 /* continuing a code for an item */
2559 } else if (strchr("hHmstyMdg", format[inpos])) {
2560 type = format[inpos];
2563 } else if (format[inpos] == '\'') {
2567 date[outpos++] = format[inpos];
2569 /* now deal with a possible buffer overflow */
2570 if (outpos >= datelen) {
2571 date[datelen - 1] = '\0';
2572 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2578 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2581 /* finish it off with a string terminator */
2584 if (outpos > datelen-1) outpos = datelen-1;
2585 date[outpos] = '\0';
2587 TRACE(ole, "OLE_GetFormatA returns string '%s', len %d\n",
2592 /******************************************************************************
2593 * OLE_GetFormatW [INTERNAL]
2595 static ULONG OLE_GetFormatW(LCID locale, DWORD flags, DWORD tflags,
2598 LPWSTR output, ULONG outlen)
2600 ULONG inpos, outpos;
2601 int count, type=0, inquote;
2602 int Overflow; /* loop check */
2605 WCHAR arg0[] = {0}, arg1[] = {'%','d',0};
2606 WCHAR arg2[] = {'%','0','2','d',0};
2607 WCHAR *argarr[] = {arg0, arg1, arg2};
2608 int datevars=0, timevars=0;
2610 /* make a debug report */
2611 TRACE(ole, "args: 0x%lx, 0x%lx, 0x%lx, time(d=%d,h=%d,m=%d,s=%d), fmt:%s (at %p),
2612 %p with max len %d\n",
2613 locale, flags, tflags,
2614 xtime->wDay, xtime->wHour, xtime->wMinute, xtime->wSecond,
2615 debugstr_w(format), format, output, outlen);
2618 FIXME(ole, "outlen = 0, returning 255\n");
2622 /* initialize state variables */
2625 inquote = Overflow = 0;
2626 /* this is really just a sanity check */
2627 output[0] = buf[0] = 0;
2629 /* this loop is the core of the function */
2630 for (inpos = 0; /* we have several break points */ ; inpos++) {
2632 if (format[inpos] == (WCHAR) '\'') {
2633 if (format[inpos+1] == '\'') {
2635 output[outpos++] = '\'';
2640 } else if (format[inpos] == 0) {
2641 output[outpos++] = 0;
2642 if (outpos > outlen) Overflow = 1;
2643 break; /* normal exit (within a quote) */
2645 output[outpos++] = format[inpos]; /* copy input */
2646 if (outpos > outlen) {
2648 output[outpos-1] = 0;
2652 } else if ( (count && (format[inpos] != type))
2653 || ( (count==4 && type =='y') ||
2654 (count==4 && type =='M') ||
2655 (count==4 && type =='d') ||
2656 (count==2 && type =='g') ||
2657 (count==2 && type =='h') ||
2658 (count==2 && type =='H') ||
2659 (count==2 && type =='m') ||
2660 (count==2 && type =='s') ||
2661 (count==2 && type =='t') ) ) {
2664 GetLocaleInfo32W(locale,
2665 LOCALE_SDAYNAME1 + xtime->wDayOfWeek -1,
2666 buf, sizeof(buf)/sizeof(WCHAR) );
2667 } else if (count == 3) {
2668 GetLocaleInfo32W(locale,
2669 LOCALE_SABBREVDAYNAME1 +
2670 xtime->wDayOfWeek -1,
2671 buf, sizeof(buf)/sizeof(WCHAR) );
2673 wsnprintf32W(buf, 5, argarr[count], xtime->wDay );
2675 } else if (type == 'M') {
2677 GetLocaleInfo32W(locale, LOCALE_SMONTHNAME1 +
2678 xtime->wMonth -1, buf,
2679 sizeof(buf)/sizeof(WCHAR) );
2680 } else if (count == 3) {
2681 GetLocaleInfo32W(locale, LOCALE_SABBREVMONTHNAME1 +
2682 xtime->wMonth -1, buf,
2683 sizeof(buf)/sizeof(WCHAR) );
2685 wsnprintf32W(buf, 5, argarr[count], xtime->wMonth);
2687 } else if (type == 'y') {
2689 wsnprintf32W(buf, 6, argarr[1] /* "%d" */,
2691 } else if (count == 3) {
2692 lstrcpynAtoW(buf, "yyy", 5);
2694 wsnprintf32W(buf, 6, argarr[count],
2695 xtime->wYear % 100);
2697 } else if (type == 'g') {
2699 FIXME(ole, "LOCALE_ICALENDARTYPE unimplemented\n");
2700 lstrcpynAtoW(buf, "AD", 5);
2702 /* Win API sez we copy it verbatim */
2703 lstrcpynAtoW(buf, "g", 5);
2705 } else if (type == 'h') {
2706 /* hours 1:00-12:00 --- is this right? */
2707 wsnprintf32W(buf, 5, argarr[count],
2708 (xtime->wHour-1)%12 +1);
2709 } else if (type == 'H') {
2710 wsnprintf32W(buf, 5, argarr[count],
2712 } else if (type == 'm' ) {
2713 wsnprintf32W(buf, 5, argarr[count],
2715 } else if (type == 's' ) {
2716 wsnprintf32W(buf, 5, argarr[count],
2718 } else if (type == 't') {
2719 GetLocaleInfo32W(locale, (xtime->wHour < 12) ?
2720 LOCALE_S1159 : LOCALE_S2359,
2727 /* no matter what happened, we need to check this next
2728 character the next time we loop through */
2731 /* cat buf onto the output */
2732 outlen = lstrlen32W(buf);
2733 if (outpos + buflen < outlen) {
2734 output[outpos] = 0; /* a "hook" for strcat */
2735 lstrcat32W(output, buf);
2739 lstrcatn32W(output, buf, outlen - outpos);
2740 output[outlen - 1] = 0;
2742 break; /* Abnormal exit */
2745 /* reset the variables we used this time */
2748 } else if (format[inpos] == 0) {
2749 /* we can't check for this at the beginning, because that
2750 would keep us from printing a format spec that ended the
2753 break; /* NORMAL EXIT */
2755 /* how we keep track of the middle of a format spec */
2758 } else if ( (datevars && (format[inpos]=='d' ||
2759 format[inpos]=='M' ||
2760 format[inpos]=='y' ||
2761 format[inpos]=='g') ) ||
2762 (timevars && (format[inpos]=='H' ||
2763 format[inpos]=='h' ||
2764 format[inpos]=='m' ||
2765 format[inpos]=='s' ||
2766 format[inpos]=='t') ) ) {
2767 type = format[inpos];
2770 } else if (format[inpos] == '\'') {
2774 /* unquoted literals */
2775 output[outpos++] = format[inpos];
2780 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2781 WARN(ole, " buffer overflow\n");
2784 /* final string terminator and sanity check */
2786 if (outpos > outlen-1) outpos = outlen-1;
2787 output[outpos] = '0';
2789 TRACE(ole, " returning %s\n", debugstr_w(output));
2791 return (!Overflow) ? outlen : 0;
2796 /******************************************************************************
2797 * GetDateFormat32A [KERNEL32.310]
2798 * Makes an ASCII string of the date
2800 * This function uses format to format the date, or, if format
2801 * is NULL, uses the default for the locale. format is a string
2802 * of literal fields and characters as follows:
2804 * - d single-digit (no leading zero) day (of month)
2805 * - dd two-digit day (of month)
2806 * - ddd short day-of-week name
2807 * - dddd long day-of-week name
2808 * - M single-digit month
2809 * - MM two-digit month
2810 * - MMM short month name
2811 * - MMMM full month name
2812 * - y two-digit year, no leading 0
2813 * - yy two-digit year
2814 * - yyyy four-digit year
2818 ULONG WINAPI GetDateFormat32A(LCID locale,DWORD flags,
2820 LPCSTR format, LPSTR date,ULONG datelen)
2823 char format_buf[40];
2826 LPSYSTEMTIME thistime;
2830 TRACE(ole,"(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",
2831 locale,flags,xtime,format,date,datelen);
2834 locale = LOCALE_SYSTEM_DEFAULT;
2837 if (locale == LOCALE_SYSTEM_DEFAULT) {
2838 thislocale = GetSystemDefaultLCID();
2839 } else if (locale == LOCALE_USER_DEFAULT) {
2840 thislocale = GetUserDefaultLCID();
2842 thislocale = locale;
2845 if (xtime == NULL) {
2852 if (format == NULL) {
2853 GetLocaleInfo32A(thislocale, ((flags&DATE_LONGDATE)
2855 : LOCALE_SSHORTDATE),
2856 format_buf, sizeof(format_buf));
2857 thisformat = format_buf;
2859 thisformat = format;
2863 ret = OLE_GetFormatA(thislocale, flags, 0, thistime, thisformat,
2868 "GetDateFormat32A() returning %d, with data=%s\n",
2873 /******************************************************************************
2874 * GetDateFormat32W [KERNEL32.311]
2875 * Makes a Unicode string of the date
2877 * Acts the same as GetDateFormat32A(), except that it's Unicode.
2878 * Accepts & returns sizes as counts of Unicode characters.
2881 ULONG WINAPI GetDateFormat32W(LCID locale,DWORD flags,
2884 LPWSTR date, INT32 datelen)
2886 unsigned short datearr[] = {'1','9','9','4','-','1','-','1',0};
2888 FIXME(ole, "STUB (should call OLE_GetFormatW)\n");
2889 lstrcpyn32W(date, datearr, datelen);
2890 return ( datelen < 9) ? datelen : 9;
2895 /**************************************************************************
2896 * EnumDateFormats32A (KERNEL32.198)
2898 BOOL32 WINAPI EnumDateFormats32A(
2899 DATEFMT_ENUMPROC32A lpDateFmtEnumProc, LCID Locale, DWORD dwFlags)
2901 FIXME(ole, "Only US English supported\n");
2903 if(!lpDateFmtEnumProc)
2905 SetLastError(ERROR_INVALID_PARAMETER);
2911 case DATE_SHORTDATE:
2912 if(!(*lpDateFmtEnumProc)("M/d/yy")) return TRUE;
2913 if(!(*lpDateFmtEnumProc)("M/d/yyyy")) return TRUE;
2914 if(!(*lpDateFmtEnumProc)("MM/dd/yy")) return TRUE;
2915 if(!(*lpDateFmtEnumProc)("MM/dd/yyyy")) return TRUE;
2916 if(!(*lpDateFmtEnumProc)("yy/MM/dd")) return TRUE;
2917 if(!(*lpDateFmtEnumProc)("dd-MMM-yy")) return TRUE;
2920 if(!(*lpDateFmtEnumProc)("dddd, MMMM dd, yyyy")) return TRUE;
2921 if(!(*lpDateFmtEnumProc)("MMMM dd, yyyy")) return TRUE;
2922 if(!(*lpDateFmtEnumProc)("dddd, dd MMMM, yyyy")) return TRUE;
2923 if(!(*lpDateFmtEnumProc)("dd MMMM, yyyy")) return TRUE;
2926 FIXME(ole, "Unknown date format (%ld)\n", dwFlags);
2927 SetLastError(ERROR_INVALID_PARAMETER);
2932 /**************************************************************************
2933 * EnumDateFormats32W (KERNEL32.199)
2935 BOOL32 WINAPI EnumDateFormats32W(
2936 DATEFMT_ENUMPROC32W lpDateFmtEnumProc, LCID Locale, DWORD dwFlags)
2938 FIXME(ole, "(%p, %ld, %ld): stub\n", lpDateFmtEnumProc, Locale, dwFlags);
2939 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
2943 /**************************************************************************
2944 * EnumTimeFormats32A (KERNEL32.210)
2946 BOOL32 WINAPI EnumTimeFormats32A(
2947 TIMEFMT_ENUMPROC32A lpTimeFmtEnumProc, LCID Locale, DWORD dwFlags)
2949 FIXME(ole, "Only US English supported\n");
2951 if(!lpTimeFmtEnumProc)
2953 SetLastError(ERROR_INVALID_PARAMETER);
2959 FIXME(ole, "Unknown time format (%ld)\n", dwFlags);
2962 if(!(*lpTimeFmtEnumProc)("h:mm:ss tt")) return TRUE;
2963 if(!(*lpTimeFmtEnumProc)("hh:mm:ss tt")) return TRUE;
2964 if(!(*lpTimeFmtEnumProc)("H:mm:ss")) return TRUE;
2965 if(!(*lpTimeFmtEnumProc)("HH:mm:ss")) return TRUE;
2970 /**************************************************************************
2971 * EnumTimeFormats32W (KERNEL32.211)
2973 BOOL32 WINAPI EnumTimeFormats32W(
2974 TIMEFMT_ENUMPROC32W lpTimeFmtEnumProc, LCID Locale, DWORD dwFlags)
2976 FIXME(ole, "(%p,%ld,%ld): stub", lpTimeFmtEnumProc, Locale, dwFlags);
2977 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
2981 /**************************************************************************
2982 * GetNumberFormat32A (KERNEL32.355)
2984 INT32 WINAPI GetNumberFormat32A(LCID locale, DWORD dwflags,
2985 LPCSTR lpvalue, const NUMBERFMT32A * lpFormat,
2986 LPSTR lpNumberStr, int cchNumber)
2988 FIXME(file,"%s: stub, no reformating done\n",lpvalue);
2990 lstrcpyn32A( lpNumberStr, lpvalue, cchNumber );
2991 return cchNumber? lstrlen32A( lpNumberStr ) : 0;
2993 /**************************************************************************
2994 * GetNumberFormat32W (KERNEL32.xxx)
2996 INT32 WINAPI GetNumberFormat32W(LCID locale, DWORD dwflags,
2997 LPCWSTR lpvalue, const NUMBERFMT32W * lpFormat,
2998 LPWSTR lpNumberStr, int cchNumber)
3000 FIXME(file,"%s: stub, no reformating done\n",debugstr_w(lpvalue));
3002 lstrcpyn32W( lpNumberStr, lpvalue, cchNumber );
3003 return cchNumber? lstrlen32W( lpNumberStr ) : 0;
3005 /******************************************************************************
3006 * OLE2NLS_CheckLocale [intern]
3008 static LCID OLE2NLS_CheckLocale (LCID locale)
3011 { locale = LOCALE_SYSTEM_DEFAULT;
3014 if (locale == LOCALE_SYSTEM_DEFAULT)
3015 { return GetSystemDefaultLCID();
3017 else if (locale == LOCALE_USER_DEFAULT)
3018 { return GetUserDefaultLCID();
3024 /******************************************************************************
3025 * GetTimeFormat32A [KERNEL32.422]
3026 * Makes an ASCII string of the time
3028 * Formats date according to format, or locale default if format is
3029 * NULL. The format consists of literal characters and fields as follows:
3031 * h hours with no leading zero (12-hour)
3032 * hh hours with full two digits
3033 * H hours with no leading zero (24-hour)
3034 * HH hours with full two digits
3035 * m minutes with no leading zero
3036 * mm minutes with full two digits
3037 * s seconds with no leading zero
3038 * ss seconds with full two digits
3039 * t time marker (A or P)
3040 * tt time marker (AM, PM)
3044 GetTimeFormat32A(LCID locale, /* in */
3045 DWORD flags, /* in */
3046 LPSYSTEMTIME xtime, /* in */
3047 LPCSTR format, /* in */
3048 LPSTR timestr, /* out */
3049 INT32 timelen /* in */)
3050 { char format_buf[40];
3053 LPSYSTEMTIME thistime;
3055 DWORD thisflags=LOCALE_STIMEFORMAT; /* standart timeformat */
3058 TRACE(ole,"GetTimeFormat(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",locale,flags,xtime,format,timestr,timelen);
3060 thislocale = OLE2NLS_CheckLocale ( locale );
3062 if ( flags & (TIME_NOTIMEMARKER | TIME_FORCE24HOURFORMAT ))
3063 { FIXME(ole,"TIME_NOTIMEMARKER or TIME_FORCE24HOURFORMAT not implemented\n");
3066 flags &= (TIME_NOSECONDS | TIME_NOMINUTESORSECONDS); /* mask for OLE_GetFormatA*/
3069 { if (flags & LOCALE_NOUSEROVERRIDE) /*use system default*/
3070 { thislocale = GetSystemDefaultLCID();
3072 GetLocaleInfo32A(thislocale, thisflags, format_buf, sizeof(format_buf));
3073 thisformat = format_buf;
3076 { thisformat = format;
3079 if (xtime == NULL) /* NULL means use the current local time*/
3080 { GetSystemTime(&t);
3086 ret = OLE_GetFormatA(thislocale, thisflags, flags, thistime, thisformat,
3092 /******************************************************************************
3093 * GetTimeFormat32W [KERNEL32.423]
3094 * Makes a Unicode string of the time
3097 GetTimeFormat32W(LCID locale, /* in */
3098 DWORD flags, /* in */
3099 LPSYSTEMTIME xtime, /* in */
3100 LPCWSTR format, /* in */
3101 LPWSTR timestr, /* out */
3102 INT32 timelen /* in */)
3103 { WCHAR format_buf[40];
3106 LPSYSTEMTIME thistime;
3108 DWORD thisflags=LOCALE_STIMEFORMAT; /* standart timeformat */
3111 TRACE(ole,"GetTimeFormat(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",locale,flags,
3112 xtime,debugstr_w(format),timestr,timelen);
3114 thislocale = OLE2NLS_CheckLocale ( locale );
3116 if ( flags & (TIME_NOTIMEMARKER | TIME_FORCE24HOURFORMAT ))
3117 { FIXME(ole,"TIME_NOTIMEMARKER or TIME_FORCE24HOURFORMAT not implemented\n");
3120 flags &= (TIME_NOSECONDS | TIME_NOMINUTESORSECONDS); /* mask for OLE_GetFormatA*/
3123 { if (flags & LOCALE_NOUSEROVERRIDE) /*use system default*/
3124 { thislocale = GetSystemDefaultLCID();
3126 GetLocaleInfo32W(thislocale, thisflags, format_buf, 40);
3127 thisformat = format_buf;
3130 { thisformat = format;
3133 if (xtime == NULL) /* NULL means use the current local time*/
3134 { GetSystemTime(&t);
3141 ret = OLE_GetFormatW(thislocale, thisflags, flags, thistime, thisformat,