4 * Copyright 1995 Martin von Loewis
5 * Copyright 1998 David Lee Lambert
18 #include "debugtools.h"
22 DECLARE_DEBUG_CHANNEL(file)
23 DECLARE_DEBUG_CHANNEL(ole)
24 DECLARE_DEBUG_CHANNEL(string)
25 DECLARE_DEBUG_CHANNEL(win32)
27 struct NLS_langlocale {
29 struct NLS_localevar {
35 #define LANG_BEGIN(l,s) { MAKELANGID(l,s), {
37 #define LOCVAL(type,value) {type,value},
41 static const struct NLS_langlocale langlocales[] = {
42 /* add languages in numerical order of main language (last two digits)
43 * it is much easier to find the missing holes that way */
45 LANG_BEGIN (LANG_CATALAN, SUBLANG_DEFAULT) /*0x0403*/
46 #include "nls/cat.nls"
49 LANG_BEGIN (LANG_CZECH, SUBLANG_DEFAULT) /*0x0405*/
50 #include "nls/cze.nls"
53 LANG_BEGIN (LANG_DANISH, SUBLANG_DEFAULT) /*0x0406*/
54 #include "nls/dan.nls"
57 LANG_BEGIN (LANG_GERMAN, SUBLANG_GERMAN) /*0x0407*/
58 #include "nls/deu.nls"
60 LANG_BEGIN (LANG_GERMAN, SUBLANG_GERMAN_SWISS) /*0x0807*/
61 #include "nls/des.nls"
63 LANG_BEGIN (LANG_GERMAN, SUBLANG_GERMAN_AUSTRIAN) /*0x0C07*/
64 #include "nls/dea.nls"
66 LANG_BEGIN (LANG_GERMAN, SUBLANG_GERMAN_LUXEMBOURG) /*0x1007*/
67 #include "nls/del.nls"
69 LANG_BEGIN (LANG_GERMAN, SUBLANG_GERMAN_LIECHTENSTEIN) /*0x1407*/
70 #include "nls/dec.nls"
73 LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_US) /*0x0409*/
74 #include "nls/enu.nls"
76 LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_UK) /*0x0809*/
77 #include "nls/eng.nls"
79 LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_AUS) /*0x0C09*/
80 #include "nls/ena.nls"
82 LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_CAN) /*0x1009*/
83 #include "nls/enc.nls"
85 LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_NZ) /*0x1409*/
86 #include "nls/enz.nls"
88 LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_EIRE) /*0x1809*/
89 #include "nls/irl.nls"
91 LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_SAFRICA) /*0x1C09*/
92 #include "nls/ens.nls"
94 LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_JAMAICA) /*0x2009*/
95 #include "nls/enj.nls"
97 LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_CARRIBEAN) /*0x2409*/
98 #include "nls/enb.nls"
100 LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_BELIZE) /*0x2809*/
101 #include "nls/enl.nls"
103 LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_TRINIDAD) /*0x2C09*/
104 #include "nls/ent.nls"
107 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH) /*0x040a*/
108 #include "nls/esp.nls"
110 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_MEXICAN) /*0x080a*/
111 #include "nls/esm.nls"
113 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_MODERN) /*0x0C0a*/
114 #include "nls/esn.nls"
116 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_GUATEMALA) /*0x100a*/
117 #include "nls/esg.nls"
119 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_COSTARICA) /*0x140a*/
120 #include "nls/esc.nls"
122 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_PANAMA) /*0x180a*/
123 #include "nls/esa.nls"
125 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_DOMINICAN) /*0x1C0A*/
126 #include "nls/esd.nls"
128 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_VENEZUELA) /*0x200a*/
129 #include "nls/esv.nls"
131 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_COLOMBIA) /*0x240a*/
132 #include "nls/eso.nls"
134 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_PERU) /*0x280a*/
135 #include "nls/esr.nls"
137 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_ARGENTINA) /*0x2c0a*/
138 #include "nls/ess.nls"
140 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_ECUADOR) /*0x300a*/
141 #include "nls/esf.nls"
143 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_CHILE) /*0x340a*/
144 #include "nls/esl.nls"
146 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_URUGUAY) /*0x380a*/
147 #include "nls/esy.nls"
149 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_PARAGUAY) /*0x3c0a*/
150 #include "nls/esz.nls"
152 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_BOLIVIA) /*0x400a*/
153 #include "nls/esb.nls"
155 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_EL_SALVADOR) /*0x440a*/
156 #include "nls/ese.nls"
158 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_HONDURAS) /*0x480a*/
159 #include "nls/esh.nls"
161 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_NICARAGUA) /*0x4c0a*/
162 #include "nls/esi.nls"
164 LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_PUERTO_RICO) /*0x500a*/
165 #include "nls/esu.nls"
168 LANG_BEGIN (LANG_FINNISH, SUBLANG_DEFAULT) /*0x040B*/
169 #include "nls/fin.nls"
172 LANG_BEGIN (LANG_FRENCH, SUBLANG_FRENCH) /*0x040C*/
173 #include "nls/fra.nls"
175 LANG_BEGIN (LANG_FRENCH, SUBLANG_FRENCH_BELGIAN) /*0x080C*/
176 #include "nls/frb.nls"
178 LANG_BEGIN (LANG_FRENCH, SUBLANG_FRENCH_CANADIAN) /*0x0C0C*/
179 #include "nls/frc.nls"
181 LANG_BEGIN (LANG_FRENCH, SUBLANG_FRENCH_SWISS) /*0x100C*/
182 #include "nls/frs.nls"
184 LANG_BEGIN (LANG_FRENCH, SUBLANG_FRENCH_LUXEMBOURG) /*0x140C*/
185 #include "nls/frl.nls"
188 LANG_BEGIN (LANG_HUNGARIAN, SUBLANG_DEFAULT) /*0x040e*/
189 #include "nls/hun.nls"
192 LANG_BEGIN (LANG_ITALIAN, SUBLANG_ITALIAN) /*0x0410*/
193 #include "nls/ita.nls"
195 LANG_BEGIN (LANG_ITALIAN, SUBLANG_ITALIAN_SWISS) /*0x0810*/
196 #include "nls/its.nls"
199 LANG_BEGIN (LANG_KOREAN, SUBLANG_KOREAN) /*0x0412*/
200 #include "nls/kor.nls"
203 LANG_BEGIN (LANG_DUTCH, SUBLANG_DUTCH) /*0x0413*/
204 #include "nls/nld.nls"
206 LANG_BEGIN (LANG_DUTCH, SUBLANG_DUTCH_BELGIAN) /*0x0813*/
207 #include "nls/nlb.nls"
209 LANG_BEGIN (LANG_DUTCH, SUBLANG_DUTCH_SURINAM) /*0x0C13*/
210 #include "nls/nls.nls"
213 LANG_BEGIN (LANG_NORWEGIAN, SUBLANG_NORWEGIAN_BOKMAL) /*0x0414*/
214 #include "nls/nor.nls"
216 LANG_BEGIN (LANG_NORWEGIAN, SUBLANG_NORWEGIAN_NYNORSK) /*0x0814*/
217 #include "nls/non.nls"
220 LANG_BEGIN (LANG_POLISH, SUBLANG_DEFAULT) /*0x0415*/
221 #include "nls/plk.nls"
224 LANG_BEGIN (LANG_PORTUGUESE ,SUBLANG_PORTUGUESE_BRAZILIAN) /*0x0416*/
225 #include "nls/ptb.nls"
227 LANG_BEGIN (LANG_PORTUGUESE ,SUBLANG_PORTUGUESE) /*0x0816*/
228 #include "nls/ptg.nls"
231 LANG_BEGIN (LANG_RUSSIAN, SUBLANG_DEFAULT) /*0x419*/
232 #include "nls/rus.nls"
235 LANG_BEGIN (LANG_SLOVAK, SUBLANG_DEFAULT) /*0x041b*/
236 #include "nls/sky.nls"
239 LANG_BEGIN (LANG_SWEDISH, SUBLANG_SWEDISH) /*0x041d*/
240 #include "nls/sve.nls"
242 LANG_BEGIN (LANG_SWEDISH, SUBLANG_SWEDISH_FINLAND) /*0x081d*/
243 #include "nls/svf.nls"
246 LANG_BEGIN (LANG_THAI, SUBLANG_DEFAULT) /*0x41e*/
247 #include "nls/tha.nls"
250 LANG_BEGIN (LANG_ESPERANTO, SUBLANG_DEFAULT) /*0x048f*/
251 #include "nls/esperanto.nls"
254 LANG_BEGIN (LANG_WALON, SUBLANG_DEFAULT) /*0x0490*/
255 #include "nls/wal.nls"
260 /* Locale name to id map. used by EnumSystemLocales, GetLocalInfoA
261 * MUST contain all #defines from winnls.h
262 * last entry has NULL name, 0 id.
264 #define LOCALE_ENTRY(x) {#x,LOCALE_##x}
265 static struct tagLOCALE_NAME2ID {
268 } locale_name2id[]= {
269 LOCALE_ENTRY(ILANGUAGE),
270 LOCALE_ENTRY(SLANGUAGE),
271 LOCALE_ENTRY(SENGLANGUAGE),
272 LOCALE_ENTRY(SABBREVLANGNAME),
273 LOCALE_ENTRY(SNATIVELANGNAME),
274 LOCALE_ENTRY(ICOUNTRY),
275 LOCALE_ENTRY(SCOUNTRY),
276 LOCALE_ENTRY(SENGCOUNTRY),
277 LOCALE_ENTRY(SABBREVCTRYNAME),
278 LOCALE_ENTRY(SNATIVECTRYNAME),
279 LOCALE_ENTRY(IDEFAULTLANGUAGE),
280 LOCALE_ENTRY(IDEFAULTCOUNTRY),
281 LOCALE_ENTRY(IDEFAULTCODEPAGE),
282 LOCALE_ENTRY(IDEFAULTANSICODEPAGE),
283 LOCALE_ENTRY(IDEFAULTMACCODEPAGE),
285 LOCALE_ENTRY(IMEASURE),
286 LOCALE_ENTRY(SDECIMAL),
287 LOCALE_ENTRY(STHOUSAND),
288 LOCALE_ENTRY(SGROUPING),
289 LOCALE_ENTRY(IDIGITS),
290 LOCALE_ENTRY(ILZERO),
291 LOCALE_ENTRY(INEGNUMBER),
292 LOCALE_ENTRY(SNATIVEDIGITS),
293 LOCALE_ENTRY(SCURRENCY),
294 LOCALE_ENTRY(SINTLSYMBOL),
295 LOCALE_ENTRY(SMONDECIMALSEP),
296 LOCALE_ENTRY(SMONTHOUSANDSEP),
297 LOCALE_ENTRY(SMONGROUPING),
298 LOCALE_ENTRY(ICURRDIGITS),
299 LOCALE_ENTRY(IINTLCURRDIGITS),
300 LOCALE_ENTRY(ICURRENCY),
301 LOCALE_ENTRY(INEGCURR),
304 LOCALE_ENTRY(SSHORTDATE),
305 LOCALE_ENTRY(SLONGDATE),
306 LOCALE_ENTRY(STIMEFORMAT),
308 LOCALE_ENTRY(ILDATE),
310 LOCALE_ENTRY(ITIMEMARKPOSN),
311 LOCALE_ENTRY(ICENTURY),
312 LOCALE_ENTRY(ITLZERO),
313 LOCALE_ENTRY(IDAYLZERO),
314 LOCALE_ENTRY(IMONLZERO),
317 LOCALE_ENTRY(ICALENDARTYPE),
318 LOCALE_ENTRY(IOPTIONALCALENDAR),
319 LOCALE_ENTRY(IFIRSTDAYOFWEEK),
320 LOCALE_ENTRY(IFIRSTWEEKOFYEAR),
321 LOCALE_ENTRY(SDAYNAME1),
322 LOCALE_ENTRY(SDAYNAME2),
323 LOCALE_ENTRY(SDAYNAME3),
324 LOCALE_ENTRY(SDAYNAME4),
325 LOCALE_ENTRY(SDAYNAME5),
326 LOCALE_ENTRY(SDAYNAME6),
327 LOCALE_ENTRY(SDAYNAME7),
328 LOCALE_ENTRY(SABBREVDAYNAME1),
329 LOCALE_ENTRY(SABBREVDAYNAME2),
330 LOCALE_ENTRY(SABBREVDAYNAME3),
331 LOCALE_ENTRY(SABBREVDAYNAME4),
332 LOCALE_ENTRY(SABBREVDAYNAME5),
333 LOCALE_ENTRY(SABBREVDAYNAME6),
334 LOCALE_ENTRY(SABBREVDAYNAME7),
335 LOCALE_ENTRY(SMONTHNAME1),
336 LOCALE_ENTRY(SMONTHNAME2),
337 LOCALE_ENTRY(SMONTHNAME3),
338 LOCALE_ENTRY(SMONTHNAME4),
339 LOCALE_ENTRY(SMONTHNAME5),
340 LOCALE_ENTRY(SMONTHNAME6),
341 LOCALE_ENTRY(SMONTHNAME7),
342 LOCALE_ENTRY(SMONTHNAME8),
343 LOCALE_ENTRY(SMONTHNAME9),
344 LOCALE_ENTRY(SMONTHNAME10),
345 LOCALE_ENTRY(SMONTHNAME11),
346 LOCALE_ENTRY(SMONTHNAME12),
347 LOCALE_ENTRY(SMONTHNAME13),
348 LOCALE_ENTRY(SABBREVMONTHNAME1),
349 LOCALE_ENTRY(SABBREVMONTHNAME2),
350 LOCALE_ENTRY(SABBREVMONTHNAME3),
351 LOCALE_ENTRY(SABBREVMONTHNAME4),
352 LOCALE_ENTRY(SABBREVMONTHNAME5),
353 LOCALE_ENTRY(SABBREVMONTHNAME6),
354 LOCALE_ENTRY(SABBREVMONTHNAME7),
355 LOCALE_ENTRY(SABBREVMONTHNAME8),
356 LOCALE_ENTRY(SABBREVMONTHNAME9),
357 LOCALE_ENTRY(SABBREVMONTHNAME10),
358 LOCALE_ENTRY(SABBREVMONTHNAME11),
359 LOCALE_ENTRY(SABBREVMONTHNAME12),
360 LOCALE_ENTRY(SABBREVMONTHNAME13),
361 LOCALE_ENTRY(SPOSITIVESIGN),
362 LOCALE_ENTRY(SNEGATIVESIGN),
363 LOCALE_ENTRY(IPOSSIGNPOSN),
364 LOCALE_ENTRY(INEGSIGNPOSN),
365 LOCALE_ENTRY(IPOSSYMPRECEDES),
366 LOCALE_ENTRY(IPOSSEPBYSPACE),
367 LOCALE_ENTRY(INEGSYMPRECEDES),
368 LOCALE_ENTRY(INEGSEPBYSPACE),
369 LOCALE_ENTRY(FONTSIGNATURE),
370 LOCALE_ENTRY(SISO639LANGNAME),
371 LOCALE_ENTRY(SISO3166CTRYNAME),
375 const struct map_lcid2str {
377 const char *langname;
379 {0x0401,"Arabic (Saudi Arabia)"},
380 {0x0801,"Arabic (Iraq)"},
381 {0x0c01,"Arabic (Egypt)"},
382 {0x1001,"Arabic (Libya)"},
383 {0x1401,"Arabic (Algeria)"},
384 {0x1801,"Arabic (Morocco)"},
385 {0x1c01,"Arabic (Tunisia)"},
386 {0x2001,"Arabic (Oman)"},
387 {0x2401,"Arabic (Yemen)"},
388 {0x2801,"Arabic (Syria)"},
389 {0x2c01,"Arabic (Jordan)"},
390 {0x3001,"Arabic (Lebanon)"},
391 {0x3401,"Arabic (Kuwait)"},
392 {0x3801,"Arabic (United Arab Emirates)"},
393 {0x3c01,"Arabic (Bahrain)"},
394 {0x4001,"Arabic (Qatar)"},
395 {0x0402,"Bulgarian"},
397 {0x0404,"Chinese (Taiwan)"},
398 {0x0804,"Chinese (People's Republic of China)"},
399 {0x0c04,"Chinese (Hong Kong)"},
400 {0x1004,"Chinese (Singapore)"},
401 {0x1404,"Chinese (Macau)"},
404 {0x0407,"German (Germany)"},
405 {0x0807,"German (Switzerland)"},
406 {0x0c07,"German (Austria)"},
407 {0x1007,"German (Luxembourg)"},
408 {0x1407,"German (Liechtenstein)"},
410 {0x0409,"English (United States)"},
411 {0x0809,"English (United Kingdom)"},
412 {0x0c09,"English (Australia)"},
413 {0x1009,"English (Canada)"},
414 {0x1409,"English (New Zealand)"},
415 {0x1809,"English (Ireland)"},
416 {0x1c09,"English (South Africa)"},
417 {0x2009,"English (Jamaica)"},
418 {0x2409,"English (Caribbean)"},
419 {0x2809,"English (Belize)"},
420 {0x2c09,"English (Trinidad)"},
421 {0x3009,"English (Zimbabwe)"},
422 {0x3409,"English (Philippines)"},
423 {0x040a,"Spanish (Spain, traditional sorting)"},
424 {0x080a,"Spanish (Mexico)"},
425 {0x0c0a,"Spanish (Spain, international sorting)"},
426 {0x100a,"Spanish (Guatemala)"},
427 {0x140a,"Spanish (Costa Rica)"},
428 {0x180a,"Spanish (Panama)"},
429 {0x1c0a,"Spanish (Dominican Republic)"},
430 {0x200a,"Spanish (Venezuela)"},
431 {0x240a,"Spanish (Colombia)"},
432 {0x280a,"Spanish (Peru)"},
433 {0x2c0a,"Spanish (Argentina)"},
434 {0x300a,"Spanish (Ecuador)"},
435 {0x340a,"Spanish (Chile)"},
436 {0x380a,"Spanish (Uruguay)"},
437 {0x3c0a,"Spanish (Paraguay)"},
438 {0x400a,"Spanish (Bolivia)"},
439 {0x440a,"Spanish (El Salvador)"},
440 {0x480a,"Spanish (Honduras)"},
441 {0x4c0a,"Spanish (Nicaragua)"},
442 {0x500a,"Spanish (Puerto Rico)"},
444 {0x040c,"French (France)"},
445 {0x080c,"French (Belgium)"},
446 {0x0c0c,"French (Canada)"},
447 {0x100c,"French (Switzerland)"},
448 {0x140c,"French (Luxembourg)"},
449 {0x180c,"French (Monaco)"},
451 {0x040e,"Hungarian"},
452 {0x040f,"Icelandic"},
453 {0x0410,"Italian (Italy)"},
454 {0x0810,"Italian (Switzerland)"},
456 {0x0412,"Korean (Wansung)"},
457 {0x0812,"Korean (Johab)"},
458 {0x0413,"Dutch (Netherlands)"},
459 {0x0813,"Dutch (Belgium)"},
460 {0x0414,"Norwegian (Bokmal)"},
461 {0x0814,"Norwegian (Nynorsk)"},
463 {0x0416,"Portuguese (Brazil)"},
464 {0x0816,"Portuguese (Portugal)"},
465 {0x0417,"Rhaeto Romanic"},
467 {0x0818,"Moldavian"},
468 {0x0419,"Russian (Russia)"},
469 {0x0819,"Russian (Moldavia)"},
471 {0x081a,"Serbian (latin)"},
472 {0x0c1a,"Serbian (cyrillic)"},
475 {0x041d,"Swedish (Sweden)"},
476 {0x081d,"Swedish (Finland)"},
480 {0x0421,"Indonesian"},
481 {0x0422,"Ukrainian"},
482 {0x0423,"Belarusian"},
486 {0x0427,"Lithuanian (modern)"},
487 {0x0827,"Lithuanian (classic)"},
490 {0x042a,"Vietnamese"},
492 {0x042c,"Azeri (latin)"},
493 {0x082c,"Azeri (cyrillic)"},
496 {0x042f,"Macedonian"},
503 {0x0436,"Afrikaans"},
509 {0x043c,"Irish gaelic"},
510 {0x083c,"Scottish gaelic"},
511 {0x043e,"Malay (Malaysia)"},
512 {0x083e,"Malay (Brunei Darussalam)"},
515 {0x0443,"Uzbek (latin)"},
516 {0x0843,"Uzbek (cyrillic)"},
525 {0x044c,"Malayalam"},
530 {0x048f,"Esperanto"}, /* Non official */
531 {0x0490,"Walon"}, /* Non official */
535 {0x0402,"Bulgarisch"},
536 {0x0403,"Katalanisch"},
537 {0x0404,"Traditionales Chinesisch"},
538 {0x0405,"Tschecisch"},
541 {0x0408,"Griechisch"},
542 {0x0409,"Amerikanisches Englisch"},
543 {0x040A,"Kastilisches Spanisch"},
545 {0x040C,"Franzvsisch"},
546 {0x040D,"Hebrdisch"},
547 {0x040E,"Ungarisch"},
548 {0x040F,"Isldndisch"},
549 {0x0410,"Italienisch"},
550 {0x0411,"Japanisch"},
551 {0x0412,"Koreanisch"},
552 {0x0413,"Niederldndisch"},
553 {0x0414,"Norwegisch-Bokmal"},
555 {0x0416,"Brasilianisches Portugiesisch"},
556 {0x0417,"Rdtoromanisch"},
557 {0x0418,"Rumdnisch"},
559 {0x041A,"Kroatoserbisch (lateinisch)"},
560 {0x041B,"Slowenisch"},
561 {0x041C,"Albanisch"},
562 {0x041D,"Schwedisch"},
567 {0x0804,"Vereinfachtes Chinesisch"},
568 {0x0807,"Schweizerdeutsch"},
569 {0x0809,"Britisches Englisch"},
570 {0x080A,"Mexikanisches Spanisch"},
571 {0x080C,"Belgisches Franzvsisch"},
572 {0x0810,"Schweizerisches Italienisch"},
573 {0x0813,"Belgisches Niederldndisch"},
574 {0x0814,"Norgwegisch-Nynorsk"},
575 {0x0816,"Portugiesisch"},
576 {0x081A,"Serbokratisch (kyrillisch)"},
577 {0x0C1C,"Kanadisches Franzvsisch"},
578 {0x100C,"Schweizerisches Franzvsisch"},
579 {0x0000,"Unbekannt"},
582 /***********************************************************************
583 * GetUserDefaultLCID (OLE2NLS.1)
585 LCID WINAPI GetUserDefaultLCID()
587 return MAKELCID( GetUserDefaultLangID() , SORT_DEFAULT );
590 /***********************************************************************
591 * GetSystemDefaultLCID (OLE2NLS.2)
593 LCID WINAPI GetSystemDefaultLCID()
595 return GetUserDefaultLCID();
598 /***********************************************************************
599 * GetUserDefaultLangID (OLE2NLS.3)
601 LANGID WINAPI GetUserDefaultLangID()
603 /* caching result, if defined from environment, which should (?) not change during a WINE session */
604 static LANGID userLCID = 0;
605 if (Options.language) {
606 return Languages[Options.language].langid;
611 char *lang,*country,*charset,*dialect,*next;
614 buf=getenv("LANGUAGE");
615 if (!buf) buf=getenv("LANG");
616 if (!buf) buf=getenv("LC_ALL");
617 if (!buf) buf=getenv("LC_MESSAGES");
618 if (!buf) buf=getenv("LC_CTYPE");
619 if (!buf) return userLCID = MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT );
621 if (!strcmp(buf,"POSIX") || !strcmp(buf,"C")) {
622 return MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT );
628 next=strchr(lang,':'); if (next) *next++='\0';
629 dialect=strchr(lang,'@'); if (dialect) *dialect++='\0';
630 charset=strchr(lang,'.'); if (charset) *charset++='\0';
631 country=strchr(lang,'_'); if (country) *country++='\0';
633 ret=MAIN_GetLanguageID(lang, country, charset, dialect);
637 } while (lang && !ret);
639 /* FIXME : are strings returned by getenv() to be free()'ed ? */
640 userLCID = (LANGID)ret;
645 /***********************************************************************
646 * GetSystemDefaultLangID (OLE2NLS.4)
648 LANGID WINAPI GetSystemDefaultLangID()
650 return GetUserDefaultLangID();
653 /******************************************************************************
654 * GetLocaleInfo16 [OLE2NLS.5]
655 * Is the last parameter really WORD for Win16?
657 INT16 WINAPI GetLocaleInfo16(LCID lcid,LCTYPE LCType,LPSTR buf,INT16 len)
659 return GetLocaleInfoA(lcid,LCType,buf,len);
661 /******************************************************************************
662 * ConvertDefaultLocale32 [KERNEL32.147]
664 LCID WINAPI ConvertDefaultLocale32 (LCID lcid)
666 { case LOCALE_SYSTEM_DEFAULT:
667 return GetSystemDefaultLCID();
668 case LOCALE_USER_DEFAULT:
669 return GetUserDefaultLCID();
671 return MAKELCID (LANG_NEUTRAL, SUBLANG_NEUTRAL);
673 return MAKELANGID( PRIMARYLANGID(lcid), SUBLANG_NEUTRAL);
675 /******************************************************************************
676 * GetLocaleInfo32A [KERNEL32.342]
679 * LANG_NEUTRAL is equal to LOCALE_SYSTEM_DEFAULT
681 * MS online documentation states that the string returned is NULL terminated
682 * except for LOCALE_FONTSIGNATURE which "will return a non-NULL
683 * terminated string".
685 INT WINAPI GetLocaleInfoA(LCID lcid,LCTYPE LCType,LPSTR buf,INT len)
691 TRACE_(ole)("(lcid=0x%lx,lctype=0x%lx,%p,%x)\n",lcid,LCType,buf,len);
693 if (len && (! buf) ) {
694 SetLastError(ERROR_INSUFFICIENT_BUFFER);
698 if (lcid ==0 || lcid == LANG_SYSTEM_DEFAULT || (LCType & LOCALE_NOUSEROVERRIDE) ) /* 0x00, 0x400 */
700 lcid = GetSystemDefaultLCID();
702 else if (lcid == LANG_USER_DEFAULT) /*0x800*/
704 lcid = GetUserDefaultLCID();
706 LCType &= ~(LOCALE_NOUSEROVERRIDE|LOCALE_USE_CP_ACP);
708 /* As an option, we could obtain the value from win.ini.
709 This would not match the Wine compile-time option.
710 Also, not all identifiers are available from win.ini */
712 /* If we are through all of this, retLen should not be zero anymore.
713 If it is, the value is not supported */
715 while (locale_name2id[i].name!=NULL) {
716 if (LCType == locale_name2id[i].id) {
717 retString = locale_name2id[i].name;
723 FIXME_(ole)("Unkown LC type %lX\n",LCType);
728 for (i=0;(i<3 && !found);i++) {
731 for (j=0;j<sizeof(langlocales)/sizeof(langlocales[0]);j++) {
732 if (langlocales[j].lang == lang) {
735 for (k=0;k<sizeof(langlocales[j].locvars)/sizeof(langlocales[j].locvars[0]) && (langlocales[j].locvars[k].type);k++) {
736 if (langlocales[j].locvars[k].type == LCType) {
738 retString = langlocales[j].locvars[k].val;
746 /* language not found, try without a sublanguage*/
747 if (i==1) lang=MAKELANGID( PRIMARYLANGID(lang), SUBLANG_DEFAULT);
748 /* mask the LC Value */
749 if (i==2) LCType &= 0xfff;
753 ERR_(ole)("'%s' not supported for your language (%04X).\n",
754 retString,(WORD)lcid);
755 SetLastError(ERROR_INVALID_PARAMETER);
758 /* a FONTSIGNATURE is not a string, just 6 DWORDs */
759 if (LCType == LOCALE_FONTSIGNATURE) {
761 memcpy(buf, retString, (len<=sizeof(FONTSIGNATURE))?len:sizeof(FONTSIGNATURE));
762 return sizeof(FONTSIGNATURE);
764 /* if len=0 return only the length, don't touch the buffer*/
765 if (len) lstrcpynA(buf,retString,len);
766 return strlen(retString)+1;
769 /******************************************************************************
770 * GetLocaleInfo32W [KERNEL32.343]
773 * MS documentation states that len "specifies the size, in bytes (ANSI version)
774 * or characters (Unicode version), of" wbuf. Thus the number returned is
775 * the same between GetLocaleInfo32W and GetLocaleInfo32A.
777 INT WINAPI GetLocaleInfoW(LCID lcid,LCTYPE LCType,LPWSTR wbuf,INT len)
781 if (len && (! wbuf) )
782 { SetLastError(ERROR_INSUFFICIENT_BUFFER);
786 abuf = (LPSTR)HeapAlloc(GetProcessHeap(),0,len);
787 wlen = GetLocaleInfoA(lcid, LCType, abuf, len);
789 if (wlen && len) /* if len=0 return only the length*/
790 lstrcpynAtoW(wbuf,abuf,len);
792 HeapFree(GetProcessHeap(),0,abuf);
796 /******************************************************************************
797 * SetLocaleInfoA [KERNEL32.656]
799 BOOL16 WINAPI SetLocaleInfoA(DWORD lcid, DWORD lctype, LPCSTR data)
801 FIXME_(ole)("(%ld,%ld,%s): stub\n",lcid,lctype,data);
805 /******************************************************************************
806 * IsValidLocale [KERNEL32.489]
808 BOOL WINAPI IsValidLocale(LCID lcid,DWORD flags)
810 /* we support ANY language. Well, at least say that...*/
814 /******************************************************************************
815 * EnumSystemLocales32W [KERNEL32.209]
817 BOOL WINAPI EnumSystemLocalesW( LOCALE_ENUMPROCW lpfnLocaleEnum,
825 TRACE_(win32)("(%p,%08lx)\n",lpfnLocaleEnum,flags );
826 /* see if we can reuse the Win95 registry entries.... */
827 if (ERROR_SUCCESS==RegOpenKeyA(HKEY_LOCAL_MACHINE,"System\\CurrentControlSet\\control\\Nls\\Locale\\",&xhkey)) {
830 if (ERROR_SUCCESS!=RegEnumKeyW(xhkey,i,buffer,sizeof(buffer)))
832 if (!lpfnLocaleEnum(buffer))
841 while (languages[i].langid!=0)
846 sprintf(xbuffer,"%08lx",(DWORD)languages[i].langid);
848 cp = HEAP_strdupAtoW( GetProcessHeap(), 0, xbuffer );
849 ret = lpfnLocaleEnum(cp);
850 HeapFree( GetProcessHeap(), 0, cp );
857 /******************************************************************************
858 * EnumSystemLocales32A [KERNEL32.208]
860 BOOL WINAPI EnumSystemLocalesA(LOCALE_ENUMPROCA lpfnLocaleEnum,
867 TRACE_(win32)("(%p,%08lx)\n",
870 if (ERROR_SUCCESS==RegOpenKeyA(HKEY_LOCAL_MACHINE,"System\\CurrentControlSet\\control\\Nls\\Locale\\",&xhkey)) {
873 if (ERROR_SUCCESS!=RegEnumKeyA(xhkey,i,buffer,sizeof(buffer)))
875 if (!lpfnLocaleEnum(buffer))
883 while (languages[i].langid!=0) {
884 sprintf(buffer,"%08lx",(DWORD)languages[i].langid);
885 if (!lpfnLocaleEnum(buffer))
892 static const unsigned char CT_CType2_LUT[] = {
893 C2_NOTAPPLICABLE, /* - 0 */
894 C2_NOTAPPLICABLE, /* - 1 */
895 C2_NOTAPPLICABLE, /* - 2 */
896 C2_NOTAPPLICABLE, /* - 3 */
897 C2_NOTAPPLICABLE, /* - 4 */
898 C2_NOTAPPLICABLE, /* - 5 */
899 C2_NOTAPPLICABLE, /* - 6 */
900 C2_NOTAPPLICABLE, /* - 7 */
901 C2_NOTAPPLICABLE, /* - 8 */
902 C2_SEGMENTSEPARATOR, /* - 9 */
903 C2_NOTAPPLICABLE, /* - 10 */
904 C2_NOTAPPLICABLE, /* - 11 */
905 C2_NOTAPPLICABLE, /* - 12 */
906 C2_NOTAPPLICABLE, /* - 13 */
907 C2_NOTAPPLICABLE, /* - 14 */
908 C2_NOTAPPLICABLE, /* - 15 */
909 C2_NOTAPPLICABLE, /* - 16 */
910 C2_NOTAPPLICABLE, /* - 17 */
911 C2_NOTAPPLICABLE, /* - 18 */
912 C2_NOTAPPLICABLE, /* - 19 */
913 C2_NOTAPPLICABLE, /* - 20 */
914 C2_NOTAPPLICABLE, /* - 21 */
915 C2_NOTAPPLICABLE, /* - 22 */
916 C2_NOTAPPLICABLE, /* - 23 */
917 C2_NOTAPPLICABLE, /* - 24 */
918 C2_NOTAPPLICABLE, /* - 25 */
919 C2_NOTAPPLICABLE, /* - 26 */
920 C2_NOTAPPLICABLE, /* - 27 */
921 C2_NOTAPPLICABLE, /* - 28 */
922 C2_NOTAPPLICABLE, /* - 29 */
923 C2_NOTAPPLICABLE, /* - 30 */
924 C2_NOTAPPLICABLE, /* - 31 */
925 C2_WHITESPACE, /* - 32 */
926 C2_OTHERNEUTRAL, /* ! - 33 */
927 C2_OTHERNEUTRAL, /* " - 34 */ /* " */
928 C2_EUROPETERMINATOR, /* # - 35 */
929 C2_EUROPETERMINATOR, /* $ - 36 */
930 C2_EUROPETERMINATOR, /* % - 37 */
931 C2_LEFTTORIGHT, /* & - 38 */
932 C2_OTHERNEUTRAL, /* ' - 39 */
933 C2_OTHERNEUTRAL, /* ( - 40 */
934 C2_OTHERNEUTRAL, /* ) - 41 */
935 C2_OTHERNEUTRAL, /* * - 42 */
936 C2_EUROPETERMINATOR, /* + - 43 */
937 C2_COMMONSEPARATOR, /* , - 44 */
938 C2_EUROPETERMINATOR, /* - - 45 */
939 C2_EUROPESEPARATOR, /* . - 46 */
940 C2_EUROPESEPARATOR, /* / - 47 */
941 C2_EUROPENUMBER, /* 0 - 48 */
942 C2_EUROPENUMBER, /* 1 - 49 */
943 C2_EUROPENUMBER, /* 2 - 50 */
944 C2_EUROPENUMBER, /* 3 - 51 */
945 C2_EUROPENUMBER, /* 4 - 52 */
946 C2_EUROPENUMBER, /* 5 - 53 */
947 C2_EUROPENUMBER, /* 6 - 54 */
948 C2_EUROPENUMBER, /* 7 - 55 */
949 C2_EUROPENUMBER, /* 8 - 56 */
950 C2_EUROPENUMBER, /* 9 - 57 */
951 C2_COMMONSEPARATOR, /* : - 58 */
952 C2_OTHERNEUTRAL, /* ; - 59 */
953 C2_OTHERNEUTRAL, /* < - 60 */
954 C2_OTHERNEUTRAL, /* = - 61 */
955 C2_OTHERNEUTRAL, /* > - 62 */
956 C2_OTHERNEUTRAL, /* ? - 63 */
957 C2_LEFTTORIGHT, /* @ - 64 */
958 C2_LEFTTORIGHT, /* A - 65 */
959 C2_LEFTTORIGHT, /* B - 66 */
960 C2_LEFTTORIGHT, /* C - 67 */
961 C2_LEFTTORIGHT, /* D - 68 */
962 C2_LEFTTORIGHT, /* E - 69 */
963 C2_LEFTTORIGHT, /* F - 70 */
964 C2_LEFTTORIGHT, /* G - 71 */
965 C2_LEFTTORIGHT, /* H - 72 */
966 C2_LEFTTORIGHT, /* I - 73 */
967 C2_LEFTTORIGHT, /* J - 74 */
968 C2_LEFTTORIGHT, /* K - 75 */
969 C2_LEFTTORIGHT, /* L - 76 */
970 C2_LEFTTORIGHT, /* M - 77 */
971 C2_LEFTTORIGHT, /* N - 78 */
972 C2_LEFTTORIGHT, /* O - 79 */
973 C2_LEFTTORIGHT, /* P - 80 */
974 C2_LEFTTORIGHT, /* Q - 81 */
975 C2_LEFTTORIGHT, /* R - 82 */
976 C2_LEFTTORIGHT, /* S - 83 */
977 C2_LEFTTORIGHT, /* T - 84 */
978 C2_LEFTTORIGHT, /* U - 85 */
979 C2_LEFTTORIGHT, /* V - 86 */
980 C2_LEFTTORIGHT, /* W - 87 */
981 C2_LEFTTORIGHT, /* X - 88 */
982 C2_LEFTTORIGHT, /* Y - 89 */
983 C2_LEFTTORIGHT, /* Z - 90 */
984 C2_OTHERNEUTRAL, /* [ - 91 */
985 C2_OTHERNEUTRAL, /* \ - 92 */
986 C2_OTHERNEUTRAL, /* ] - 93 */
987 C2_OTHERNEUTRAL, /* ^ - 94 */
988 C2_OTHERNEUTRAL, /* _ - 95 */
989 C2_OTHERNEUTRAL, /* ` - 96 */
990 C2_LEFTTORIGHT, /* a - 97 */
991 C2_LEFTTORIGHT, /* b - 98 */
992 C2_LEFTTORIGHT, /* c - 99 */
993 C2_LEFTTORIGHT, /* d - 100 */
994 C2_LEFTTORIGHT, /* e - 101 */
995 C2_LEFTTORIGHT, /* f - 102 */
996 C2_LEFTTORIGHT, /* g - 103 */
997 C2_LEFTTORIGHT, /* h - 104 */
998 C2_LEFTTORIGHT, /* i - 105 */
999 C2_LEFTTORIGHT, /* j - 106 */
1000 C2_LEFTTORIGHT, /* k - 107 */
1001 C2_LEFTTORIGHT, /* l - 108 */
1002 C2_LEFTTORIGHT, /* m - 109 */
1003 C2_LEFTTORIGHT, /* n - 110 */
1004 C2_LEFTTORIGHT, /* o - 111 */
1005 C2_LEFTTORIGHT, /* p - 112 */
1006 C2_LEFTTORIGHT, /* q - 113 */
1007 C2_LEFTTORIGHT, /* r - 114 */
1008 C2_LEFTTORIGHT, /* s - 115 */
1009 C2_LEFTTORIGHT, /* t - 116 */
1010 C2_LEFTTORIGHT, /* u - 117 */
1011 C2_LEFTTORIGHT, /* v - 118 */
1012 C2_LEFTTORIGHT, /* w - 119 */
1013 C2_LEFTTORIGHT, /* x - 120 */
1014 C2_LEFTTORIGHT, /* y - 121 */
1015 C2_LEFTTORIGHT, /* z - 122 */
1016 C2_OTHERNEUTRAL, /* { - 123 */
1017 C2_OTHERNEUTRAL, /* | - 124 */
1018 C2_OTHERNEUTRAL, /* } - 125 */
1019 C2_OTHERNEUTRAL, /* ~ - 126 */
1020 C2_NOTAPPLICABLE, /*
\7f - 127 */
1021 C2_NOTAPPLICABLE, /*
\80 - 128 */
1022 C2_NOTAPPLICABLE, /*
\81 - 129 */
1023 C2_OTHERNEUTRAL, /*
\82 - 130 */
1024 C2_LEFTTORIGHT, /*
\83 - 131 */
1025 C2_OTHERNEUTRAL, /*
\84 - 132 */
1026 C2_OTHERNEUTRAL, /*
\85 - 133 */
1027 C2_OTHERNEUTRAL, /*
\86 - 134 */
1028 C2_OTHERNEUTRAL, /*
\87 - 135 */
1029 C2_LEFTTORIGHT, /*
\88 - 136 */
1030 C2_EUROPETERMINATOR, /*
\89 - 137 */
1031 C2_LEFTTORIGHT, /*
\8a - 138 */
1032 C2_OTHERNEUTRAL, /*
\8b - 139 */
1033 C2_LEFTTORIGHT, /*
\8c - 140 */
1034 C2_NOTAPPLICABLE, /*
\8d - 141 */
1035 C2_NOTAPPLICABLE, /*
\8e - 142 */
1036 C2_NOTAPPLICABLE, /*
\8f - 143 */
1037 C2_NOTAPPLICABLE, /*
\90 - 144 */
1038 C2_OTHERNEUTRAL, /*
\91 - 145 */
1039 C2_OTHERNEUTRAL, /*
\92 - 146 */
1040 C2_OTHERNEUTRAL, /*
\93 - 147 */
1041 C2_OTHERNEUTRAL, /*
\94 - 148 */
1042 C2_OTHERNEUTRAL, /*
\95 - 149 */
1043 C2_OTHERNEUTRAL, /*
\96 - 150 */
1044 C2_OTHERNEUTRAL, /*
\97 - 151 */
1045 C2_LEFTTORIGHT, /*
\98 - 152 */
1046 C2_OTHERNEUTRAL, /*
\99 - 153 */
1047 C2_LEFTTORIGHT, /*
\9a - 154 */
1048 C2_OTHERNEUTRAL, /*
\9b - 155 */
1049 C2_LEFTTORIGHT, /*
\9c - 156 */
1050 C2_NOTAPPLICABLE, /*
\9d - 157 */
1051 C2_NOTAPPLICABLE, /*
\9e - 158 */
1052 C2_LEFTTORIGHT, /*
\9f - 159 */
1053 C2_WHITESPACE, /* - 160 */
1054 C2_OTHERNEUTRAL, /* ¡ - 161 */
1055 C2_EUROPETERMINATOR, /* ¢ - 162 */
1056 C2_EUROPETERMINATOR, /* £ - 163 */
1057 C2_EUROPETERMINATOR, /* ¤ - 164 */
1058 C2_EUROPETERMINATOR, /* ¥ - 165 */
1059 C2_OTHERNEUTRAL, /* ¦ - 166 */
1060 C2_OTHERNEUTRAL, /* § - 167 */
1061 C2_OTHERNEUTRAL, /* ¨ - 168 */
1062 C2_OTHERNEUTRAL, /* © - 169 */
1063 C2_OTHERNEUTRAL, /* ª - 170 */
1064 C2_OTHERNEUTRAL, /* « - 171 */
1065 C2_OTHERNEUTRAL, /* ¬ - 172 */
1066 C2_OTHERNEUTRAL, /* - 173 */
1067 C2_OTHERNEUTRAL, /* ® - 174 */
1068 C2_OTHERNEUTRAL, /* ¯ - 175 */
1069 C2_EUROPETERMINATOR, /* ° - 176 */
1070 C2_EUROPETERMINATOR, /* ± - 177 */
1071 C2_EUROPENUMBER, /* ² - 178 */
1072 C2_EUROPENUMBER, /* ³ - 179 */
1073 C2_OTHERNEUTRAL, /* ´ - 180 */
1074 C2_OTHERNEUTRAL, /* µ - 181 */
1075 C2_OTHERNEUTRAL, /* ¶ - 182 */
1076 C2_OTHERNEUTRAL, /* · - 183 */
1077 C2_OTHERNEUTRAL, /* ¸ - 184 */
1078 C2_EUROPENUMBER, /* ¹ - 185 */
1079 C2_OTHERNEUTRAL, /* º - 186 */
1080 C2_OTHERNEUTRAL, /* » - 187 */
1081 C2_OTHERNEUTRAL, /* ¼ - 188 */
1082 C2_OTHERNEUTRAL, /* ½ - 189 */
1083 C2_OTHERNEUTRAL, /* ¾ - 190 */
1084 C2_OTHERNEUTRAL, /* ¿ - 191 */
1085 C2_LEFTTORIGHT, /* À - 192 */
1086 C2_LEFTTORIGHT, /* Á - 193 */
1087 C2_LEFTTORIGHT, /* Â - 194 */
1088 C2_LEFTTORIGHT, /* Ã - 195 */
1089 C2_LEFTTORIGHT, /* Ä - 196 */
1090 C2_LEFTTORIGHT, /* Å - 197 */
1091 C2_LEFTTORIGHT, /* Æ - 198 */
1092 C2_LEFTTORIGHT, /* Ç - 199 */
1093 C2_LEFTTORIGHT, /* È - 200 */
1094 C2_LEFTTORIGHT, /* É - 201 */
1095 C2_LEFTTORIGHT, /* Ê - 202 */
1096 C2_LEFTTORIGHT, /* Ë - 203 */
1097 C2_LEFTTORIGHT, /* Ì - 204 */
1098 C2_LEFTTORIGHT, /* Í - 205 */
1099 C2_LEFTTORIGHT, /* Î - 206 */
1100 C2_LEFTTORIGHT, /* Ï - 207 */
1101 C2_LEFTTORIGHT, /* Ð - 208 */
1102 C2_LEFTTORIGHT, /* Ñ - 209 */
1103 C2_LEFTTORIGHT, /* Ò - 210 */
1104 C2_LEFTTORIGHT, /* Ó - 211 */
1105 C2_LEFTTORIGHT, /* Ô - 212 */
1106 C2_LEFTTORIGHT, /* Õ - 213 */
1107 C2_LEFTTORIGHT, /* Ö - 214 */
1108 C2_OTHERNEUTRAL, /* × - 215 */
1109 C2_LEFTTORIGHT, /* Ø - 216 */
1110 C2_LEFTTORIGHT, /* Ù - 217 */
1111 C2_LEFTTORIGHT, /* Ú - 218 */
1112 C2_LEFTTORIGHT, /* Û - 219 */
1113 C2_LEFTTORIGHT, /* Ü - 220 */
1114 C2_LEFTTORIGHT, /* Ý - 221 */
1115 C2_LEFTTORIGHT, /* Þ - 222 */
1116 C2_LEFTTORIGHT, /* ß - 223 */
1117 C2_LEFTTORIGHT, /* à - 224 */
1118 C2_LEFTTORIGHT, /* á - 225 */
1119 C2_LEFTTORIGHT, /* â - 226 */
1120 C2_LEFTTORIGHT, /* ã - 227 */
1121 C2_LEFTTORIGHT, /* ä - 228 */
1122 C2_LEFTTORIGHT, /* å - 229 */
1123 C2_LEFTTORIGHT, /* æ - 230 */
1124 C2_LEFTTORIGHT, /* ç - 231 */
1125 C2_LEFTTORIGHT, /* è - 232 */
1126 C2_LEFTTORIGHT, /* é - 233 */
1127 C2_LEFTTORIGHT, /* ê - 234 */
1128 C2_LEFTTORIGHT, /* ë - 235 */
1129 C2_LEFTTORIGHT, /* ì - 236 */
1130 C2_LEFTTORIGHT, /* í - 237 */
1131 C2_LEFTTORIGHT, /* î - 238 */
1132 C2_LEFTTORIGHT, /* ï - 239 */
1133 C2_LEFTTORIGHT, /* ð - 240 */
1134 C2_LEFTTORIGHT, /* ñ - 241 */
1135 C2_LEFTTORIGHT, /* ò - 242 */
1136 C2_LEFTTORIGHT, /* ó - 243 */
1137 C2_LEFTTORIGHT, /* ô - 244 */
1138 C2_LEFTTORIGHT, /* õ - 245 */
1139 C2_LEFTTORIGHT, /* ö - 246 */
1140 C2_OTHERNEUTRAL, /* ÷ - 247 */
1141 C2_LEFTTORIGHT, /* ø - 248 */
1142 C2_LEFTTORIGHT, /* ù - 249 */
1143 C2_LEFTTORIGHT, /* ú - 250 */
1144 C2_LEFTTORIGHT, /* û - 251 */
1145 C2_LEFTTORIGHT, /* ü - 252 */
1146 C2_LEFTTORIGHT, /* ý - 253 */
1147 C2_LEFTTORIGHT, /* þ - 254 */
1148 C2_LEFTTORIGHT /* ÿ - 255 */
1151 const WORD OLE2NLS_CT_CType3_LUT[] = {
1185 0x0048, /* ! - 33 */
1186 0x0448, /* " - 34 */ /* " */
1187 0x0048, /* # - 35 */
1188 0x0448, /* $ - 36 */
1189 0x0048, /* % - 37 */
1190 0x0048, /* & - 38 */
1191 0x0440, /* ' - 39 */
1192 0x0048, /* ( - 40 */
1193 0x0048, /* ) - 41 */
1194 0x0048, /* * - 42 */
1195 0x0048, /* + - 43 */
1196 0x0048, /* , - 44 */
1197 0x0440, /* - - 45 */
1198 0x0048, /* . - 46 */
1199 0x0448, /* / - 47 */
1200 0x0040, /* 0 - 48 */
1201 0x0040, /* 1 - 49 */
1202 0x0040, /* 2 - 50 */
1203 0x0040, /* 3 - 51 */
1204 0x0040, /* 4 - 52 */
1205 0x0040, /* 5 - 53 */
1206 0x0040, /* 6 - 54 */
1207 0x0040, /* 7 - 55 */
1208 0x0040, /* 8 - 56 */
1209 0x0040, /* 9 - 57 */
1210 0x0048, /* : - 58 */
1211 0x0048, /* ; - 59 */
1212 0x0048, /* < - 60 */
1213 0x0448, /* = - 61 */
1214 0x0048, /* > - 62 */
1215 0x0048, /* ? - 63 */
1216 0x0448, /* @ - 64 */
1217 0x8040, /* A - 65 */
1218 0x8040, /* B - 66 */
1219 0x8040, /* C - 67 */
1220 0x8040, /* D - 68 */
1221 0x8040, /* E - 69 */
1222 0x8040, /* F - 70 */
1223 0x8040, /* G - 71 */
1224 0x8040, /* H - 72 */
1225 0x8040, /* I - 73 */
1226 0x8040, /* J - 74 */
1227 0x8040, /* K - 75 */
1228 0x8040, /* L - 76 */
1229 0x8040, /* M - 77 */
1230 0x8040, /* N - 78 */
1231 0x8040, /* O - 79 */
1232 0x8040, /* P - 80 */
1233 0x8040, /* Q - 81 */
1234 0x8040, /* R - 82 */
1235 0x8040, /* S - 83 */
1236 0x8040, /* T - 84 */
1237 0x8040, /* U - 85 */
1238 0x8040, /* V - 86 */
1239 0x8040, /* W - 87 */
1240 0x8040, /* X - 88 */
1241 0x8040, /* Y - 89 */
1242 0x8040, /* Z - 90 */
1243 0x0048, /* [ - 91 */
1244 0x0448, /* \ - 92 */
1245 0x0048, /* ] - 93 */
1246 0x0448, /* ^ - 94 */
1247 0x0448, /* _ - 95 */
1248 0x0448, /* ` - 96 */
1249 0x8040, /* a - 97 */
1250 0x8040, /* b - 98 */
1251 0x8040, /* c - 99 */
1252 0x8040, /* d - 100 */
1253 0x8040, /* e - 101 */
1254 0x8040, /* f - 102 */
1255 0x8040, /* g - 103 */
1256 0x8040, /* h - 104 */
1257 0x8040, /* i - 105 */
1258 0x8040, /* j - 106 */
1259 0x8040, /* k - 107 */
1260 0x8040, /* l - 108 */
1261 0x8040, /* m - 109 */
1262 0x8040, /* n - 110 */
1263 0x8040, /* o - 111 */
1264 0x8040, /* p - 112 */
1265 0x8040, /* q - 113 */
1266 0x8040, /* r - 114 */
1267 0x8040, /* s - 115 */
1268 0x8040, /* t - 116 */
1269 0x8040, /* u - 117 */
1270 0x8040, /* v - 118 */
1271 0x8040, /* w - 119 */
1272 0x8040, /* x - 120 */
1273 0x8040, /* y - 121 */
1274 0x8040, /* z - 122 */
1275 0x0048, /* { - 123 */
1276 0x0048, /* | - 124 */
1277 0x0048, /* } - 125 */
1278 0x0448, /* ~ - 126 */
1279 0x0000, /*
\7f - 127 */
1280 0x0000, /*
\80 - 128 */
1281 0x0000, /*
\81 - 129 */
1282 0x0008, /*
\82 - 130 */
1283 0x8000, /*
\83 - 131 */
1284 0x0008, /*
\84 - 132 */
1285 0x0008, /*
\85 - 133 */
1286 0x0008, /*
\86 - 134 */
1287 0x0008, /*
\87 - 135 */
1288 0x0001, /*
\88 - 136 */
1289 0x0008, /*
\89 - 137 */
1290 0x8003, /*
\8a - 138 */
1291 0x0008, /*
\8b - 139 */
1292 0x8000, /*
\8c - 140 */
1293 0x0000, /*
\8d - 141 */
1294 0x0000, /*
\8e - 142 */
1295 0x0000, /*
\8f - 143 */
1296 0x0000, /*
\90 - 144 */
1297 0x0088, /*
\91 - 145 */
1298 0x0088, /*
\92 - 146 */
1299 0x0088, /*
\93 - 147 */
1300 0x0088, /*
\94 - 148 */
1301 0x0008, /*
\95 - 149 */
1302 0x0400, /*
\96 - 150 */
1303 0x0400, /*
\97 - 151 */
1304 0x0408, /*
\98 - 152 */
1305 0x0000, /*
\99 - 153 */
1306 0x8003, /*
\9a - 154 */
1307 0x0008, /*
\9b - 155 */
1308 0x8000, /*
\9c - 156 */
1309 0x0000, /*
\9d - 157 */
1310 0x0000, /*
\9e - 158 */
1311 0x8003, /*
\9f - 159 */
1313 0x0008, /* ¡ - 161 */
1314 0x0048, /* ¢ - 162 */
1315 0x0048, /* £ - 163 */
1316 0x0008, /* ¤ - 164 */
1317 0x0048, /* ¥ - 165 */
1318 0x0048, /* ¦ - 166 */
1319 0x0008, /* § - 167 */
1320 0x0408, /* ¨ - 168 */
1321 0x0008, /* © - 169 */
1322 0x0400, /* ª - 170 */
1323 0x0008, /* « - 171 */
1324 0x0048, /* ¬ - 172 */
1325 0x0408, /* - 173 */
1326 0x0008, /* ® - 174 */
1327 0x0448, /* ¯ - 175 */
1328 0x0008, /* ° - 176 */
1329 0x0008, /* ± - 177 */
1330 0x0000, /* ² - 178 */
1331 0x0000, /* ³ - 179 */
1332 0x0408, /* ´ - 180 */
1333 0x0008, /* µ - 181 */
1334 0x0008, /* ¶ - 182 */
1335 0x0008, /* · - 183 */
1336 0x0408, /* ¸ - 184 */
1337 0x0000, /* ¹ - 185 */
1338 0x0400, /* º - 186 */
1339 0x0008, /* » - 187 */
1340 0x0000, /* ¼ - 188 */
1341 0x0000, /* ½ - 189 */
1342 0x0000, /* ¾ - 190 */
1343 0x0008, /* ¿ - 191 */
1344 0x8003, /* À - 192 */
1345 0x8003, /* Á - 193 */
1346 0x8003, /* Â - 194 */
1347 0x8003, /* Ã - 195 */
1348 0x8003, /* Ä - 196 */
1349 0x8003, /* Å - 197 */
1350 0x8000, /* Æ - 198 */
1351 0x8003, /* Ç - 199 */
1352 0x8003, /* È - 200 */
1353 0x8003, /* É - 201 */
1354 0x8003, /* Ê - 202 */
1355 0x8003, /* Ë - 203 */
1356 0x8003, /* Ì - 204 */
1357 0x8003, /* Í - 205 */
1358 0x8003, /* Î - 206 */
1359 0x8003, /* Ï - 207 */
1360 0x8000, /* Ð - 208 */
1361 0x8003, /* Ñ - 209 */
1362 0x8003, /* Ò - 210 */
1363 0x8003, /* Ó - 211 */
1364 0x8003, /* Ô - 212 */
1365 0x8003, /* Õ - 213 */
1366 0x8003, /* Ö - 214 */
1367 0x0008, /* × - 215 */
1368 0x8003, /* Ø - 216 */
1369 0x8003, /* Ù - 217 */
1370 0x8003, /* Ú - 218 */
1371 0x8003, /* Û - 219 */
1372 0x8003, /* Ü - 220 */
1373 0x8003, /* Ý - 221 */
1374 0x8000, /* Þ - 222 */
1375 0x8000, /* ß - 223 */
1376 0x8003, /* à - 224 */
1377 0x8003, /* á - 225 */
1378 0x8003, /* â - 226 */
1379 0x8003, /* ã - 227 */
1380 0x8003, /* ä - 228 */
1381 0x8003, /* å - 229 */
1382 0x8000, /* æ - 230 */
1383 0x8003, /* ç - 231 */
1384 0x8003, /* è - 232 */
1385 0x8003, /* é - 233 */
1386 0x8003, /* ê - 234 */
1387 0x8003, /* ë - 235 */
1388 0x8003, /* ì - 236 */
1389 0x8003, /* í - 237 */
1390 0x8003, /* î - 238 */
1391 0x8003, /* ï - 239 */
1392 0x8000, /* ð - 240 */
1393 0x8003, /* ñ - 241 */
1394 0x8003, /* ò - 242 */
1395 0x8003, /* ó - 243 */
1396 0x8003, /* ô - 244 */
1397 0x8003, /* õ - 245 */
1398 0x8003, /* ö - 246 */
1399 0x0008, /* ÷ - 247 */
1400 0x8003, /* ø - 248 */
1401 0x8003, /* ù - 249 */
1402 0x8003, /* ú - 250 */
1403 0x8003, /* û - 251 */
1404 0x8003, /* ü - 252 */
1405 0x8003, /* ý - 253 */
1406 0x8000, /* þ - 254 */
1407 0x8003 /* ÿ - 255 */
1410 /******************************************************************************
1411 * GetStringType16 [OLE2NLS.7]
1413 BOOL16 WINAPI GetStringType16(LCID locale,DWORD dwInfoType,LPCSTR src,
1414 INT16 cchSrc,LPWORD chartype)
1416 return GetStringTypeExA(locale,dwInfoType,src,cchSrc,chartype);
1418 /******************************************************************************
1419 * GetStringType32A [KERNEL32.396]
1421 BOOL WINAPI GetStringTypeA(LCID locale,DWORD dwInfoType,LPCSTR src,
1422 INT cchSrc,LPWORD chartype)
1424 return GetStringTypeExA(locale,dwInfoType,src,cchSrc,chartype);
1427 /******************************************************************************
1428 * GetStringTypeEx32A [KERNEL32.397]
1430 * FIXME: Ignores the locale.
1432 BOOL WINAPI GetStringTypeExA(LCID locale,DWORD dwInfoType,LPCSTR src,
1433 INT cchSrc,LPWORD chartype)
1437 if ((src==NULL) || (chartype==NULL) || (src==(LPSTR)chartype))
1439 SetLastError(ERROR_INVALID_PARAMETER);
1444 cchSrc=lstrlenA(src)+1;
1446 switch (dwInfoType) {
1448 for (i=0;i<cchSrc;i++)
1451 if (isdigit(src[i])) chartype[i]|=C1_DIGIT;
1452 if (isalpha(src[i])) chartype[i]|=C1_ALPHA;
1453 if (islower(src[i])) chartype[i]|=C1_LOWER;
1454 if (isupper(src[i])) chartype[i]|=C1_UPPER;
1455 if (isspace(src[i])) chartype[i]|=C1_SPACE;
1456 if (ispunct(src[i])) chartype[i]|=C1_PUNCT;
1457 if (iscntrl(src[i])) chartype[i]|=C1_CNTRL;
1458 /* FIXME: isblank() is a GNU extension */
1459 /* if (isblank(src[i])) chartype[i]|=C1_BLANK; */
1460 if ((src[i] == ' ') || (src[i] == '\t')) chartype[i]|=C1_BLANK;
1466 for (i=0;i<cchSrc;i++)
1468 chartype[i]=(WORD)CT_CType2_LUT[i];
1473 for (i=0;i<cchSrc;i++)
1475 chartype[i]=OLE2NLS_CT_CType3_LUT[i];
1480 ERR_(ole)("Unknown dwInfoType:%ld\n",dwInfoType);
1485 /******************************************************************************
1486 * GetStringType32W [KERNEL32.399]
1489 * Yes, this is missing LCID locale. MS fault.
1491 BOOL WINAPI GetStringTypeW(DWORD dwInfoType,LPCWSTR src,INT cchSrc,
1494 return GetStringTypeExW(0/*defaultlocale*/,dwInfoType,src,cchSrc,chartype);
1497 /******************************************************************************
1498 * GetStringTypeEx32W [KERNEL32.398]
1500 * FIXME: unicode chars are assumed chars
1502 BOOL WINAPI GetStringTypeExW(LCID locale,DWORD dwInfoType,LPCWSTR src,
1503 INT cchSrc,LPWORD chartype)
1509 cchSrc=lstrlenW(src)+1;
1511 switch (dwInfoType) {
1513 FIXME_(ole)("CT_CTYPE2 not supported.\n");
1516 FIXME_(ole)("CT_CTYPE3 not supported.\n");
1520 for (i=0;i<cchSrc;i++) {
1522 if (isdigit(src[i])) chartype[i]|=C1_DIGIT;
1523 if (isalpha(src[i])) chartype[i]|=C1_ALPHA;
1524 if (islower(src[i])) chartype[i]|=C1_LOWER;
1525 if (isupper(src[i])) chartype[i]|=C1_UPPER;
1526 if (isspace(src[i])) chartype[i]|=C1_SPACE;
1527 if (ispunct(src[i])) chartype[i]|=C1_PUNCT;
1528 if (iscntrl(src[i])) chartype[i]|=C1_CNTRL;
1529 /* FIXME: isblank() is a GNU extension */
1530 /* if (isblank(src[i])) chartype[i]|=C1_BLANK; */
1531 if ((src[i] == ' ') || (src[i] == '\t')) chartype[i]|=C1_BLANK;
1537 /*****************************************************************
1538 * WINE_GetLanguageName [internal]
1540 static LPCSTR WINE_GetLanguageName( UINT langid )
1543 for ( i = 0; languages[i].langid != 0; i++ )
1544 if ( langid == languages[i].langid )
1547 return languages[i].langname;
1550 /***********************************************************************
1551 * VerLanguageNameA [KERNEL32.709][VERSION.9]
1553 DWORD WINAPI VerLanguageNameA( UINT wLang, LPSTR szLang, UINT nSize )
1560 * First, check \System\CurrentControlSet\control\Nls\Locale\<langid>
1561 * from the registry.
1565 "\\System\\CurrentControlSet\\control\\Nls\\Locale\\%08x",
1568 result = RegQueryValueA( HKEY_LOCAL_MACHINE, buffer, szLang, (LPDWORD)&nSize );
1569 if ( result == ERROR_SUCCESS || result == ERROR_MORE_DATA )
1573 * If that fails, use the internal table
1576 name = WINE_GetLanguageName( wLang );
1577 lstrcpynA( szLang, name, nSize );
1578 return lstrlenA( name );
1581 /***********************************************************************
1582 * VerLanguageNameW [KERNEL32.710][VERSION.10]
1584 DWORD WINAPI VerLanguageNameW( UINT wLang, LPWSTR szLang, UINT nSize )
1592 * First, check \System\CurrentControlSet\control\Nls\Locale\<langid>
1593 * from the registry.
1597 "\\System\\CurrentControlSet\\control\\Nls\\Locale\\%08x",
1600 keyname = HEAP_strdupAtoW( GetProcessHeap(), 0, buffer );
1601 result = RegQueryValueW( HKEY_LOCAL_MACHINE, keyname, szLang, (LPDWORD)&nSize );
1602 HeapFree( GetProcessHeap(), 0, keyname );
1604 if ( result == ERROR_SUCCESS || result == ERROR_MORE_DATA )
1608 * If that fails, use the internal table
1611 name = WINE_GetLanguageName( wLang );
1612 lstrcpynAtoW( szLang, name, nSize );
1613 return lstrlenA( name );
1617 static const unsigned char LCM_Unicode_LUT[] = {
1650 7 , 28, /* ! - 33 */
1651 7 , 29, /* " - 34 */ /* " */
1652 7 , 31, /* # - 35 */
1653 7 , 33, /* $ - 36 */
1654 7 , 35, /* % - 37 */
1655 7 , 37, /* & - 38 */
1656 6 , 128, /* ' - 39 */
1657 7 , 39, /* ( - 40 */
1658 7 , 42, /* ) - 41 */
1659 7 , 45, /* * - 42 */
1661 7 , 47, /* , - 44 */
1662 6 , 130, /* - - 45 */
1663 7 , 51, /* . - 46 */
1664 7 , 53, /* / - 47 */
1665 12 , 3, /* 0 - 48 */
1666 12 , 33, /* 1 - 49 */
1667 12 , 51, /* 2 - 50 */
1668 12 , 70, /* 3 - 51 */
1669 12 , 88, /* 4 - 52 */
1670 12 , 106, /* 5 - 53 */
1671 12 , 125, /* 6 - 54 */
1672 12 , 144, /* 7 - 55 */
1673 12 , 162, /* 8 - 56 */
1674 12 , 180, /* 9 - 57 */
1675 7 , 55, /* : - 58 */
1676 7 , 58, /* ; - 59 */
1677 8 , 14, /* < - 60 */
1678 8 , 18, /* = - 61 */
1679 8 , 20, /* > - 62 */
1680 7 , 60, /* ? - 63 */
1681 7 , 62, /* @ - 64 */
1682 14 , 2, /* A - 65 */
1683 14 , 9, /* B - 66 */
1684 14 , 10, /* C - 67 */
1685 14 , 26, /* D - 68 */
1686 14 , 33, /* E - 69 */
1687 14 , 35, /* F - 70 */
1688 14 , 37, /* G - 71 */
1689 14 , 44, /* H - 72 */
1690 14 , 50, /* I - 73 */
1691 14 , 53, /* J - 74 */
1692 14 , 54, /* K - 75 */
1693 14 , 72, /* L - 76 */
1694 14 , 81, /* M - 77 */
1695 14 , 112, /* N - 78 */
1696 14 , 124, /* O - 79 */
1697 14 , 126, /* P - 80 */
1698 14 , 137, /* Q - 81 */
1699 14 , 138, /* R - 82 */
1700 14 , 145, /* S - 83 */
1701 14 , 153, /* T - 84 */
1702 14 , 159, /* U - 85 */
1703 14 , 162, /* V - 86 */
1704 14 , 164, /* W - 87 */
1705 14 , 166, /* X - 88 */
1706 14 , 167, /* Y - 89 */
1707 14 , 169, /* Z - 90 */
1708 7 , 63, /* [ - 91 */
1709 7 , 65, /* \ - 92 */
1710 7 , 66, /* ] - 93 */
1711 7 , 67, /* ^ - 94 */
1712 7 , 68, /* _ - 95 */
1713 7 , 72, /* ` - 96 */
1714 14 , 2, /* a - 97 */
1715 14 , 9, /* b - 98 */
1716 14 , 10, /* c - 99 */
1717 14 , 26, /* d - 100 */
1718 14 , 33, /* e - 101 */
1719 14 , 35, /* f - 102 */
1720 14 , 37, /* g - 103 */
1721 14 , 44, /* h - 104 */
1722 14 , 50, /* i - 105 */
1723 14 , 53, /* j - 106 */
1724 14 , 54, /* k - 107 */
1725 14 , 72, /* l - 108 */
1726 14 , 81, /* m - 109 */
1727 14 , 112, /* n - 110 */
1728 14 , 124, /* o - 111 */
1729 14 , 126, /* p - 112 */
1730 14 , 137, /* q - 113 */
1731 14 , 138, /* r - 114 */
1732 14 , 145, /* s - 115 */
1733 14 , 153, /* t - 116 */
1734 14 , 159, /* u - 117 */
1735 14 , 162, /* v - 118 */
1736 14 , 164, /* w - 119 */
1737 14 , 166, /* x - 120 */
1738 14 , 167, /* y - 121 */
1739 14 , 169, /* z - 122 */
1740 7 , 74, /* { - 123 */
1741 7 , 76, /* | - 124 */
1742 7 , 78, /* } - 125 */
1743 7 , 80, /* ~ - 126 */
1744 6 , 29, /*
\7f - 127 */
1745 6 , 30, /*
\80 - 128 */
1746 6 , 31, /*
\81 - 129 */
1747 7 , 123, /*
\82 - 130 */
1748 14 , 35, /*
\83 - 131 */
1749 7 , 127, /*
\84 - 132 */
1750 10 , 21, /*
\85 - 133 */
1751 10 , 15, /*
\86 - 134 */
1752 10 , 16, /*
\87 - 135 */
1753 7 , 67, /*
\88 - 136 */
1754 10 , 22, /*
\89 - 137 */
1755 14 , 145, /*
\8a - 138 */
1756 7 , 136, /*
\8b - 139 */
1757 14 + 16 , 124, /*
\8c - 140 */
1758 6 , 43, /*
\8d - 141 */
1759 6 , 44, /*
\8e - 142 */
1760 6 , 45, /*
\8f - 143 */
1761 6 , 46, /*
\90 - 144 */
1762 7 , 121, /*
\91 - 145 */
1763 7 , 122, /*
\92 - 146 */
1764 7 , 125, /*
\93 - 147 */
1765 7 , 126, /*
\94 - 148 */
1766 10 , 17, /*
\95 - 149 */
1767 6 , 137, /*
\96 - 150 */
1768 6 , 139, /*
\97 - 151 */
1769 7 , 93, /*
\98 - 152 */
1770 14 , 156, /*
\99 - 153 */
1771 14 , 145, /*
\9a - 154 */
1772 7 , 137, /*
\9b - 155 */
1773 14 + 16 , 124, /*
\9c - 156 */
1774 6 , 59, /*
\9d - 157 */
1775 6 , 60, /*
\9e - 158 */
1776 14 , 167, /*
\9f - 159 */
1778 7 , 81, /* ¡ - 161 */
1779 10 , 2, /* ¢ - 162 */
1780 10 , 3, /* £ - 163 */
1781 10 , 4, /* ¤ - 164 */
1782 10 , 5, /* ¥ - 165 */
1783 7 , 82, /* ¦ - 166 */
1784 10 , 6, /* § - 167 */
1785 7 , 83, /* ¨ - 168 */
1786 10 , 7, /* © - 169 */
1787 14 , 2, /* ª - 170 */
1788 8 , 24, /* « - 171 */
1789 10 , 8, /* ¬ - 172 */
1790 6 , 131, /* - 173 */
1791 10 , 9, /* ® - 174 */
1792 7 , 84, /* ¯ - 175 */
1793 10 , 10, /* ° - 176 */
1794 8 , 23, /* ± - 177 */
1795 12 , 51, /* ² - 178 */
1796 12 , 70, /* ³ - 179 */
1797 7 , 85, /* ´ - 180 */
1798 10 , 11, /* µ - 181 */
1799 10 , 12, /* ¶ - 182 */
1800 10 , 13, /* · - 183 */
1801 7 , 86, /* ¸ - 184 */
1802 12 , 33, /* ¹ - 185 */
1803 14 , 124, /* º - 186 */
1804 8 , 26, /* » - 187 */
1805 12 , 21, /* ¼ - 188 */
1806 12 , 25, /* ½ - 189 */
1807 12 , 29, /* ¾ - 190 */
1808 7 , 87, /* ¿ - 191 */
1809 14 , 2, /* À - 192 */
1810 14 , 2, /* Á - 193 */
1811 14 , 2, /* Â - 194 */
1812 14 , 2, /* Ã - 195 */
1813 14 , 2, /* Ä - 196 */
1814 14 , 2, /* Å - 197 */
1815 14 + 16 , 2, /* Æ - 198 */
1816 14 , 10, /* Ç - 199 */
1817 14 , 33, /* È - 200 */
1818 14 , 33, /* É - 201 */
1819 14 , 33, /* Ê - 202 */
1820 14 , 33, /* Ë - 203 */
1821 14 , 50, /* Ì - 204 */
1822 14 , 50, /* Í - 205 */
1823 14 , 50, /* Î - 206 */
1824 14 , 50, /* Ï - 207 */
1825 14 , 26, /* Ð - 208 */
1826 14 , 112, /* Ñ - 209 */
1827 14 , 124, /* Ò - 210 */
1828 14 , 124, /* Ó - 211 */
1829 14 , 124, /* Ô - 212 */
1830 14 , 124, /* Õ - 213 */
1831 14 , 124, /* Ö - 214 */
1832 8 , 28, /* × - 215 */
1833 14 , 124, /* Ø - 216 */
1834 14 , 159, /* Ù - 217 */
1835 14 , 159, /* Ú - 218 */
1836 14 , 159, /* Û - 219 */
1837 14 , 159, /* Ü - 220 */
1838 14 , 167, /* Ý - 221 */
1839 14 + 32 , 153, /* Þ - 222 */
1840 14 + 48 , 145, /* ß - 223 */
1841 14 , 2, /* à - 224 */
1842 14 , 2, /* á - 225 */
1843 14 , 2, /* â - 226 */
1844 14 , 2, /* ã - 227 */
1845 14 , 2, /* ä - 228 */
1846 14 , 2, /* å - 229 */
1847 14 + 16 , 2, /* æ - 230 */
1848 14 , 10, /* ç - 231 */
1849 14 , 33, /* è - 232 */
1850 14 , 33, /* é - 233 */
1851 14 , 33, /* ê - 234 */
1852 14 , 33, /* ë - 235 */
1853 14 , 50, /* ì - 236 */
1854 14 , 50, /* í - 237 */
1855 14 , 50, /* î - 238 */
1856 14 , 50, /* ï - 239 */
1857 14 , 26, /* ð - 240 */
1858 14 , 112, /* ñ - 241 */
1859 14 , 124, /* ò - 242 */
1860 14 , 124, /* ó - 243 */
1861 14 , 124, /* ô - 244 */
1862 14 , 124, /* õ - 245 */
1863 14 , 124, /* ö - 246 */
1864 8 , 29, /* ÷ - 247 */
1865 14 , 124, /* ø - 248 */
1866 14 , 159, /* ù - 249 */
1867 14 , 159, /* ú - 250 */
1868 14 , 159, /* û - 251 */
1869 14 , 159, /* ü - 252 */
1870 14 , 167, /* ý - 253 */
1871 14 + 32 , 153, /* þ - 254 */
1872 14 , 167 /* ÿ - 255 */ };
1874 static const unsigned char LCM_Unicode_LUT_2[] = { 33, 44, 145 };
1876 #define LCM_Diacritic_Start 131
1878 static const unsigned char LCM_Diacritic_LUT[] = {
1879 123, /*
\83 - 131 */
2006 /******************************************************************************
2007 * OLE2NLS_isPunctuation [INTERNAL]
2009 static int OLE2NLS_isPunctuation(unsigned char c)
2011 /* "punctuation character" in this context is a character which is
2012 considered "less important" during word sort comparison.
2013 See LCMapString implementation for the precise definition
2014 of "less important". */
2016 return (LCM_Unicode_LUT[-2+2*c]==6);
2019 /******************************************************************************
2020 * OLE2NLS_isNonSpacing [INTERNAL]
2022 static int OLE2NLS_isNonSpacing(unsigned char c)
2024 /* This function is used by LCMapString32A. Characters
2025 for which it returns true are ignored when mapping a
2026 string with NORM_IGNORENONSPACE */
2027 return ((c==136) || (c==170) || (c==186));
2030 /******************************************************************************
2031 * OLE2NLS_isSymbol [INTERNAL]
2033 static int OLE2NLS_isSymbol(unsigned char c)
2035 /* This function is used by LCMapString32A. Characters
2036 for which it returns true are ignored when mapping a
2037 string with NORM_IGNORESYMBOLS */
2038 return ( (c!=0) && !IsCharAlphaNumericA(c) );
2041 /******************************************************************************
2042 * identity [Internal]
2044 static int identity(int c)
2049 /*************************************************************************
2050 * LCMapString32A [KERNEL32.492]
2052 * Convert a string, or generate a sort key from it.
2054 * If (mapflags & LCMAP_SORTKEY), the function will generate
2055 * a sort key for the source string. Else, it will convert it
2056 * accordingly to the flags LCMAP_UPPERCASE, LCMAP_LOWERCASE,...
2060 * Success : length of the result string.
2063 * If called with scrlen = -1, the function will compute the length
2064 * of the 0-terminated string strsrc by itself.
2066 * If called with dstlen = 0, returns the buffer length that
2067 * would be required.
2069 * NORM_IGNOREWIDTH means to compare ASCII and wide characters
2070 * as if they are equal.
2071 * In the only code page implemented so far, there may not be
2072 * wide characters in strings passed to LCMapString32A,
2073 * so there is nothing to be done for this flag.
2075 INT WINAPI LCMapStringA(
2076 LCID lcid /* locale identifier created with MAKELCID;
2077 LOCALE_SYSTEM_DEFAULT and LOCALE_USER_DEFAULT are
2078 predefined values. */,
2079 DWORD mapflags /* flags */,
2080 LPCSTR srcstr /* source buffer */,
2081 INT srclen /* source length */,
2082 LPSTR dststr /* destination buffer */,
2083 INT dstlen /* destination buffer length */)
2087 TRACE_(string)("(0x%04lx,0x%08lx,%s,%d,%p,%d)\n",
2088 lcid,mapflags,srcstr,srclen,dststr,dstlen);
2090 if ( ((dstlen!=0) && (dststr==NULL)) || (srcstr==NULL) )
2092 ERR_(ole)("(src=%s,dest=%s): Invalid NULL string\n", srcstr, dststr);
2093 SetLastError(ERROR_INVALID_PARAMETER);
2097 srclen = lstrlenA(srcstr) + 1 ; /* (include final '\0') */
2099 #define LCMAPSTRINGA_SUPPORTED_FLAGS (LCMAP_UPPERCASE | \
2103 NORM_IGNORENONSPACE | \
2107 if (mapflags & ~LCMAPSTRINGA_SUPPORTED_FLAGS)
2109 FIXME_(string)("(0x%04lx,0x%08lx,%p,%d,%p,%d): "
2110 "unimplemented flags: 0x%08lx\n",
2117 mapflags & ~LCMAPSTRINGA_SUPPORTED_FLAGS
2121 if ( !(mapflags & LCMAP_SORTKEY) )
2124 int (*f)(int) = identity;
2125 int flag_ignorenonspace = mapflags & NORM_IGNORENONSPACE;
2126 int flag_ignoresymbols = mapflags & NORM_IGNORESYMBOLS;
2128 if (flag_ignorenonspace || flag_ignoresymbols)
2130 /* For some values of mapflags, the length of the resulting
2131 string is not known at this point. Windows does map the string
2132 and does not SetLastError ERROR_INSUFFICIENT_BUFFER in
2136 /* Compute required length */
2137 for (i=j=0; i < srclen; i++)
2139 if ( !(flag_ignorenonspace && OLE2NLS_isNonSpacing(srcstr[i]))
2140 && !(flag_ignoresymbols && OLE2NLS_isSymbol(srcstr[i])) )
2152 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2156 if (mapflags & LCMAP_UPPERCASE)
2158 else if (mapflags & LCMAP_LOWERCASE)
2160 /* FIXME: NORM_IGNORENONSPACE requires another conversion */
2161 for (i=j=0; (i<srclen) && (j<dstlen) ; i++)
2163 if ( !(flag_ignorenonspace && OLE2NLS_isNonSpacing(srcstr[i]))
2164 && !(flag_ignoresymbols && OLE2NLS_isSymbol(srcstr[i])) )
2166 dststr[j] = (CHAR) f(srcstr[i]);
2173 /* else ... (mapflags & LCMAP_SORTKEY) */
2177 int diacritic_len=0;
2178 int delayed_punctuation_len=0;
2179 char *case_component;
2180 char *diacritic_component;
2181 char *delayed_punctuation_component;
2183 int flag_stringsort = mapflags & SORT_STRINGSORT;
2185 /* compute how much room we will need */
2186 for (i=0;i<srclen;i++)
2189 unsigned char source_char = srcstr[i];
2190 if (source_char!='\0')
2192 if (flag_stringsort || !OLE2NLS_isPunctuation(source_char))
2195 if ( LCM_Unicode_LUT[-2+2*source_char] & ~15 )
2196 unicode_len++; /* double letter */
2200 delayed_punctuation_len++;
2204 if (isupper(source_char))
2205 case_len=unicode_len;
2207 ofs = source_char - LCM_Diacritic_Start;
2208 if ((ofs>=0) && (LCM_Diacritic_LUT[ofs]!=2))
2209 diacritic_len=unicode_len;
2212 if (mapflags & NORM_IGNORECASE)
2214 if (mapflags & NORM_IGNORENONSPACE)
2217 room = 2 * unicode_len /* "unicode" component */
2218 + diacritic_len /* "diacritic" component */
2219 + case_len /* "case" component */
2220 + 4 * delayed_punctuation_len /* punctuation in word sort mode */
2221 + 4 /* four '\1' separators */
2222 + 1 ; /* terminal '\0' */
2225 else if (dstlen<room)
2227 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2231 /*FIXME the Pointercheck should not be nessesary */
2232 if (IsBadWritePtr (dststr,room))
2233 { ERR_(string)("bad destination buffer (dststr) : %p,%d\n",dststr,dstlen);
2234 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2238 /* locate each component, write separators */
2239 diacritic_component = dststr + 2*unicode_len ;
2240 *diacritic_component++ = '\1';
2241 case_component = diacritic_component + diacritic_len ;
2242 *case_component++ = '\1';
2243 delayed_punctuation_component = case_component + case_len ;
2244 *delayed_punctuation_component++ = '\1';
2245 *delayed_punctuation_component++ = '\1';
2247 /* read source string char by char, write
2248 corresponding weight in each component. */
2249 for (i=0,count=0;i<srclen;i++)
2251 unsigned char source_char=srcstr[i];
2252 if (source_char!='\0')
2255 type = LCM_Unicode_LUT[-2+2*source_char];
2256 longcode = type >> 4;
2258 if (!flag_stringsort && OLE2NLS_isPunctuation(source_char))
2260 UINT16 encrypted_location = (1<<15) + 7 + 4*count;
2261 *delayed_punctuation_component++ = (unsigned char) (encrypted_location>>8);
2262 *delayed_punctuation_component++ = (unsigned char) (encrypted_location&255);
2263 /* big-endian is used here because it lets string comparison be
2264 compatible with numerical comparison */
2266 *delayed_punctuation_component++ = type;
2267 *delayed_punctuation_component++ = LCM_Unicode_LUT[-1+2*source_char];
2268 /* assumption : a punctuation character is never a
2269 double or accented letter */
2273 dststr[2*count] = type;
2274 dststr[2*count+1] = LCM_Unicode_LUT[-1+2*source_char];
2278 case_component[count] = ( isupper(source_char) ? 18 : 2 ) ;
2279 if (count<diacritic_len)
2280 diacritic_component[count] = 2; /* assumption: a double letter
2281 is never accented */
2284 dststr[2*count] = type;
2285 dststr[2*count+1] = *(LCM_Unicode_LUT_2 - 1 + longcode);
2286 /* 16 in the first column of LCM_Unicode_LUT --> longcode = 1
2287 32 in the first column of LCM_Unicode_LUT --> longcode = 2
2288 48 in the first column of LCM_Unicode_LUT --> longcode = 3 */
2292 case_component[count] = ( isupper(source_char) ? 18 : 2 ) ;
2293 if (count<diacritic_len)
2295 int ofs = source_char - LCM_Diacritic_Start;
2296 diacritic_component[count] = (ofs>=0 ? LCM_Diacritic_LUT[ofs] : 2);
2302 dststr[room-1] = '\0';
2307 /*************************************************************************
2308 * LCMapString32W [KERNEL32.493]
2310 * Convert a string, or generate a sort key from it.
2314 * See LCMapString32A for documentation
2316 INT WINAPI LCMapStringW(
2317 LCID lcid,DWORD mapflags,LPCWSTR srcstr,INT srclen,LPWSTR dststr,
2322 TRACE_(string)("(0x%04lx,0x%08lx,%p,%d,%p,%d)\n",
2323 lcid,mapflags,srcstr,srclen,dststr,dstlen);
2325 if ( ((dstlen!=0) && (dststr==NULL)) || (srcstr==NULL) )
2327 ERR_(ole)("(src=%p,dst=%p): Invalid NULL string\n", srcstr, dststr);
2328 SetLastError(ERROR_INVALID_PARAMETER);
2332 srclen = lstrlenW(srcstr)+1;
2333 if (mapflags & LCMAP_SORTKEY)
2335 FIXME_(string)("(0x%04lx,0x%08lx,%p,%d,%p,%d): "
2336 "unimplemented flags: 0x%08lx\n",
2337 lcid,mapflags,srcstr,srclen,dststr,dstlen,mapflags);
2342 int (*f)(int)=identity;
2346 if (dstlen<srclen) {
2347 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2350 if (mapflags & LCMAP_UPPERCASE)
2352 else if (mapflags & LCMAP_LOWERCASE)
2354 for (i=0; i < srclen; i++)
2355 dststr[i] = (WCHAR) f(srcstr[i]);
2360 /***********************************************************************
2361 * CompareString16 (OLE2NLS.8)
2363 UINT16 WINAPI CompareString16(DWORD lcid,DWORD fdwStyle,
2364 LPCSTR s1,DWORD l1,LPCSTR s2,DWORD l2)
2366 return (UINT16)CompareStringA(lcid,fdwStyle,s1,l1,s2,l2);
2369 /******************************************************************************
2370 * CompareString32A [KERNEL32.143]
2371 * Compares two strings using locale
2375 * success: CSTR_LESS_THAN, CSTR_EQUAL, CSTR_GREATER_THAN
2380 * Defaults to a word sort, but uses a string sort if
2381 * SORT_STRINGSORT is set.
2382 * Calls SetLastError for ERROR_INVALID_FLAGS, ERROR_INVALID_PARAMETER.
2386 * This implementation ignores the locale
2390 * Quite inefficient.
2392 UINT WINAPI CompareStringA(
2393 DWORD lcid, /* locale ID */
2394 DWORD fdwStyle, /* comparison-style options */
2395 LPCSTR s1, /* first string */
2396 DWORD l1, /* length of first string */
2397 LPCSTR s2, /* second string */
2398 DWORD l2) /* length of second string */
2400 int mapstring_flags;
2404 TRACE_(ole)("%s and %s\n",
2405 debugstr_a (s1), debugstr_a (s2));
2407 if ( (s1==NULL) || (s2==NULL) )
2409 ERR_(ole)("(s1=%s,s2=%s): Invalid NULL string\n", s1, s2);
2410 SetLastError(ERROR_INVALID_PARAMETER);
2414 if(fdwStyle & NORM_IGNORESYMBOLS)
2415 FIXME_(ole)("IGNORESYMBOLS not supported\n");
2417 mapstring_flags = LCMAP_SORTKEY | fdwStyle ;
2418 len1 = LCMapStringA(lcid,mapstring_flags,s1,l1,NULL,0);
2419 len2 = LCMapStringA(lcid,mapstring_flags,s2,l2,NULL,0);
2421 if ((len1==0)||(len2==0))
2422 return 0; /* something wrong happened */
2424 sk1 = (LPSTR)HeapAlloc(GetProcessHeap(),0,len1);
2425 sk2 = (LPSTR)HeapAlloc(GetProcessHeap(),0,len2);
2426 if ( (!LCMapStringA(lcid,mapstring_flags,s1,l1,sk1,len1))
2427 || (!LCMapStringA(lcid,mapstring_flags,s2,l2,sk2,len2)) )
2429 ERR_(ole)("Bug in LCmapString32A.\n");
2434 /* strcmp doesn't necessarily return -1, 0, or 1 */
2435 result = strcmp(sk1,sk2);
2437 HeapFree(GetProcessHeap(),0,sk1);
2438 HeapFree(GetProcessHeap(),0,sk2);
2445 /* must be greater, if we reach this point */
2449 /******************************************************************************
2450 * CompareString32W [KERNEL32.144]
2451 * This implementation ignores the locale
2452 * FIXME : Does only string sort. Should
2453 * be reimplemented the same way as CompareString32A.
2455 UINT WINAPI CompareStringW(DWORD lcid, DWORD fdwStyle,
2456 LPCWSTR s1, DWORD l1, LPCWSTR s2,DWORD l2)
2459 if(fdwStyle & NORM_IGNORENONSPACE)
2460 FIXME_(ole)("IGNORENONSPACE not supprted\n");
2461 if(fdwStyle & NORM_IGNORESYMBOLS)
2462 FIXME_(ole)("IGNORESYMBOLS not supported\n");
2464 /* Is strcmp defaulting to string sort or to word sort?? */
2465 /* FIXME: Handle NORM_STRINGSORT */
2466 l1 = (l1==-1)?lstrlenW(s1):l1;
2467 l2 = (l2==-1)?lstrlenW(s2):l2;
2468 len = l1<l2 ? l1:l2;
2469 ret = (fdwStyle & NORM_IGNORECASE) ?
2470 CRTDLL__wcsnicmp(s1,s2,len) : CRTDLL_wcsncmp(s1,s2,len);
2471 /* not equal, return 1 or 3 */
2472 if(ret!=0) return ret+2;
2473 /* same len, return 2 */
2474 if(l1==l2) return 2;
2475 /* the longer one is lexically greater */
2476 return (l1<l2)? 1 : 3;
2479 /******************************************************************************
2480 * OLE_GetFormatA [Internal]
2483 * If datelen == 0, it should return the reguired string length.
2485 This function implements stuff for GetDateFormat() and
2488 d single-digit (no leading zero) day (of month)
2489 dd two-digit day (of month)
2490 ddd short day-of-week name
2491 dddd long day-of-week name
2492 M single-digit month
2494 MMM short month name
2495 MMMM full month name
2496 y two-digit year, no leading 0
2498 yyyy four-digit year
2500 h hours with no leading zero (12-hour)
2501 hh hours with full two digits
2502 H hours with no leading zero (24-hour)
2503 HH hours with full two digits
2504 m minutes with no leading zero
2505 mm minutes with full two digits
2506 s seconds with no leading zero
2507 ss seconds with full two digits
2508 t time marker (A or P)
2509 tt time marker (AM, PM)
2510 '' used to quote literal characters
2511 '' (within a quoted string) indicates a literal '
2513 These functions REQUIRE valid locale, date, and format.
2515 static INT OLE_GetFormatA(LCID locale,
2519 LPCSTR _format, /*in*/
2524 int count, type, inquote, Overflow;
2530 const char * _dgfmt[] = { "%d", "%02d" };
2531 const char ** dgfmt = _dgfmt - 1;
2533 /* report, for debugging */
2534 TRACE_(ole)("(0x%lx,0x%lx, 0x%lx, time(d=%d,h=%d,m=%d,s=%d), fmt=%p \'%s\' , %p, len=%d)\n",
2535 locale, flags, tflags,
2536 xtime->wDay, xtime->wHour, xtime->wMinute, xtime->wSecond,
2537 _format, _format, date, datelen);
2540 FIXME_(ole)("datelen = 0, returning 255\n");
2544 /* initalize state variables and output buffer */
2546 count = 0; inquote = 0; Overflow = 0;
2548 date[0] = buf[0] = '\0';
2550 strcpy(format,_format);
2552 /* alter the formatstring, while it works for all languages now in wine
2553 its possible that it fails when the time looks like ss:mm:hh as example*/
2554 if (tflags & (TIME_NOMINUTESORSECONDS))
2555 { if ((pos = strstr ( format, ":mm")))
2556 { memcpy ( pos, pos+3, strlen(format)-(pos-format)-2 );
2559 if (tflags & (TIME_NOSECONDS))
2560 { if ((pos = strstr ( format, ":ss")))
2561 { memcpy ( pos, pos+3, strlen(format)-(pos-format)-2 );
2565 for (inpos = 0;; inpos++) {
2566 /* 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]); */
2568 if (format[inpos] == '\'') {
2569 if (format[inpos+1] == '\'') {
2571 date[outpos++] = '\'';
2574 continue; /* we did nothing to the output */
2576 } else if (format[inpos] == '\0') {
2577 date[outpos++] = '\0';
2578 if (outpos > datelen) Overflow = 1;
2581 date[outpos++] = format[inpos];
2582 if (outpos > datelen) {
2584 date[outpos-1] = '\0'; /* this is the last place where
2585 it's safe to write */
2589 } else if ( (count && (format[inpos] != type))
2591 || (count == 2 && strchr("ghHmst", type)) )
2595 GetLocaleInfoA(locale,
2597 + xtime->wDayOfWeek - 1,
2599 } else if (count == 3) {
2600 GetLocaleInfoA(locale,
2601 LOCALE_SABBREVDAYNAME1
2602 + xtime->wDayOfWeek - 1,
2605 sprintf(buf, dgfmt[count], xtime->wDay);
2607 } else if (type == 'M') {
2609 GetLocaleInfoA(locale,
2610 LOCALE_SABBREVMONTHNAME1
2611 + xtime->wMonth - 1,
2613 } else if (count == 4) {
2614 GetLocaleInfoA(locale,
2616 + xtime->wMonth - 1,
2619 sprintf(buf, dgfmt[count], xtime->wMonth);
2621 } else if (type == 'y') {
2623 sprintf(buf, "%d", xtime->wYear);
2624 } else if (count == 3) {
2626 WARN_(ole)("unknown format, c=%c, n=%d\n", type, count);
2628 sprintf(buf, dgfmt[count], xtime->wYear % 100);
2630 } else if (type == 'g') {
2632 FIXME_(ole)("LOCALE_ICALENDARTYPE unimp.\n");
2636 WARN_(ole)("unknown format, c=%c, n=%d\n", type, count);
2638 } else if (type == 'h') {
2639 /* gives us hours 1:00 -- 12:00 */
2640 sprintf(buf, dgfmt[count], (xtime->wHour-1)%12 +1);
2641 } else if (type == 'H') {
2643 sprintf(buf, dgfmt[count], xtime->wHour);
2644 } else if ( type == 'm') {
2645 sprintf(buf, dgfmt[count], xtime->wMinute);
2646 } else if ( type == 's') {
2647 sprintf(buf, dgfmt[count], xtime->wSecond);
2648 } else if (type == 't') {
2650 sprintf(buf, "%c", (xtime->wHour < 12) ? 'A' : 'P');
2651 } else if (count == 2) {
2652 /* sprintf(buf, "%s", (xtime->wHour < 12) ? "AM" : "PM"); */
2653 GetLocaleInfoA(locale,
2655 ? LOCALE_S1159 : LOCALE_S2359,
2660 /* we need to check the next char in the format string
2661 again, no matter what happened */
2664 /* add the contents of buf to the output */
2665 buflen = strlen(buf);
2666 if (outpos + buflen < datelen) {
2667 date[outpos] = '\0'; /* for strcat to hook onto */
2671 date[outpos] = '\0';
2672 strncat(date, buf, datelen - outpos);
2673 date[datelen - 1] = '\0';
2674 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2675 WARN_(ole)("insufficient buffer\n");
2679 /* reset the variables we used to keep track of this item */
2682 } else if (format[inpos] == '\0') {
2683 /* we can't check for this at the loop-head, because
2684 that breaks the printing of the last format-item */
2685 date[outpos] = '\0';
2688 /* continuing a code for an item */
2691 } else if (strchr("hHmstyMdg", format[inpos])) {
2692 type = format[inpos];
2695 } else if (format[inpos] == '\'') {
2699 date[outpos++] = format[inpos];
2701 /* now deal with a possible buffer overflow */
2702 if (outpos >= datelen) {
2703 date[datelen - 1] = '\0';
2704 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2710 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2713 /* finish it off with a string terminator */
2716 if (outpos > datelen-1) outpos = datelen-1;
2717 date[outpos] = '\0';
2719 TRACE_(ole)("OLE_GetFormatA returns string '%s', len %d\n",
2724 /******************************************************************************
2725 * OLE_GetFormatW [INTERNAL]
2727 static INT OLE_GetFormatW(LCID locale, DWORD flags, DWORD tflags,
2730 LPWSTR output, INT outlen)
2733 int count, type=0, inquote;
2734 int Overflow; /* loop check */
2737 WCHAR arg0[] = {0}, arg1[] = {'%','d',0};
2738 WCHAR arg2[] = {'%','0','2','d',0};
2740 int datevars=0, timevars=0;
2746 /* make a debug report */
2747 TRACE_(ole)("args: 0x%lx, 0x%lx, 0x%lx, time(d=%d,h=%d,m=%d,s=%d), fmt:%s (at %p), "
2748 "%p with max len %d\n",
2749 locale, flags, tflags,
2750 xtime->wDay, xtime->wHour, xtime->wMinute, xtime->wSecond,
2751 debugstr_w(format), format, output, outlen);
2754 FIXME_(ole)("outlen = 0, returning 255\n");
2758 /* initialize state variables */
2761 inquote = Overflow = 0;
2762 /* this is really just a sanity check */
2763 output[0] = buf[0] = 0;
2765 /* this loop is the core of the function */
2766 for (inpos = 0; /* we have several break points */ ; inpos++) {
2768 if (format[inpos] == (WCHAR) '\'') {
2769 if (format[inpos+1] == '\'') {
2771 output[outpos++] = '\'';
2776 } else if (format[inpos] == 0) {
2777 output[outpos++] = 0;
2778 if (outpos > outlen) Overflow = 1;
2779 break; /* normal exit (within a quote) */
2781 output[outpos++] = format[inpos]; /* copy input */
2782 if (outpos > outlen) {
2784 output[outpos-1] = 0;
2788 } else if ( (count && (format[inpos] != type))
2789 || ( (count==4 && type =='y') ||
2790 (count==4 && type =='M') ||
2791 (count==4 && type =='d') ||
2792 (count==2 && type =='g') ||
2793 (count==2 && type =='h') ||
2794 (count==2 && type =='H') ||
2795 (count==2 && type =='m') ||
2796 (count==2 && type =='s') ||
2797 (count==2 && type =='t') ) ) {
2800 GetLocaleInfoW(locale,
2801 LOCALE_SDAYNAME1 + xtime->wDayOfWeek -1,
2802 buf, sizeof(buf)/sizeof(WCHAR) );
2803 } else if (count == 3) {
2804 GetLocaleInfoW(locale,
2805 LOCALE_SABBREVDAYNAME1 +
2806 xtime->wDayOfWeek -1,
2807 buf, sizeof(buf)/sizeof(WCHAR) );
2809 wsnprintfW(buf, 5, argarr[count], xtime->wDay );
2811 } else if (type == 'M') {
2813 GetLocaleInfoW(locale, LOCALE_SMONTHNAME1 +
2814 xtime->wMonth -1, buf,
2815 sizeof(buf)/sizeof(WCHAR) );
2816 } else if (count == 3) {
2817 GetLocaleInfoW(locale, LOCALE_SABBREVMONTHNAME1 +
2818 xtime->wMonth -1, buf,
2819 sizeof(buf)/sizeof(WCHAR) );
2821 wsnprintfW(buf, 5, argarr[count], xtime->wMonth);
2823 } else if (type == 'y') {
2825 wsnprintfW(buf, 6, argarr[1] /* "%d" */,
2827 } else if (count == 3) {
2828 lstrcpynAtoW(buf, "yyy", 5);
2830 wsnprintfW(buf, 6, argarr[count],
2831 xtime->wYear % 100);
2833 } else if (type == 'g') {
2835 FIXME_(ole)("LOCALE_ICALENDARTYPE unimplemented\n");
2836 lstrcpynAtoW(buf, "AD", 5);
2838 /* Win API sez we copy it verbatim */
2839 lstrcpynAtoW(buf, "g", 5);
2841 } else if (type == 'h') {
2842 /* hours 1:00-12:00 --- is this right? */
2843 wsnprintfW(buf, 5, argarr[count],
2844 (xtime->wHour-1)%12 +1);
2845 } else if (type == 'H') {
2846 wsnprintfW(buf, 5, argarr[count],
2848 } else if (type == 'm' ) {
2849 wsnprintfW(buf, 5, argarr[count],
2851 } else if (type == 's' ) {
2852 wsnprintfW(buf, 5, argarr[count],
2854 } else if (type == 't') {
2855 GetLocaleInfoW(locale, (xtime->wHour < 12) ?
2856 LOCALE_S1159 : LOCALE_S2359,
2863 /* no matter what happened, we need to check this next
2864 character the next time we loop through */
2867 /* cat buf onto the output */
2868 outlen = lstrlenW(buf);
2869 if (outpos + buflen < outlen) {
2870 lstrcpyW( output + outpos, buf );
2873 lstrcpynW( output + outpos, buf, outlen - outpos );
2875 break; /* Abnormal exit */
2878 /* reset the variables we used this time */
2881 } else if (format[inpos] == 0) {
2882 /* we can't check for this at the beginning, because that
2883 would keep us from printing a format spec that ended the
2886 break; /* NORMAL EXIT */
2888 /* how we keep track of the middle of a format spec */
2891 } else if ( (datevars && (format[inpos]=='d' ||
2892 format[inpos]=='M' ||
2893 format[inpos]=='y' ||
2894 format[inpos]=='g') ) ||
2895 (timevars && (format[inpos]=='H' ||
2896 format[inpos]=='h' ||
2897 format[inpos]=='m' ||
2898 format[inpos]=='s' ||
2899 format[inpos]=='t') ) ) {
2900 type = format[inpos];
2903 } else if (format[inpos] == '\'') {
2907 /* unquoted literals */
2908 output[outpos++] = format[inpos];
2913 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2914 WARN_(ole)(" buffer overflow\n");
2917 /* final string terminator and sanity check */
2919 if (outpos > outlen-1) outpos = outlen-1;
2920 output[outpos] = '0';
2922 TRACE_(ole)(" returning %s\n", debugstr_w(output));
2924 return (!Overflow) ? outlen : 0;
2929 /******************************************************************************
2930 * GetDateFormat32A [KERNEL32.310]
2931 * Makes an ASCII string of the date
2933 * This function uses format to format the date, or, if format
2934 * is NULL, uses the default for the locale. format is a string
2935 * of literal fields and characters as follows:
2937 * - d single-digit (no leading zero) day (of month)
2938 * - dd two-digit day (of month)
2939 * - ddd short day-of-week name
2940 * - dddd long day-of-week name
2941 * - M single-digit month
2942 * - MM two-digit month
2943 * - MMM short month name
2944 * - MMMM full month name
2945 * - y two-digit year, no leading 0
2946 * - yy two-digit year
2947 * - yyyy four-digit year
2951 INT WINAPI GetDateFormatA(LCID locale,DWORD flags,
2953 LPCSTR format, LPSTR date,INT datelen)
2956 char format_buf[40];
2959 LPSYSTEMTIME thistime;
2963 TRACE_(ole)("(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",
2964 locale,flags,xtime,format,date,datelen);
2967 locale = LOCALE_SYSTEM_DEFAULT;
2970 if (locale == LOCALE_SYSTEM_DEFAULT) {
2971 thislocale = GetSystemDefaultLCID();
2972 } else if (locale == LOCALE_USER_DEFAULT) {
2973 thislocale = GetUserDefaultLCID();
2975 thislocale = locale;
2978 if (xtime == NULL) {
2985 if (format == NULL) {
2986 GetLocaleInfoA(thislocale, ((flags&DATE_LONGDATE)
2988 : LOCALE_SSHORTDATE),
2989 format_buf, sizeof(format_buf));
2990 thisformat = format_buf;
2992 thisformat = format;
2996 ret = OLE_GetFormatA(thislocale, flags, 0, thistime, thisformat,
3001 "GetDateFormat32A() returning %d, with data=%s\n",
3006 /******************************************************************************
3007 * GetDateFormat32W [KERNEL32.311]
3008 * Makes a Unicode string of the date
3010 * Acts the same as GetDateFormat32A(), except that it's Unicode.
3011 * Accepts & returns sizes as counts of Unicode characters.
3014 INT WINAPI GetDateFormatW(LCID locale,DWORD flags,
3017 LPWSTR date, INT datelen)
3019 unsigned short datearr[] = {'1','9','9','4','-','1','-','1',0};
3021 FIXME_(ole)("STUB (should call OLE_GetFormatW)\n");
3022 lstrcpynW(date, datearr, datelen);
3023 return ( datelen < 9) ? datelen : 9;
3028 /**************************************************************************
3029 * EnumDateFormats32A (KERNEL32.198)
3031 BOOL WINAPI EnumDateFormatsA(
3032 DATEFMT_ENUMPROCA lpDateFmtEnumProc, LCID Locale, DWORD dwFlags)
3034 FIXME_(ole)("Only US English supported\n");
3036 if(!lpDateFmtEnumProc)
3038 SetLastError(ERROR_INVALID_PARAMETER);
3044 case DATE_SHORTDATE:
3045 if(!(*lpDateFmtEnumProc)("M/d/yy")) return TRUE;
3046 if(!(*lpDateFmtEnumProc)("M/d/yyyy")) return TRUE;
3047 if(!(*lpDateFmtEnumProc)("MM/dd/yy")) return TRUE;
3048 if(!(*lpDateFmtEnumProc)("MM/dd/yyyy")) return TRUE;
3049 if(!(*lpDateFmtEnumProc)("yy/MM/dd")) return TRUE;
3050 if(!(*lpDateFmtEnumProc)("dd-MMM-yy")) return TRUE;
3053 if(!(*lpDateFmtEnumProc)("dddd, MMMM dd, yyyy")) return TRUE;
3054 if(!(*lpDateFmtEnumProc)("MMMM dd, yyyy")) return TRUE;
3055 if(!(*lpDateFmtEnumProc)("dddd, dd MMMM, yyyy")) return TRUE;
3056 if(!(*lpDateFmtEnumProc)("dd MMMM, yyyy")) return TRUE;
3059 FIXME_(ole)("Unknown date format (%ld)\n", dwFlags);
3060 SetLastError(ERROR_INVALID_PARAMETER);
3065 /**************************************************************************
3066 * EnumDateFormats32W (KERNEL32.199)
3068 BOOL WINAPI EnumDateFormatsW(
3069 DATEFMT_ENUMPROCW lpDateFmtEnumProc, LCID Locale, DWORD dwFlags)
3071 FIXME_(ole)("(%p, %ld, %ld): stub\n", lpDateFmtEnumProc, Locale, dwFlags);
3072 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
3076 /**************************************************************************
3077 * EnumTimeFormats32A (KERNEL32.210)
3079 BOOL WINAPI EnumTimeFormatsA(
3080 TIMEFMT_ENUMPROCA lpTimeFmtEnumProc, LCID Locale, DWORD dwFlags)
3082 FIXME_(ole)("Only US English supported\n");
3084 if(!lpTimeFmtEnumProc)
3086 SetLastError(ERROR_INVALID_PARAMETER);
3092 FIXME_(ole)("Unknown time format (%ld)\n", dwFlags);
3095 if(!(*lpTimeFmtEnumProc)("h:mm:ss tt")) return TRUE;
3096 if(!(*lpTimeFmtEnumProc)("hh:mm:ss tt")) return TRUE;
3097 if(!(*lpTimeFmtEnumProc)("H:mm:ss")) return TRUE;
3098 if(!(*lpTimeFmtEnumProc)("HH:mm:ss")) return TRUE;
3103 /**************************************************************************
3104 * EnumTimeFormats32W (KERNEL32.211)
3106 BOOL WINAPI EnumTimeFormatsW(
3107 TIMEFMT_ENUMPROCW lpTimeFmtEnumProc, LCID Locale, DWORD dwFlags)
3109 FIXME_(ole)("(%p,%ld,%ld): stub\n", lpTimeFmtEnumProc, Locale, dwFlags);
3110 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
3114 /**************************************************************************
3115 * GetNumberFormat32A (KERNEL32.355)
3117 INT WINAPI GetNumberFormatA(LCID locale, DWORD dwflags,
3118 LPCSTR lpvalue, const NUMBERFMTA * lpFormat,
3119 LPSTR lpNumberStr, int cchNumber)
3121 FIXME_(file)("%s: stub, no reformating done\n",lpvalue);
3123 lstrcpynA( lpNumberStr, lpvalue, cchNumber );
3124 return cchNumber? lstrlenA( lpNumberStr ) : 0;
3126 /**************************************************************************
3127 * GetNumberFormat32W (KERNEL32.xxx)
3129 INT WINAPI GetNumberFormatW(LCID locale, DWORD dwflags,
3130 LPCWSTR lpvalue, const NUMBERFMTW * lpFormat,
3131 LPWSTR lpNumberStr, int cchNumber)
3133 FIXME_(file)("%s: stub, no reformating done\n",debugstr_w(lpvalue));
3135 lstrcpynW( lpNumberStr, lpvalue, cchNumber );
3136 return cchNumber? lstrlenW( lpNumberStr ) : 0;
3138 /******************************************************************************
3139 * OLE2NLS_CheckLocale [intern]
3141 static LCID OLE2NLS_CheckLocale (LCID locale)
3144 { locale = LOCALE_SYSTEM_DEFAULT;
3147 if (locale == LOCALE_SYSTEM_DEFAULT)
3148 { return GetSystemDefaultLCID();
3150 else if (locale == LOCALE_USER_DEFAULT)
3151 { return GetUserDefaultLCID();
3157 /******************************************************************************
3158 * GetTimeFormat32A [KERNEL32.422]
3159 * Makes an ASCII string of the time
3161 * Formats date according to format, or locale default if format is
3162 * NULL. The format consists of literal characters and fields as follows:
3164 * h hours with no leading zero (12-hour)
3165 * hh hours with full two digits
3166 * H hours with no leading zero (24-hour)
3167 * HH hours with full two digits
3168 * m minutes with no leading zero
3169 * mm minutes with full two digits
3170 * s seconds with no leading zero
3171 * ss seconds with full two digits
3172 * t time marker (A or P)
3173 * tt time marker (AM, PM)
3177 GetTimeFormatA(LCID locale, /* in */
3178 DWORD flags, /* in */
3179 LPSYSTEMTIME xtime, /* in */
3180 LPCSTR format, /* in */
3181 LPSTR timestr, /* out */
3182 INT timelen /* in */)
3183 { char format_buf[40];
3186 LPSYSTEMTIME thistime;
3188 DWORD thisflags=LOCALE_STIMEFORMAT; /* standart timeformat */
3191 TRACE_(ole)("GetTimeFormat(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",locale,flags,xtime,format,timestr,timelen);
3193 thislocale = OLE2NLS_CheckLocale ( locale );
3195 if ( flags & (TIME_NOTIMEMARKER | TIME_FORCE24HOURFORMAT ))
3196 { FIXME_(ole)("TIME_NOTIMEMARKER or TIME_FORCE24HOURFORMAT not implemented\n");
3199 flags &= (TIME_NOSECONDS | TIME_NOMINUTESORSECONDS); /* mask for OLE_GetFormatA*/
3202 { if (flags & LOCALE_NOUSEROVERRIDE) /*use system default*/
3203 { thislocale = GetSystemDefaultLCID();
3205 GetLocaleInfoA(thislocale, thisflags, format_buf, sizeof(format_buf));
3206 thisformat = format_buf;
3209 { thisformat = format;
3212 if (xtime == NULL) /* NULL means use the current local time*/
3219 ret = OLE_GetFormatA(thislocale, thisflags, flags, thistime, thisformat,
3225 /******************************************************************************
3226 * GetTimeFormat32W [KERNEL32.423]
3227 * Makes a Unicode string of the time
3230 GetTimeFormatW(LCID locale, /* in */
3231 DWORD flags, /* in */
3232 LPSYSTEMTIME xtime, /* in */
3233 LPCWSTR format, /* in */
3234 LPWSTR timestr, /* out */
3235 INT timelen /* in */)
3236 { WCHAR format_buf[40];
3239 LPSYSTEMTIME thistime;
3241 DWORD thisflags=LOCALE_STIMEFORMAT; /* standart timeformat */
3244 TRACE_(ole)("GetTimeFormat(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",locale,flags,
3245 xtime,debugstr_w(format),timestr,timelen);
3247 thislocale = OLE2NLS_CheckLocale ( locale );
3249 if ( flags & (TIME_NOTIMEMARKER | TIME_FORCE24HOURFORMAT ))
3250 { FIXME_(ole)("TIME_NOTIMEMARKER or TIME_FORCE24HOURFORMAT not implemented\n");
3253 flags &= (TIME_NOSECONDS | TIME_NOMINUTESORSECONDS); /* mask for OLE_GetFormatA*/
3256 { if (flags & LOCALE_NOUSEROVERRIDE) /*use system default*/
3257 { thislocale = GetSystemDefaultLCID();
3259 GetLocaleInfoW(thislocale, thisflags, format_buf, 40);
3260 thisformat = format_buf;
3263 { thisformat = format;
3266 if (xtime == NULL) /* NULL means use the current local time*/
3267 { GetSystemTime(&t);
3274 ret = OLE_GetFormatW(thislocale, thisflags, flags, thistime, thisformat,
3279 /******************************************************************************
3280 * EnumCalendarInfoA [KERNEL32.196]
3282 BOOL WINAPI EnumCalendarInfoA(
3283 CALINFO_ENUMPROCA calinfoproc,LCID locale,CALID calendar,CALTYPE caltype
3285 FIXME_(ole)("(%p,0x%04lx,0x%08lx,0x%08lx),stub!\n",calinfoproc,locale,calendar,caltype);