4 * Copyright 1995 Martin von Loewis
5 * Copyright 1998 David Lee Lambert
20 struct NLS_langlocale
{
22 struct NLS_localevar
{
28 #define LANG_BEGIN(l,s) { MAKELANGID(l,s), {
30 #define LOCVAL(type,value) {type,value},
34 static const struct NLS_langlocale langlocales
[] = {
35 /* add languages in numerical order of main language (last two digits)
36 * it is much easier to find the missing holes that way */
38 LANG_BEGIN (LANG_CATALAN
, SUBLANG_DEFAULT
) /*0x0403*/
39 #include "nls/cat.nls"
42 LANG_BEGIN (LANG_CZECH
, SUBLANG_DEFAULT
) /*0x0405*/
43 #include "nls/cze.nls"
46 LANG_BEGIN (LANG_DANISH
, SUBLANG_DEFAULT
) /*0x0406*/
47 #include "nls/dan.nls"
50 LANG_BEGIN (LANG_GERMAN
, SUBLANG_GERMAN
) /*0x0407*/
51 #include "nls/deu.nls"
53 LANG_BEGIN (LANG_GERMAN
, SUBLANG_GERMAN_SWISS
) /*0x0807*/
54 #include "nls/des.nls"
56 LANG_BEGIN (LANG_GERMAN
, SUBLANG_GERMAN_AUSTRIAN
) /*0x0C07*/
57 #include "nls/dea.nls"
59 LANG_BEGIN (LANG_GERMAN
, SUBLANG_GERMAN_LUXEMBOURG
) /*0x1007*/
60 #include "nls/del.nls"
62 LANG_BEGIN (LANG_GERMAN
, SUBLANG_GERMAN_LIECHTENSTEIN
) /*0x1407*/
63 #include "nls/dec.nls"
66 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_US
) /*0x0409*/
67 #include "nls/enu.nls"
69 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_UK
) /*0x0809*/
70 #include "nls/eng.nls"
72 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_AUS
) /*0x0C09*/
73 #include "nls/ena.nls"
75 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_CAN
) /*0x1009*/
76 #include "nls/enc.nls"
78 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_NZ
) /*0x1409*/
79 #include "nls/enz.nls"
81 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_EIRE
) /*0x1809*/
82 #include "nls/irl.nls"
84 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_SAFRICA
) /*0x1C09*/
85 #include "nls/ens.nls"
87 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_JAMAICA
) /*0x2009*/
88 #include "nls/enj.nls"
90 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_CARRIBEAN
) /*0x2409*/
91 #include "nls/enb.nls"
93 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_BELIZE
) /*0x2809*/
94 #include "nls/enl.nls"
96 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_TRINIDAD
) /*0x2C09*/
97 #include "nls/ent.nls"
100 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH
) /*0x040a*/
101 #include "nls/esp.nls"
103 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_MEXICAN
) /*0x080a*/
104 #include "nls/esm.nls"
106 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_MODERN
) /*0x0C0a*/
107 #include "nls/esn.nls"
109 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_GUATEMALA
) /*0x100a*/
110 #include "nls/esg.nls"
112 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_COSTARICA
) /*0x140a*/
113 #include "nls/esc.nls"
115 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_PANAMA
) /*0x180a*/
116 #include "nls/esa.nls"
118 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_DOMINICAN
) /*0x1C0A*/
119 #include "nls/esd.nls"
121 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_VENEZUELA
) /*0x200a*/
122 #include "nls/esv.nls"
124 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_COLOMBIA
) /*0x240a*/
125 #include "nls/eso.nls"
127 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_PERU
) /*0x280a*/
128 #include "nls/esr.nls"
130 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_ARGENTINA
) /*0x2c0a*/
131 #include "nls/ess.nls"
133 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_ECUADOR
) /*0x300a*/
134 #include "nls/esf.nls"
136 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_CHILE
) /*0x340a*/
137 #include "nls/esl.nls"
139 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_URUGUAY
) /*0x380a*/
140 #include "nls/esy.nls"
142 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_PARAGUAY
) /*0x3c0a*/
143 #include "nls/esz.nls"
145 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_BOLIVIA
) /*0x400a*/
146 #include "nls/esb.nls"
148 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_EL_SALVADOR
) /*0x440a*/
149 #include "nls/ese.nls"
151 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_HONDURAS
) /*0x480a*/
152 #include "nls/esh.nls"
154 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_NICARAGUA
) /*0x4c0a*/
155 #include "nls/esi.nls"
157 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_PUERTO_RICO
) /*0x500a*/
158 #include "nls/esu.nls"
161 LANG_BEGIN (LANG_FINNISH
, SUBLANG_DEFAULT
) /*0x040B*/
162 #include "nls/fin.nls"
165 LANG_BEGIN (LANG_FRENCH
, SUBLANG_FRENCH
) /*0x040C*/
166 #include "nls/fra.nls"
168 LANG_BEGIN (LANG_FRENCH
, SUBLANG_FRENCH_BELGIAN
) /*0x080C*/
169 #include "nls/frb.nls"
171 LANG_BEGIN (LANG_FRENCH
, SUBLANG_FRENCH_CANADIAN
) /*0x0C0C*/
172 #include "nls/frc.nls"
174 LANG_BEGIN (LANG_FRENCH
, SUBLANG_FRENCH_SWISS
) /*0x100C*/
175 #include "nls/frs.nls"
177 LANG_BEGIN (LANG_FRENCH
, SUBLANG_FRENCH_LUXEMBOURG
) /*0x140C*/
178 #include "nls/frl.nls"
181 LANG_BEGIN (LANG_HUNGARIAN
, SUBLANG_DEFAULT
) /*0x040e*/
182 #include "nls/hun.nls"
185 LANG_BEGIN (LANG_ITALIAN
, SUBLANG_ITALIAN
) /*0x0410*/
186 #include "nls/ita.nls"
188 LANG_BEGIN (LANG_ITALIAN
, SUBLANG_ITALIAN_SWISS
) /*0x0810*/
189 #include "nls/its.nls"
192 LANG_BEGIN (LANG_KOREAN
, SUBLANG_KOREAN
) /*0x0412*/
193 #include "nls/kor.nls"
196 LANG_BEGIN (LANG_DUTCH
, SUBLANG_DUTCH
) /*0x0413*/
197 #include "nls/nld.nls"
199 LANG_BEGIN (LANG_DUTCH
, SUBLANG_DUTCH_BELGIAN
) /*0x0813*/
200 #include "nls/nlb.nls"
202 LANG_BEGIN (LANG_DUTCH
, SUBLANG_DUTCH_SURINAM
) /*0x0C13*/
203 #include "nls/nls.nls"
206 LANG_BEGIN (LANG_NORWEGIAN
, SUBLANG_NORWEGIAN_BOKMAL
) /*0x0414*/
207 #include "nls/nor.nls"
209 LANG_BEGIN (LANG_NORWEGIAN
, SUBLANG_NORWEGIAN_NYNORSK
) /*0x0814*/
210 #include "nls/non.nls"
213 LANG_BEGIN (LANG_POLISH
, SUBLANG_DEFAULT
) /*0x0415*/
214 #include "nls/plk.nls"
217 LANG_BEGIN (LANG_PORTUGUESE
,SUBLANG_PORTUGUESE_BRAZILIAN
) /*0x0416*/
218 #include "nls/ptb.nls"
220 LANG_BEGIN (LANG_PORTUGUESE
,SUBLANG_PORTUGUESE
) /*0x0816*/
221 #include "nls/ptg.nls"
224 LANG_BEGIN (LANG_SLOVAK
, SUBLANG_DEFAULT
) /*0x041b*/
225 #include "nls/sky.nls"
228 LANG_BEGIN (LANG_SWEDISH
, SUBLANG_SWEDISH
) /*0x041d*/
229 #include "nls/sve.nls"
231 LANG_BEGIN (LANG_SWEDISH
, SUBLANG_SWEDISH_FINLAND
) /*0x081d*/
232 #include "nls/svf.nls"
235 LANG_BEGIN (LANG_THAI
, SUBLANG_DEFAULT
) /*0x41e*/
236 #include "nls/tha.nls"
239 LANG_BEGIN (LANG_ESPERANTO
, SUBLANG_DEFAULT
) /*0x048f*/
240 #include "nls/esperanto.nls"
245 /* Locale name to id map. used by EnumSystemLocales, GetLocalInfoA
246 * MUST contain all #defines from winnls.h
247 * last entry has NULL name, 0 id.
249 #define LOCALE_ENTRY(x) {#x,LOCALE_##x}
250 static struct tagLOCALE_NAME2ID
{
253 } locale_name2id
[]= {
254 LOCALE_ENTRY(ILANGUAGE
),
255 LOCALE_ENTRY(SLANGUAGE
),
256 LOCALE_ENTRY(SENGLANGUAGE
),
257 LOCALE_ENTRY(SABBREVLANGNAME
),
258 LOCALE_ENTRY(SNATIVELANGNAME
),
259 LOCALE_ENTRY(ICOUNTRY
),
260 LOCALE_ENTRY(SCOUNTRY
),
261 LOCALE_ENTRY(SENGCOUNTRY
),
262 LOCALE_ENTRY(SABBREVCTRYNAME
),
263 LOCALE_ENTRY(SNATIVECTRYNAME
),
264 LOCALE_ENTRY(IDEFAULTLANGUAGE
),
265 LOCALE_ENTRY(IDEFAULTCOUNTRY
),
266 LOCALE_ENTRY(IDEFAULTCODEPAGE
),
267 LOCALE_ENTRY(IDEFAULTANSICODEPAGE
),
268 LOCALE_ENTRY(IDEFAULTMACCODEPAGE
),
270 LOCALE_ENTRY(IMEASURE
),
271 LOCALE_ENTRY(SDECIMAL
),
272 LOCALE_ENTRY(STHOUSAND
),
273 LOCALE_ENTRY(SGROUPING
),
274 LOCALE_ENTRY(IDIGITS
),
275 LOCALE_ENTRY(ILZERO
),
276 LOCALE_ENTRY(INEGNUMBER
),
277 LOCALE_ENTRY(SNATIVEDIGITS
),
278 LOCALE_ENTRY(SCURRENCY
),
279 LOCALE_ENTRY(SINTLSYMBOL
),
280 LOCALE_ENTRY(SMONDECIMALSEP
),
281 LOCALE_ENTRY(SMONTHOUSANDSEP
),
282 LOCALE_ENTRY(SMONGROUPING
),
283 LOCALE_ENTRY(ICURRDIGITS
),
284 LOCALE_ENTRY(IINTLCURRDIGITS
),
285 LOCALE_ENTRY(ICURRENCY
),
286 LOCALE_ENTRY(INEGCURR
),
289 LOCALE_ENTRY(SSHORTDATE
),
290 LOCALE_ENTRY(SLONGDATE
),
291 LOCALE_ENTRY(STIMEFORMAT
),
293 LOCALE_ENTRY(ILDATE
),
295 LOCALE_ENTRY(ITIMEMARKPOSN
),
296 LOCALE_ENTRY(ICENTURY
),
297 LOCALE_ENTRY(ITLZERO
),
298 LOCALE_ENTRY(IDAYLZERO
),
299 LOCALE_ENTRY(IMONLZERO
),
302 LOCALE_ENTRY(ICALENDARTYPE
),
303 LOCALE_ENTRY(IOPTIONALCALENDAR
),
304 LOCALE_ENTRY(IFIRSTDAYOFWEEK
),
305 LOCALE_ENTRY(IFIRSTWEEKOFYEAR
),
306 LOCALE_ENTRY(SDAYNAME1
),
307 LOCALE_ENTRY(SDAYNAME2
),
308 LOCALE_ENTRY(SDAYNAME3
),
309 LOCALE_ENTRY(SDAYNAME4
),
310 LOCALE_ENTRY(SDAYNAME5
),
311 LOCALE_ENTRY(SDAYNAME6
),
312 LOCALE_ENTRY(SDAYNAME7
),
313 LOCALE_ENTRY(SABBREVDAYNAME1
),
314 LOCALE_ENTRY(SABBREVDAYNAME2
),
315 LOCALE_ENTRY(SABBREVDAYNAME3
),
316 LOCALE_ENTRY(SABBREVDAYNAME4
),
317 LOCALE_ENTRY(SABBREVDAYNAME5
),
318 LOCALE_ENTRY(SABBREVDAYNAME6
),
319 LOCALE_ENTRY(SABBREVDAYNAME7
),
320 LOCALE_ENTRY(SMONTHNAME1
),
321 LOCALE_ENTRY(SMONTHNAME2
),
322 LOCALE_ENTRY(SMONTHNAME3
),
323 LOCALE_ENTRY(SMONTHNAME4
),
324 LOCALE_ENTRY(SMONTHNAME5
),
325 LOCALE_ENTRY(SMONTHNAME6
),
326 LOCALE_ENTRY(SMONTHNAME7
),
327 LOCALE_ENTRY(SMONTHNAME8
),
328 LOCALE_ENTRY(SMONTHNAME9
),
329 LOCALE_ENTRY(SMONTHNAME10
),
330 LOCALE_ENTRY(SMONTHNAME11
),
331 LOCALE_ENTRY(SMONTHNAME12
),
332 LOCALE_ENTRY(SMONTHNAME13
),
333 LOCALE_ENTRY(SABBREVMONTHNAME1
),
334 LOCALE_ENTRY(SABBREVMONTHNAME2
),
335 LOCALE_ENTRY(SABBREVMONTHNAME3
),
336 LOCALE_ENTRY(SABBREVMONTHNAME4
),
337 LOCALE_ENTRY(SABBREVMONTHNAME5
),
338 LOCALE_ENTRY(SABBREVMONTHNAME6
),
339 LOCALE_ENTRY(SABBREVMONTHNAME7
),
340 LOCALE_ENTRY(SABBREVMONTHNAME8
),
341 LOCALE_ENTRY(SABBREVMONTHNAME9
),
342 LOCALE_ENTRY(SABBREVMONTHNAME10
),
343 LOCALE_ENTRY(SABBREVMONTHNAME11
),
344 LOCALE_ENTRY(SABBREVMONTHNAME12
),
345 LOCALE_ENTRY(SABBREVMONTHNAME13
),
346 LOCALE_ENTRY(SPOSITIVESIGN
),
347 LOCALE_ENTRY(SNEGATIVESIGN
),
348 LOCALE_ENTRY(IPOSSIGNPOSN
),
349 LOCALE_ENTRY(INEGSIGNPOSN
),
350 LOCALE_ENTRY(IPOSSYMPRECEDES
),
351 LOCALE_ENTRY(IPOSSEPBYSPACE
),
352 LOCALE_ENTRY(INEGSYMPRECEDES
),
353 LOCALE_ENTRY(INEGSEPBYSPACE
),
354 LOCALE_ENTRY(FONTSIGNATURE
),
355 LOCALE_ENTRY(SISO639LANGNAME
),
356 LOCALE_ENTRY(SISO3166CTRYNAME
),
360 const struct map_lcid2str
{
362 const char *langname
;
364 {0x0401,"Arabic (Saudi Arabia)"},
365 {0x0801,"Arabic (Iraq)"},
366 {0x0c01,"Arabic (Egypt)"},
367 {0x1001,"Arabic (Libya)"},
368 {0x1401,"Arabic (Algeria)"},
369 {0x1801,"Arabic (Morocco)"},
370 {0x1c01,"Arabic (Tunisia)"},
371 {0x2001,"Arabic (Oman)"},
372 {0x2401,"Arabic (Yemen)"},
373 {0x2801,"Arabic (Syria)"},
374 {0x2c01,"Arabic (Jordan)"},
375 {0x3001,"Arabic (Lebanon)"},
376 {0x3401,"Arabic (Kuwait)"},
377 {0x3801,"Arabic (United Arab Emirates)"},
378 {0x3c01,"Arabic (Bahrain)"},
379 {0x4001,"Arabic (Qatar)"},
380 {0x0402,"Bulgarian"},
382 {0x0404,"Chinese (Taiwan)"},
383 {0x0804,"Chinese (People's Republic of China)"},
384 {0x0c04,"Chinese (Hong Kong)"},
385 {0x1004,"Chinese (Singapore)"},
386 {0x1404,"Chinese (Macau)"},
389 {0x0407,"German (Germany)"},
390 {0x0807,"German (Switzerland)"},
391 {0x0c07,"German (Austria)"},
392 {0x1007,"German (Luxembourg)"},
393 {0x1407,"German (Liechtenstein)"},
395 {0x0409,"English (United States)"},
396 {0x0809,"English (United Kingdom)"},
397 {0x0c09,"English (Australia)"},
398 {0x1009,"English (Canada)"},
399 {0x1409,"English (New Zealand)"},
400 {0x1809,"English (Ireland)"},
401 {0x1c09,"English (South Africa)"},
402 {0x2009,"English (Jamaica)"},
403 {0x2409,"English (Caribbean)"},
404 {0x2809,"English (Belize)"},
405 {0x2c09,"English (Trinidad)"},
406 {0x3009,"English (Zimbabwe)"},
407 {0x3409,"English (Philippines)"},
408 {0x040a,"Spanish (Spain, traditional sorting)"},
409 {0x080a,"Spanish (Mexico)"},
410 {0x0c0a,"Spanish (Spain, international sorting)"},
411 {0x100a,"Spanish (Guatemala)"},
412 {0x140a,"Spanish (Costa Rica)"},
413 {0x180a,"Spanish (Panama)"},
414 {0x1c0a,"Spanish (Dominican Republic)"},
415 {0x200a,"Spanish (Venezuela)"},
416 {0x240a,"Spanish (Colombia)"},
417 {0x280a,"Spanish (Peru)"},
418 {0x2c0a,"Spanish (Argentina)"},
419 {0x300a,"Spanish (Ecuador)"},
420 {0x340a,"Spanish (Chile)"},
421 {0x380a,"Spanish (Uruguay)"},
422 {0x3c0a,"Spanish (Paraguay)"},
423 {0x400a,"Spanish (Bolivia)"},
424 {0x440a,"Spanish (El Salvador)"},
425 {0x480a,"Spanish (Honduras)"},
426 {0x4c0a,"Spanish (Nicaragua)"},
427 {0x500a,"Spanish (Puerto Rico)"},
429 {0x040c,"French (France)"},
430 {0x080c,"French (Belgium)"},
431 {0x0c0c,"French (Canada)"},
432 {0x100c,"French (Switzerland)"},
433 {0x140c,"French (Luxembourg)"},
434 {0x180c,"French (Monaco)"},
436 {0x040e,"Hungarian"},
437 {0x040f,"Icelandic"},
438 {0x0410,"Italian (Italy)"},
439 {0x0810,"Italian (Switzerland)"},
441 {0x0412,"Korean (Wansung)"},
442 {0x0812,"Korean (Johab)"},
443 {0x0413,"Dutch (Netherlands)"},
444 {0x0813,"Dutch (Belgium)"},
445 {0x0414,"Norwegian (Bokmal)"},
446 {0x0814,"Norwegian (Nynorsk)"},
448 {0x0416,"Portuguese (Brazil)"},
449 {0x0816,"Portuguese (Portugal)"},
450 {0x0417,"Rhaeto Romanic"},
452 {0x0818,"Moldavian"},
453 {0x0419,"Russian (Russia)"},
454 {0x0819,"Russian (Moldavia)"},
456 {0x081a,"Serbian (latin)"},
457 {0x0c1a,"Serbian (cyrillic)"},
460 {0x041d,"Swedish (Sweden)"},
461 {0x081d,"Swedish (Finland)"},
465 {0x0421,"Indonesian"},
466 {0x0422,"Ukrainian"},
467 {0x0423,"Belarusian"},
471 {0x0427,"Lithuanian (modern)"},
472 {0x0827,"Lithuanian (classic)"},
475 {0x042a,"Vietnamese"},
477 {0x042c,"Azeri (latin)"},
478 {0x082c,"Azeri (cyrillic)"},
481 {0x042f,"Macedonian"},
488 {0x0436,"Afrikaans"},
494 {0x043c,"Irish gaelic"},
495 {0x083c,"Scottish gaelic"},
496 {0x043e,"Malay (Malaysia)"},
497 {0x083e,"Malay (Brunei Darussalam)"},
500 {0x0443,"Uzbek (latin)"},
501 {0x0843,"Uzbek (cyrillic)"},
510 {0x044c,"Malayalam"},
515 {0x048f,"Esperanto"}, /* Non official */
519 {0x0402,"Bulgarisch"},
520 {0x0403,"Katalanisch"},
521 {0x0404,"Traditionales Chinesisch"},
522 {0x0405,"Tschecisch"},
525 {0x0408,"Griechisch"},
526 {0x0409,"Amerikanisches Englisch"},
527 {0x040A,"Kastilisches Spanisch"},
529 {0x040C,"Franzvsisch"},
530 {0x040D,"Hebrdisch"},
531 {0x040E,"Ungarisch"},
532 {0x040F,"Isldndisch"},
533 {0x0410,"Italienisch"},
534 {0x0411,"Japanisch"},
535 {0x0412,"Koreanisch"},
536 {0x0413,"Niederldndisch"},
537 {0x0414,"Norwegisch-Bokmal"},
539 {0x0416,"Brasilianisches Portugiesisch"},
540 {0x0417,"Rdtoromanisch"},
541 {0x0418,"Rumdnisch"},
543 {0x041A,"Kroatoserbisch (lateinisch)"},
544 {0x041B,"Slowenisch"},
545 {0x041C,"Albanisch"},
546 {0x041D,"Schwedisch"},
551 {0x0804,"Vereinfachtes Chinesisch"},
552 {0x0807,"Schweizerdeutsch"},
553 {0x0809,"Britisches Englisch"},
554 {0x080A,"Mexikanisches Spanisch"},
555 {0x080C,"Belgisches Franzvsisch"},
556 {0x0810,"Schweizerisches Italienisch"},
557 {0x0813,"Belgisches Niederldndisch"},
558 {0x0814,"Norgwegisch-Nynorsk"},
559 {0x0816,"Portugiesisch"},
560 {0x081A,"Serbokratisch (kyrillisch)"},
561 {0x0C1C,"Kanadisches Franzvsisch"},
562 {0x100C,"Schweizerisches Franzvsisch"},
563 {0x0000,"Unbekannt"},
566 /***********************************************************************
567 * GetUserDefaultLCID (OLE2NLS.1)
569 LCID WINAPI
GetUserDefaultLCID()
571 return MAKELCID( GetUserDefaultLangID() , SORT_DEFAULT
);
574 /***********************************************************************
575 * GetSystemDefaultLCID (OLE2NLS.2)
577 LCID WINAPI
GetSystemDefaultLCID()
579 return GetUserDefaultLCID();
582 /***********************************************************************
583 * GetUserDefaultLangID (OLE2NLS.3)
585 LANGID WINAPI
GetUserDefaultLangID()
587 /* caching result, if defined from environment, which should (?) not change during a WINE session */
588 static LANGID userLCID
= 0;
589 if (Options
.language
) {
590 return Languages
[Options
.language
].langid
;
595 char *lang
,*country
,*charset
,*dialect
,*next
;
598 buf
=getenv("LANGUAGE");
599 if (!buf
) buf
=getenv("LANG");
600 if (!buf
) buf
=getenv("LC_ALL");
601 if (!buf
) buf
=getenv("LC_MESSAGES");
602 if (!buf
) buf
=getenv("LC_CTYPE");
603 if (!buf
) return userLCID
= MAKELANGID( LANG_ENGLISH
, SUBLANG_DEFAULT
);
605 if (!strcmp(buf
,"POSIX") || !strcmp(buf
,"C")) {
606 return MAKELANGID( LANG_ENGLISH
, SUBLANG_DEFAULT
);
612 next
=strchr(lang
,':'); if (next
) *next
++='\0';
613 dialect
=strchr(lang
,'@'); if (dialect
) *dialect
++='\0';
614 charset
=strchr(lang
,'.'); if (charset
) *charset
++='\0';
615 country
=strchr(lang
,'_'); if (country
) *country
++='\0';
617 ret
=MAIN_GetLanguageID(lang
, country
, charset
, dialect
);
621 } while (lang
&& !ret
);
623 /* FIXME : are strings returned by getenv() to be free()'ed ? */
624 userLCID
= (LANGID
)ret
;
629 /***********************************************************************
630 * GetSystemDefaultLangID (OLE2NLS.4)
632 LANGID WINAPI
GetSystemDefaultLangID()
634 return GetUserDefaultLangID();
637 /******************************************************************************
638 * GetLocaleInfo16 [OLE2NLS.5]
639 * Is the last parameter really WORD for Win16?
641 INT16 WINAPI
GetLocaleInfo16(LCID lcid
,LCTYPE LCType
,LPSTR buf
,INT16 len
)
643 return GetLocaleInfoA(lcid
,LCType
,buf
,len
);
645 /******************************************************************************
646 * ConvertDefaultLocale32 [KERNEL32.147]
648 LCID WINAPI
ConvertDefaultLocale32 (LCID lcid
)
650 { case LOCALE_SYSTEM_DEFAULT
:
651 return GetSystemDefaultLCID();
652 case LOCALE_USER_DEFAULT
:
653 return GetUserDefaultLCID();
655 return MAKELCID (LANG_NEUTRAL
, SUBLANG_NEUTRAL
);
657 return MAKELANGID( PRIMARYLANGID(lcid
), SUBLANG_NEUTRAL
);
659 /******************************************************************************
660 * GetLocaleInfo32A [KERNEL32.342]
663 * LANG_NEUTRAL is equal to LOCALE_SYSTEM_DEFAULT
665 * MS online documentation states that the string returned is NULL terminated
666 * except for LOCALE_FONTSIGNATURE which "will return a non-NULL
667 * terminated string".
669 INT WINAPI
GetLocaleInfoA(LCID lcid
,LCTYPE LCType
,LPSTR buf
,INT len
)
675 TRACE(ole
,"(lcid=0x%lx,lctype=0x%lx,%p,%x)\n",lcid
,LCType
,buf
,len
);
677 if (len
&& (! buf
) ) {
678 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
682 if (lcid
==0 || lcid
== LANG_SYSTEM_DEFAULT
|| (LCType
& LOCALE_NOUSEROVERRIDE
) ) /* 0x00, 0x400 */
684 lcid
= GetSystemDefaultLCID();
686 else if (lcid
== LANG_USER_DEFAULT
) /*0x800*/
688 lcid
= GetUserDefaultLCID();
690 LCType
&= ~(LOCALE_NOUSEROVERRIDE
|LOCALE_USE_CP_ACP
);
692 /* As an option, we could obtain the value from win.ini.
693 This would not match the Wine compile-time option.
694 Also, not all identifiers are available from win.ini */
696 /* If we are through all of this, retLen should not be zero anymore.
697 If it is, the value is not supported */
699 while (locale_name2id
[i
].name
!=NULL
) {
700 if (LCType
== locale_name2id
[i
].id
) {
701 retString
= locale_name2id
[i
].name
;
707 FIXME(ole
,"Unkown LC type %lX\n",LCType
);
712 for (i
=0;(i
<3 && !found
);i
++) {
715 for (j
=0;j
<sizeof(langlocales
)/sizeof(langlocales
[0]);j
++) {
716 if (langlocales
[j
].lang
== lang
) {
719 for (k
=0;k
<sizeof(langlocales
[j
].locvars
)/sizeof(langlocales
[j
].locvars
[0]) && (langlocales
[j
].locvars
[k
].type
);k
++) {
720 if (langlocales
[j
].locvars
[k
].type
== LCType
) {
722 retString
= langlocales
[j
].locvars
[k
].val
;
730 /* language not found, try without a sublanguage*/
731 if (i
==1) lang
=MAKELANGID( PRIMARYLANGID(lang
), SUBLANG_DEFAULT
);
732 /* mask the LC Value */
733 if (i
==2) LCType
&= 0xfff;
737 ERR(ole
,"'%s' not supported for your language (%04X).\n",
738 retString
,(WORD
)lcid
);
739 SetLastError(ERROR_INVALID_PARAMETER
);
742 /* a FONTSIGNATURE is not a string, just 6 DWORDs */
743 if (LCType
== LOCALE_FONTSIGNATURE
) {
745 memcpy(buf
, retString
, (len
<=sizeof(FONTSIGNATURE
))?len
:sizeof(FONTSIGNATURE
));
746 return sizeof(FONTSIGNATURE
);
748 /* if len=0 return only the length, don't touch the buffer*/
749 if (len
) lstrcpynA(buf
,retString
,len
);
750 return strlen(retString
)+1;
753 /******************************************************************************
754 * GetLocaleInfo32W [KERNEL32.343]
757 * MS documentation states that len "specifies the size, in bytes (ANSI version)
758 * or characters (Unicode version), of" wbuf. Thus the number returned is
759 * the same between GetLocaleInfo32W and GetLocaleInfo32A.
761 INT WINAPI
GetLocaleInfoW(LCID lcid
,LCTYPE LCType
,LPWSTR wbuf
,INT len
)
765 if (len
&& (! wbuf
) )
766 { SetLastError(ERROR_INSUFFICIENT_BUFFER
);
770 abuf
= (LPSTR
)HeapAlloc(GetProcessHeap(),0,len
);
771 wlen
= GetLocaleInfoA(lcid
, LCType
, abuf
, len
);
773 if (wlen
&& len
) /* if len=0 return only the length*/
774 lstrcpynAtoW(wbuf
,abuf
,len
);
776 HeapFree(GetProcessHeap(),0,abuf
);
780 /******************************************************************************
781 * SetLocaleInfoA [KERNEL32.656]
783 BOOL16 WINAPI
SetLocaleInfoA(DWORD lcid
, DWORD lctype
, LPCSTR data
)
785 FIXME(ole
,"(%ld,%ld,%s): stub\n",lcid
,lctype
,data
);
789 /******************************************************************************
790 * IsValidLocale [KERNEL32.489]
792 BOOL WINAPI
IsValidLocale(LCID lcid
,DWORD flags
)
794 /* we support ANY language. Well, at least say that...*/
798 /******************************************************************************
799 * EnumSystemLocales32W [KERNEL32.209]
801 BOOL WINAPI
EnumSystemLocalesW( LOCALE_ENUMPROCW lpfnLocaleEnum
,
809 TRACE(win32
,"(%p,%08lx)\n",lpfnLocaleEnum
,flags
);
810 /* see if we can reuse the Win95 registry entries.... */
811 if (ERROR_SUCCESS
==RegOpenKeyA(HKEY_LOCAL_MACHINE
,"System\\CurrentControlSet\\control\\Nls\\Locale\\",&xhkey
)) {
814 if (ERROR_SUCCESS
!=RegEnumKeyW(xhkey
,i
,buffer
,sizeof(buffer
)))
816 if (!lpfnLocaleEnum(buffer
))
825 while (languages
[i
].langid
!=0)
830 sprintf(xbuffer
,"%08lx",(DWORD
)languages
[i
].langid
);
832 cp
= HEAP_strdupAtoW( GetProcessHeap(), 0, xbuffer
);
833 ret
= lpfnLocaleEnum(cp
);
834 HeapFree( GetProcessHeap(), 0, cp
);
841 /******************************************************************************
842 * EnumSystemLocales32A [KERNEL32.208]
844 BOOL WINAPI
EnumSystemLocalesA(LOCALE_ENUMPROCA lpfnLocaleEnum
,
851 TRACE(win32
,"(%p,%08lx)\n",
854 if (ERROR_SUCCESS
==RegOpenKeyA(HKEY_LOCAL_MACHINE
,"System\\CurrentControlSet\\control\\Nls\\Locale\\",&xhkey
)) {
857 if (ERROR_SUCCESS
!=RegEnumKeyA(xhkey
,i
,buffer
,sizeof(buffer
)))
859 if (!lpfnLocaleEnum(buffer
))
867 while (languages
[i
].langid
!=0) {
868 sprintf(buffer
,"%08lx",(DWORD
)languages
[i
].langid
);
869 if (!lpfnLocaleEnum(buffer
))
876 static const unsigned char CT_CType2_LUT
[] = {
877 C2_NOTAPPLICABLE
, /* - 0 */
878 C2_NOTAPPLICABLE
, /* - 1 */
879 C2_NOTAPPLICABLE
, /* - 2 */
880 C2_NOTAPPLICABLE
, /* - 3 */
881 C2_NOTAPPLICABLE
, /* - 4 */
882 C2_NOTAPPLICABLE
, /* - 5 */
883 C2_NOTAPPLICABLE
, /* - 6 */
884 C2_NOTAPPLICABLE
, /* - 7 */
885 C2_NOTAPPLICABLE
, /* - 8 */
886 C2_SEGMENTSEPARATOR
, /* - 9 */
887 C2_NOTAPPLICABLE
, /* - 10 */
888 C2_NOTAPPLICABLE
, /* - 11 */
889 C2_NOTAPPLICABLE
, /* - 12 */
890 C2_NOTAPPLICABLE
, /* - 13 */
891 C2_NOTAPPLICABLE
, /* - 14 */
892 C2_NOTAPPLICABLE
, /* - 15 */
893 C2_NOTAPPLICABLE
, /* - 16 */
894 C2_NOTAPPLICABLE
, /* - 17 */
895 C2_NOTAPPLICABLE
, /* - 18 */
896 C2_NOTAPPLICABLE
, /* - 19 */
897 C2_NOTAPPLICABLE
, /* - 20 */
898 C2_NOTAPPLICABLE
, /* - 21 */
899 C2_NOTAPPLICABLE
, /* - 22 */
900 C2_NOTAPPLICABLE
, /* - 23 */
901 C2_NOTAPPLICABLE
, /* - 24 */
902 C2_NOTAPPLICABLE
, /* - 25 */
903 C2_NOTAPPLICABLE
, /* - 26 */
904 C2_NOTAPPLICABLE
, /* - 27 */
905 C2_NOTAPPLICABLE
, /* - 28 */
906 C2_NOTAPPLICABLE
, /* - 29 */
907 C2_NOTAPPLICABLE
, /* - 30 */
908 C2_NOTAPPLICABLE
, /* - 31 */
909 C2_WHITESPACE
, /* - 32 */
910 C2_OTHERNEUTRAL
, /* ! - 33 */
911 C2_OTHERNEUTRAL
, /* " - 34 */ /* " */
912 C2_EUROPETERMINATOR
, /* # - 35 */
913 C2_EUROPETERMINATOR
, /* $ - 36 */
914 C2_EUROPETERMINATOR
, /* % - 37 */
915 C2_LEFTTORIGHT
, /* & - 38 */
916 C2_OTHERNEUTRAL
, /* ' - 39 */
917 C2_OTHERNEUTRAL
, /* ( - 40 */
918 C2_OTHERNEUTRAL
, /* ) - 41 */
919 C2_OTHERNEUTRAL
, /* * - 42 */
920 C2_EUROPETERMINATOR
, /* + - 43 */
921 C2_COMMONSEPARATOR
, /* , - 44 */
922 C2_EUROPETERMINATOR
, /* - - 45 */
923 C2_EUROPESEPARATOR
, /* . - 46 */
924 C2_EUROPESEPARATOR
, /* / - 47 */
925 C2_EUROPENUMBER
, /* 0 - 48 */
926 C2_EUROPENUMBER
, /* 1 - 49 */
927 C2_EUROPENUMBER
, /* 2 - 50 */
928 C2_EUROPENUMBER
, /* 3 - 51 */
929 C2_EUROPENUMBER
, /* 4 - 52 */
930 C2_EUROPENUMBER
, /* 5 - 53 */
931 C2_EUROPENUMBER
, /* 6 - 54 */
932 C2_EUROPENUMBER
, /* 7 - 55 */
933 C2_EUROPENUMBER
, /* 8 - 56 */
934 C2_EUROPENUMBER
, /* 9 - 57 */
935 C2_COMMONSEPARATOR
, /* : - 58 */
936 C2_OTHERNEUTRAL
, /* ; - 59 */
937 C2_OTHERNEUTRAL
, /* < - 60 */
938 C2_OTHERNEUTRAL
, /* = - 61 */
939 C2_OTHERNEUTRAL
, /* > - 62 */
940 C2_OTHERNEUTRAL
, /* ? - 63 */
941 C2_LEFTTORIGHT
, /* @ - 64 */
942 C2_LEFTTORIGHT
, /* A - 65 */
943 C2_LEFTTORIGHT
, /* B - 66 */
944 C2_LEFTTORIGHT
, /* C - 67 */
945 C2_LEFTTORIGHT
, /* D - 68 */
946 C2_LEFTTORIGHT
, /* E - 69 */
947 C2_LEFTTORIGHT
, /* F - 70 */
948 C2_LEFTTORIGHT
, /* G - 71 */
949 C2_LEFTTORIGHT
, /* H - 72 */
950 C2_LEFTTORIGHT
, /* I - 73 */
951 C2_LEFTTORIGHT
, /* J - 74 */
952 C2_LEFTTORIGHT
, /* K - 75 */
953 C2_LEFTTORIGHT
, /* L - 76 */
954 C2_LEFTTORIGHT
, /* M - 77 */
955 C2_LEFTTORIGHT
, /* N - 78 */
956 C2_LEFTTORIGHT
, /* O - 79 */
957 C2_LEFTTORIGHT
, /* P - 80 */
958 C2_LEFTTORIGHT
, /* Q - 81 */
959 C2_LEFTTORIGHT
, /* R - 82 */
960 C2_LEFTTORIGHT
, /* S - 83 */
961 C2_LEFTTORIGHT
, /* T - 84 */
962 C2_LEFTTORIGHT
, /* U - 85 */
963 C2_LEFTTORIGHT
, /* V - 86 */
964 C2_LEFTTORIGHT
, /* W - 87 */
965 C2_LEFTTORIGHT
, /* X - 88 */
966 C2_LEFTTORIGHT
, /* Y - 89 */
967 C2_LEFTTORIGHT
, /* Z - 90 */
968 C2_OTHERNEUTRAL
, /* [ - 91 */
969 C2_OTHERNEUTRAL
, /* \ - 92 */
970 C2_OTHERNEUTRAL
, /* ] - 93 */
971 C2_OTHERNEUTRAL
, /* ^ - 94 */
972 C2_OTHERNEUTRAL
, /* _ - 95 */
973 C2_OTHERNEUTRAL
, /* ` - 96 */
974 C2_LEFTTORIGHT
, /* a - 97 */
975 C2_LEFTTORIGHT
, /* b - 98 */
976 C2_LEFTTORIGHT
, /* c - 99 */
977 C2_LEFTTORIGHT
, /* d - 100 */
978 C2_LEFTTORIGHT
, /* e - 101 */
979 C2_LEFTTORIGHT
, /* f - 102 */
980 C2_LEFTTORIGHT
, /* g - 103 */
981 C2_LEFTTORIGHT
, /* h - 104 */
982 C2_LEFTTORIGHT
, /* i - 105 */
983 C2_LEFTTORIGHT
, /* j - 106 */
984 C2_LEFTTORIGHT
, /* k - 107 */
985 C2_LEFTTORIGHT
, /* l - 108 */
986 C2_LEFTTORIGHT
, /* m - 109 */
987 C2_LEFTTORIGHT
, /* n - 110 */
988 C2_LEFTTORIGHT
, /* o - 111 */
989 C2_LEFTTORIGHT
, /* p - 112 */
990 C2_LEFTTORIGHT
, /* q - 113 */
991 C2_LEFTTORIGHT
, /* r - 114 */
992 C2_LEFTTORIGHT
, /* s - 115 */
993 C2_LEFTTORIGHT
, /* t - 116 */
994 C2_LEFTTORIGHT
, /* u - 117 */
995 C2_LEFTTORIGHT
, /* v - 118 */
996 C2_LEFTTORIGHT
, /* w - 119 */
997 C2_LEFTTORIGHT
, /* x - 120 */
998 C2_LEFTTORIGHT
, /* y - 121 */
999 C2_LEFTTORIGHT
, /* z - 122 */
1000 C2_OTHERNEUTRAL
, /* { - 123 */
1001 C2_OTHERNEUTRAL
, /* | - 124 */
1002 C2_OTHERNEUTRAL
, /* } - 125 */
1003 C2_OTHERNEUTRAL
, /* ~ - 126 */
1004 C2_NOTAPPLICABLE
, /* \x7f - 127 */
1005 C2_NOTAPPLICABLE
, /* € - 128 */
1006 C2_NOTAPPLICABLE
, /* � - 129 */
1007 C2_OTHERNEUTRAL
, /* ‚ - 130 */
1008 C2_LEFTTORIGHT
, /* ƒ - 131 */
1009 C2_OTHERNEUTRAL
, /* „ - 132 */
1010 C2_OTHERNEUTRAL
, /* … - 133 */
1011 C2_OTHERNEUTRAL
, /* † - 134 */
1012 C2_OTHERNEUTRAL
, /* ‡ - 135 */
1013 C2_LEFTTORIGHT
, /* ˆ - 136 */
1014 C2_EUROPETERMINATOR
, /* ‰ - 137 */
1015 C2_LEFTTORIGHT
, /* Š - 138 */
1016 C2_OTHERNEUTRAL
, /* ‹ - 139 */
1017 C2_LEFTTORIGHT
, /* Œ - 140 */
1018 C2_NOTAPPLICABLE
, /* � - 141 */
1019 C2_NOTAPPLICABLE
, /* Ž - 142 */
1020 C2_NOTAPPLICABLE
, /* � - 143 */
1021 C2_NOTAPPLICABLE
, /* � - 144 */
1022 C2_OTHERNEUTRAL
, /* ‘ - 145 */
1023 C2_OTHERNEUTRAL
, /* ’ - 146 */
1024 C2_OTHERNEUTRAL
, /* “ - 147 */
1025 C2_OTHERNEUTRAL
, /* ” - 148 */
1026 C2_OTHERNEUTRAL
, /* • - 149 */
1027 C2_OTHERNEUTRAL
, /* – - 150 */
1028 C2_OTHERNEUTRAL
, /* — - 151 */
1029 C2_LEFTTORIGHT
, /* ˜ - 152 */
1030 C2_OTHERNEUTRAL
, /* ™ - 153 */
1031 C2_LEFTTORIGHT
, /* š - 154 */
1032 C2_OTHERNEUTRAL
, /* › - 155 */
1033 C2_LEFTTORIGHT
, /* œ - 156 */
1034 C2_NOTAPPLICABLE
, /* � - 157 */
1035 C2_NOTAPPLICABLE
, /* ž - 158 */
1036 C2_LEFTTORIGHT
, /* Ÿ - 159 */
1037 C2_WHITESPACE
, /* - 160 */
1038 C2_OTHERNEUTRAL
, /* ¡ - 161 */
1039 C2_EUROPETERMINATOR
, /* ¢ - 162 */
1040 C2_EUROPETERMINATOR
, /* £ - 163 */
1041 C2_EUROPETERMINATOR
, /* ¤ - 164 */
1042 C2_EUROPETERMINATOR
, /* ¥ - 165 */
1043 C2_OTHERNEUTRAL
, /* ¦ - 166 */
1044 C2_OTHERNEUTRAL
, /* § - 167 */
1045 C2_OTHERNEUTRAL
, /* ¨ - 168 */
1046 C2_OTHERNEUTRAL
, /* © - 169 */
1047 C2_OTHERNEUTRAL
, /* ª - 170 */
1048 C2_OTHERNEUTRAL
, /* « - 171 */
1049 C2_OTHERNEUTRAL
, /* ¬ - 172 */
1050 C2_OTHERNEUTRAL
, /* - 173 */
1051 C2_OTHERNEUTRAL
, /* ® - 174 */
1052 C2_OTHERNEUTRAL
, /* ¯ - 175 */
1053 C2_EUROPETERMINATOR
, /* ° - 176 */
1054 C2_EUROPETERMINATOR
, /* ± - 177 */
1055 C2_EUROPENUMBER
, /* ² - 178 */
1056 C2_EUROPENUMBER
, /* ³ - 179 */
1057 C2_OTHERNEUTRAL
, /* ´ - 180 */
1058 C2_OTHERNEUTRAL
, /* µ - 181 */
1059 C2_OTHERNEUTRAL
, /* ¶ - 182 */
1060 C2_OTHERNEUTRAL
, /* · - 183 */
1061 C2_OTHERNEUTRAL
, /* ¸ - 184 */
1062 C2_EUROPENUMBER
, /* ¹ - 185 */
1063 C2_OTHERNEUTRAL
, /* º - 186 */
1064 C2_OTHERNEUTRAL
, /* » - 187 */
1065 C2_OTHERNEUTRAL
, /* ¼ - 188 */
1066 C2_OTHERNEUTRAL
, /* ½ - 189 */
1067 C2_OTHERNEUTRAL
, /* ¾ - 190 */
1068 C2_OTHERNEUTRAL
, /* ¿ - 191 */
1069 C2_LEFTTORIGHT
, /* À - 192 */
1070 C2_LEFTTORIGHT
, /* Á - 193 */
1071 C2_LEFTTORIGHT
, /* Â - 194 */
1072 C2_LEFTTORIGHT
, /* Ã - 195 */
1073 C2_LEFTTORIGHT
, /* Ä - 196 */
1074 C2_LEFTTORIGHT
, /* Å - 197 */
1075 C2_LEFTTORIGHT
, /* Æ - 198 */
1076 C2_LEFTTORIGHT
, /* Ç - 199 */
1077 C2_LEFTTORIGHT
, /* È - 200 */
1078 C2_LEFTTORIGHT
, /* É - 201 */
1079 C2_LEFTTORIGHT
, /* Ê - 202 */
1080 C2_LEFTTORIGHT
, /* Ë - 203 */
1081 C2_LEFTTORIGHT
, /* Ì - 204 */
1082 C2_LEFTTORIGHT
, /* Í - 205 */
1083 C2_LEFTTORIGHT
, /* Î - 206 */
1084 C2_LEFTTORIGHT
, /* Ï - 207 */
1085 C2_LEFTTORIGHT
, /* Ð - 208 */
1086 C2_LEFTTORIGHT
, /* Ñ - 209 */
1087 C2_LEFTTORIGHT
, /* Ò - 210 */
1088 C2_LEFTTORIGHT
, /* Ó - 211 */
1089 C2_LEFTTORIGHT
, /* Ô - 212 */
1090 C2_LEFTTORIGHT
, /* Õ - 213 */
1091 C2_LEFTTORIGHT
, /* Ö - 214 */
1092 C2_OTHERNEUTRAL
, /* × - 215 */
1093 C2_LEFTTORIGHT
, /* Ø - 216 */
1094 C2_LEFTTORIGHT
, /* Ù - 217 */
1095 C2_LEFTTORIGHT
, /* Ú - 218 */
1096 C2_LEFTTORIGHT
, /* Û - 219 */
1097 C2_LEFTTORIGHT
, /* Ü - 220 */
1098 C2_LEFTTORIGHT
, /* Ý - 221 */
1099 C2_LEFTTORIGHT
, /* Þ - 222 */
1100 C2_LEFTTORIGHT
, /* ß - 223 */
1101 C2_LEFTTORIGHT
, /* à - 224 */
1102 C2_LEFTTORIGHT
, /* á - 225 */
1103 C2_LEFTTORIGHT
, /* â - 226 */
1104 C2_LEFTTORIGHT
, /* ã - 227 */
1105 C2_LEFTTORIGHT
, /* ä - 228 */
1106 C2_LEFTTORIGHT
, /* å - 229 */
1107 C2_LEFTTORIGHT
, /* æ - 230 */
1108 C2_LEFTTORIGHT
, /* ç - 231 */
1109 C2_LEFTTORIGHT
, /* è - 232 */
1110 C2_LEFTTORIGHT
, /* é - 233 */
1111 C2_LEFTTORIGHT
, /* ê - 234 */
1112 C2_LEFTTORIGHT
, /* ë - 235 */
1113 C2_LEFTTORIGHT
, /* ì - 236 */
1114 C2_LEFTTORIGHT
, /* í - 237 */
1115 C2_LEFTTORIGHT
, /* î - 238 */
1116 C2_LEFTTORIGHT
, /* ï - 239 */
1117 C2_LEFTTORIGHT
, /* ð - 240 */
1118 C2_LEFTTORIGHT
, /* ñ - 241 */
1119 C2_LEFTTORIGHT
, /* ò - 242 */
1120 C2_LEFTTORIGHT
, /* ó - 243 */
1121 C2_LEFTTORIGHT
, /* ô - 244 */
1122 C2_LEFTTORIGHT
, /* õ - 245 */
1123 C2_LEFTTORIGHT
, /* ö - 246 */
1124 C2_OTHERNEUTRAL
, /* ÷ - 247 */
1125 C2_LEFTTORIGHT
, /* ø - 248 */
1126 C2_LEFTTORIGHT
, /* ù - 249 */
1127 C2_LEFTTORIGHT
, /* ú - 250 */
1128 C2_LEFTTORIGHT
, /* û - 251 */
1129 C2_LEFTTORIGHT
, /* ü - 252 */
1130 C2_LEFTTORIGHT
, /* ý - 253 */
1131 C2_LEFTTORIGHT
, /* þ - 254 */
1132 C2_LEFTTORIGHT
/* ÿ - 255 */
1135 const WORD OLE2NLS_CT_CType3_LUT
[] = {
1169 0x0048, /* ! - 33 */
1170 0x0448, /* " - 34 */ /* " */
1171 0x0048, /* # - 35 */
1172 0x0448, /* $ - 36 */
1173 0x0048, /* % - 37 */
1174 0x0048, /* & - 38 */
1175 0x0440, /* ' - 39 */
1176 0x0048, /* ( - 40 */
1177 0x0048, /* ) - 41 */
1178 0x0048, /* * - 42 */
1179 0x0048, /* + - 43 */
1180 0x0048, /* , - 44 */
1181 0x0440, /* - - 45 */
1182 0x0048, /* . - 46 */
1183 0x0448, /* / - 47 */
1184 0x0040, /* 0 - 48 */
1185 0x0040, /* 1 - 49 */
1186 0x0040, /* 2 - 50 */
1187 0x0040, /* 3 - 51 */
1188 0x0040, /* 4 - 52 */
1189 0x0040, /* 5 - 53 */
1190 0x0040, /* 6 - 54 */
1191 0x0040, /* 7 - 55 */
1192 0x0040, /* 8 - 56 */
1193 0x0040, /* 9 - 57 */
1194 0x0048, /* : - 58 */
1195 0x0048, /* ; - 59 */
1196 0x0048, /* < - 60 */
1197 0x0448, /* = - 61 */
1198 0x0048, /* > - 62 */
1199 0x0048, /* ? - 63 */
1200 0x0448, /* @ - 64 */
1201 0x8040, /* A - 65 */
1202 0x8040, /* B - 66 */
1203 0x8040, /* C - 67 */
1204 0x8040, /* D - 68 */
1205 0x8040, /* E - 69 */
1206 0x8040, /* F - 70 */
1207 0x8040, /* G - 71 */
1208 0x8040, /* H - 72 */
1209 0x8040, /* I - 73 */
1210 0x8040, /* J - 74 */
1211 0x8040, /* K - 75 */
1212 0x8040, /* L - 76 */
1213 0x8040, /* M - 77 */
1214 0x8040, /* N - 78 */
1215 0x8040, /* O - 79 */
1216 0x8040, /* P - 80 */
1217 0x8040, /* Q - 81 */
1218 0x8040, /* R - 82 */
1219 0x8040, /* S - 83 */
1220 0x8040, /* T - 84 */
1221 0x8040, /* U - 85 */
1222 0x8040, /* V - 86 */
1223 0x8040, /* W - 87 */
1224 0x8040, /* X - 88 */
1225 0x8040, /* Y - 89 */
1226 0x8040, /* Z - 90 */
1227 0x0048, /* [ - 91 */
1228 0x0448, /* \ - 92 */
1229 0x0048, /* ] - 93 */
1230 0x0448, /* ^ - 94 */
1231 0x0448, /* _ - 95 */
1232 0x0448, /* ` - 96 */
1233 0x8040, /* a - 97 */
1234 0x8040, /* b - 98 */
1235 0x8040, /* c - 99 */
1236 0x8040, /* d - 100 */
1237 0x8040, /* e - 101 */
1238 0x8040, /* f - 102 */
1239 0x8040, /* g - 103 */
1240 0x8040, /* h - 104 */
1241 0x8040, /* i - 105 */
1242 0x8040, /* j - 106 */
1243 0x8040, /* k - 107 */
1244 0x8040, /* l - 108 */
1245 0x8040, /* m - 109 */
1246 0x8040, /* n - 110 */
1247 0x8040, /* o - 111 */
1248 0x8040, /* p - 112 */
1249 0x8040, /* q - 113 */
1250 0x8040, /* r - 114 */
1251 0x8040, /* s - 115 */
1252 0x8040, /* t - 116 */
1253 0x8040, /* u - 117 */
1254 0x8040, /* v - 118 */
1255 0x8040, /* w - 119 */
1256 0x8040, /* x - 120 */
1257 0x8040, /* y - 121 */
1258 0x8040, /* z - 122 */
1259 0x0048, /* { - 123 */
1260 0x0048, /* | - 124 */
1261 0x0048, /* } - 125 */
1262 0x0448, /* ~ - 126 */
1263 0x0000, /* \x7f - 127 */
1264 0x0000, /* € - 128 */
1265 0x0000, /* � - 129 */
1266 0x0008, /* ‚ - 130 */
1267 0x8000, /* ƒ - 131 */
1268 0x0008, /* „ - 132 */
1269 0x0008, /* … - 133 */
1270 0x0008, /* † - 134 */
1271 0x0008, /* ‡ - 135 */
1272 0x0001, /* ˆ - 136 */
1273 0x0008, /* ‰ - 137 */
1274 0x8003, /* Š - 138 */
1275 0x0008, /* ‹ - 139 */
1276 0x8000, /* Œ - 140 */
1277 0x0000, /* � - 141 */
1278 0x0000, /* Ž - 142 */
1279 0x0000, /* � - 143 */
1280 0x0000, /* � - 144 */
1281 0x0088, /* ‘ - 145 */
1282 0x0088, /* ’ - 146 */
1283 0x0088, /* “ - 147 */
1284 0x0088, /* ” - 148 */
1285 0x0008, /* • - 149 */
1286 0x0400, /* – - 150 */
1287 0x0400, /* — - 151 */
1288 0x0408, /* ˜ - 152 */
1289 0x0000, /* ™ - 153 */
1290 0x8003, /* š - 154 */
1291 0x0008, /* › - 155 */
1292 0x8000, /* œ - 156 */
1293 0x0000, /* � - 157 */
1294 0x0000, /* ž - 158 */
1295 0x8003, /* Ÿ - 159 */
1297 0x0008, /* ¡ - 161 */
1298 0x0048, /* ¢ - 162 */
1299 0x0048, /* £ - 163 */
1300 0x0008, /* ¤ - 164 */
1301 0x0048, /* ¥ - 165 */
1302 0x0048, /* ¦ - 166 */
1303 0x0008, /* § - 167 */
1304 0x0408, /* ¨ - 168 */
1305 0x0008, /* © - 169 */
1306 0x0400, /* ª - 170 */
1307 0x0008, /* « - 171 */
1308 0x0048, /* ¬ - 172 */
1309 0x0408, /* - 173 */
1310 0x0008, /* ® - 174 */
1311 0x0448, /* ¯ - 175 */
1312 0x0008, /* ° - 176 */
1313 0x0008, /* ± - 177 */
1314 0x0000, /* ² - 178 */
1315 0x0000, /* ³ - 179 */
1316 0x0408, /* ´ - 180 */
1317 0x0008, /* µ - 181 */
1318 0x0008, /* ¶ - 182 */
1319 0x0008, /* · - 183 */
1320 0x0408, /* ¸ - 184 */
1321 0x0000, /* ¹ - 185 */
1322 0x0400, /* º - 186 */
1323 0x0008, /* » - 187 */
1324 0x0000, /* ¼ - 188 */
1325 0x0000, /* ½ - 189 */
1326 0x0000, /* ¾ - 190 */
1327 0x0008, /* ¿ - 191 */
1328 0x8003, /* À - 192 */
1329 0x8003, /* Á - 193 */
1330 0x8003, /* Â - 194 */
1331 0x8003, /* Ã - 195 */
1332 0x8003, /* Ä - 196 */
1333 0x8003, /* Å - 197 */
1334 0x8000, /* Æ - 198 */
1335 0x8003, /* Ç - 199 */
1336 0x8003, /* È - 200 */
1337 0x8003, /* É - 201 */
1338 0x8003, /* Ê - 202 */
1339 0x8003, /* Ë - 203 */
1340 0x8003, /* Ì - 204 */
1341 0x8003, /* Í - 205 */
1342 0x8003, /* Î - 206 */
1343 0x8003, /* Ï - 207 */
1344 0x8000, /* Ð - 208 */
1345 0x8003, /* Ñ - 209 */
1346 0x8003, /* Ò - 210 */
1347 0x8003, /* Ó - 211 */
1348 0x8003, /* Ô - 212 */
1349 0x8003, /* Õ - 213 */
1350 0x8003, /* Ö - 214 */
1351 0x0008, /* × - 215 */
1352 0x8003, /* Ø - 216 */
1353 0x8003, /* Ù - 217 */
1354 0x8003, /* Ú - 218 */
1355 0x8003, /* Û - 219 */
1356 0x8003, /* Ü - 220 */
1357 0x8003, /* Ý - 221 */
1358 0x8000, /* Þ - 222 */
1359 0x8000, /* ß - 223 */
1360 0x8003, /* à - 224 */
1361 0x8003, /* á - 225 */
1362 0x8003, /* â - 226 */
1363 0x8003, /* ã - 227 */
1364 0x8003, /* ä - 228 */
1365 0x8003, /* å - 229 */
1366 0x8000, /* æ - 230 */
1367 0x8003, /* ç - 231 */
1368 0x8003, /* è - 232 */
1369 0x8003, /* é - 233 */
1370 0x8003, /* ê - 234 */
1371 0x8003, /* ë - 235 */
1372 0x8003, /* ì - 236 */
1373 0x8003, /* í - 237 */
1374 0x8003, /* î - 238 */
1375 0x8003, /* ï - 239 */
1376 0x8000, /* ð - 240 */
1377 0x8003, /* ñ - 241 */
1378 0x8003, /* ò - 242 */
1379 0x8003, /* ó - 243 */
1380 0x8003, /* ô - 244 */
1381 0x8003, /* õ - 245 */
1382 0x8003, /* ö - 246 */
1383 0x0008, /* ÷ - 247 */
1384 0x8003, /* ø - 248 */
1385 0x8003, /* ù - 249 */
1386 0x8003, /* ú - 250 */
1387 0x8003, /* û - 251 */
1388 0x8003, /* ü - 252 */
1389 0x8003, /* ý - 253 */
1390 0x8000, /* þ - 254 */
1391 0x8003 /* ÿ - 255 */
1394 /******************************************************************************
1395 * GetStringType16 [OLE2NLS.7]
1397 BOOL16 WINAPI
GetStringType16(LCID locale
,DWORD dwInfoType
,LPCSTR src
,
1398 INT16 cchSrc
,LPWORD chartype
)
1400 return GetStringTypeExA(locale
,dwInfoType
,src
,cchSrc
,chartype
);
1402 /******************************************************************************
1403 * GetStringType32A [KERNEL32.396]
1405 BOOL WINAPI
GetStringTypeA(LCID locale
,DWORD dwInfoType
,LPCSTR src
,
1406 INT cchSrc
,LPWORD chartype
)
1408 return GetStringTypeExA(locale
,dwInfoType
,src
,cchSrc
,chartype
);
1411 /******************************************************************************
1412 * GetStringTypeEx32A [KERNEL32.397]
1414 * FIXME: Ignores the locale.
1416 BOOL WINAPI
GetStringTypeExA(LCID locale
,DWORD dwInfoType
,LPCSTR src
,
1417 INT cchSrc
,LPWORD chartype
)
1421 if ((src
==NULL
) || (chartype
==NULL
) || (src
==(LPSTR
)chartype
))
1423 SetLastError(ERROR_INVALID_PARAMETER
);
1428 cchSrc
=lstrlenA(src
)+1;
1430 switch (dwInfoType
) {
1432 for (i
=0;i
<cchSrc
;i
++)
1435 if (isdigit(src
[i
])) chartype
[i
]|=C1_DIGIT
;
1436 if (isalpha(src
[i
])) chartype
[i
]|=C1_ALPHA
;
1437 if (islower(src
[i
])) chartype
[i
]|=C1_LOWER
;
1438 if (isupper(src
[i
])) chartype
[i
]|=C1_UPPER
;
1439 if (isspace(src
[i
])) chartype
[i
]|=C1_SPACE
;
1440 if (ispunct(src
[i
])) chartype
[i
]|=C1_PUNCT
;
1441 if (iscntrl(src
[i
])) chartype
[i
]|=C1_CNTRL
;
1442 /* FIXME: isblank() is a GNU extension */
1443 /* if (isblank(src[i])) chartype[i]|=C1_BLANK; */
1444 if ((src
[i
] == ' ') || (src
[i
] == '\t')) chartype
[i
]|=C1_BLANK
;
1450 for (i
=0;i
<cchSrc
;i
++)
1452 chartype
[i
]=(WORD
)CT_CType2_LUT
[i
];
1457 for (i
=0;i
<cchSrc
;i
++)
1459 chartype
[i
]=OLE2NLS_CT_CType3_LUT
[i
];
1464 ERR(ole
,"Unknown dwInfoType:%ld\n",dwInfoType
);
1469 /******************************************************************************
1470 * GetStringType32W [KERNEL32.399]
1473 * Yes, this is missing LCID locale. MS fault.
1475 BOOL WINAPI
GetStringTypeW(DWORD dwInfoType
,LPCWSTR src
,INT cchSrc
,
1478 return GetStringTypeExW(0/*defaultlocale*/,dwInfoType
,src
,cchSrc
,chartype
);
1481 /******************************************************************************
1482 * GetStringTypeEx32W [KERNEL32.398]
1484 * FIXME: unicode chars are assumed chars
1486 BOOL WINAPI
GetStringTypeExW(LCID locale
,DWORD dwInfoType
,LPCWSTR src
,
1487 INT cchSrc
,LPWORD chartype
)
1493 cchSrc
=lstrlenW(src
)+1;
1495 switch (dwInfoType
) {
1497 FIXME(ole
,"CT_CTYPE2 not supported.\n");
1500 FIXME(ole
,"CT_CTYPE3 not supported.\n");
1504 for (i
=0;i
<cchSrc
;i
++) {
1506 if (isdigit(src
[i
])) chartype
[i
]|=C1_DIGIT
;
1507 if (isalpha(src
[i
])) chartype
[i
]|=C1_ALPHA
;
1508 if (islower(src
[i
])) chartype
[i
]|=C1_LOWER
;
1509 if (isupper(src
[i
])) chartype
[i
]|=C1_UPPER
;
1510 if (isspace(src
[i
])) chartype
[i
]|=C1_SPACE
;
1511 if (ispunct(src
[i
])) chartype
[i
]|=C1_PUNCT
;
1512 if (iscntrl(src
[i
])) chartype
[i
]|=C1_CNTRL
;
1513 /* FIXME: isblank() is a GNU extension */
1514 /* if (isblank(src[i])) chartype[i]|=C1_BLANK; */
1515 if ((src
[i
] == ' ') || (src
[i
] == '\t')) chartype
[i
]|=C1_BLANK
;
1521 /*****************************************************************
1522 * WINE_GetLanguageName [internal]
1524 * FIXME: Windows keeps language names in a string table
1525 * resource in VER.DLL ...
1527 LPCSTR
WINE_GetLanguageName( UINT langid
)
1530 for ( i
= 0; languages
[i
].langid
!= 0; i
++ )
1531 if ( langid
== languages
[i
].langid
)
1534 return languages
[i
].langname
;
1537 static const unsigned char LCM_Unicode_LUT
[] = {
1570 7 , 28, /* ! - 33 */
1571 7 , 29, /* " - 34 */ /* " */
1572 7 , 31, /* # - 35 */
1573 7 , 33, /* $ - 36 */
1574 7 , 35, /* % - 37 */
1575 7 , 37, /* & - 38 */
1576 6 , 128, /* ' - 39 */
1577 7 , 39, /* ( - 40 */
1578 7 , 42, /* ) - 41 */
1579 7 , 45, /* * - 42 */
1581 7 , 47, /* , - 44 */
1582 6 , 130, /* - - 45 */
1583 7 , 51, /* . - 46 */
1584 7 , 53, /* / - 47 */
1585 12 , 3, /* 0 - 48 */
1586 12 , 33, /* 1 - 49 */
1587 12 , 51, /* 2 - 50 */
1588 12 , 70, /* 3 - 51 */
1589 12 , 88, /* 4 - 52 */
1590 12 , 106, /* 5 - 53 */
1591 12 , 125, /* 6 - 54 */
1592 12 , 144, /* 7 - 55 */
1593 12 , 162, /* 8 - 56 */
1594 12 , 180, /* 9 - 57 */
1595 7 , 55, /* : - 58 */
1596 7 , 58, /* ; - 59 */
1597 8 , 14, /* < - 60 */
1598 8 , 18, /* = - 61 */
1599 8 , 20, /* > - 62 */
1600 7 , 60, /* ? - 63 */
1601 7 , 62, /* @ - 64 */
1602 14 , 2, /* A - 65 */
1603 14 , 9, /* B - 66 */
1604 14 , 10, /* C - 67 */
1605 14 , 26, /* D - 68 */
1606 14 , 33, /* E - 69 */
1607 14 , 35, /* F - 70 */
1608 14 , 37, /* G - 71 */
1609 14 , 44, /* H - 72 */
1610 14 , 50, /* I - 73 */
1611 14 , 53, /* J - 74 */
1612 14 , 54, /* K - 75 */
1613 14 , 72, /* L - 76 */
1614 14 , 81, /* M - 77 */
1615 14 , 112, /* N - 78 */
1616 14 , 124, /* O - 79 */
1617 14 , 126, /* P - 80 */
1618 14 , 137, /* Q - 81 */
1619 14 , 138, /* R - 82 */
1620 14 , 145, /* S - 83 */
1621 14 , 153, /* T - 84 */
1622 14 , 159, /* U - 85 */
1623 14 , 162, /* V - 86 */
1624 14 , 164, /* W - 87 */
1625 14 , 166, /* X - 88 */
1626 14 , 167, /* Y - 89 */
1627 14 , 169, /* Z - 90 */
1628 7 , 63, /* [ - 91 */
1629 7 , 65, /* \ - 92 */
1630 7 , 66, /* ] - 93 */
1631 7 , 67, /* ^ - 94 */
1632 7 , 68, /* _ - 95 */
1633 7 , 72, /* ` - 96 */
1634 14 , 2, /* a - 97 */
1635 14 , 9, /* b - 98 */
1636 14 , 10, /* c - 99 */
1637 14 , 26, /* d - 100 */
1638 14 , 33, /* e - 101 */
1639 14 , 35, /* f - 102 */
1640 14 , 37, /* g - 103 */
1641 14 , 44, /* h - 104 */
1642 14 , 50, /* i - 105 */
1643 14 , 53, /* j - 106 */
1644 14 , 54, /* k - 107 */
1645 14 , 72, /* l - 108 */
1646 14 , 81, /* m - 109 */
1647 14 , 112, /* n - 110 */
1648 14 , 124, /* o - 111 */
1649 14 , 126, /* p - 112 */
1650 14 , 137, /* q - 113 */
1651 14 , 138, /* r - 114 */
1652 14 , 145, /* s - 115 */
1653 14 , 153, /* t - 116 */
1654 14 , 159, /* u - 117 */
1655 14 , 162, /* v - 118 */
1656 14 , 164, /* w - 119 */
1657 14 , 166, /* x - 120 */
1658 14 , 167, /* y - 121 */
1659 14 , 169, /* z - 122 */
1660 7 , 74, /* { - 123 */
1661 7 , 76, /* | - 124 */
1662 7 , 78, /* } - 125 */
1663 7 , 80, /* ~ - 126 */
1664 6 , 29, /* \x7f - 127 */
1665 6 , 30, /* € - 128 */
1666 6 , 31, /* � - 129 */
1667 7 , 123, /* ‚ - 130 */
1668 14 , 35, /* ƒ - 131 */
1669 7 , 127, /* „ - 132 */
1670 10 , 21, /* … - 133 */
1671 10 , 15, /* † - 134 */
1672 10 , 16, /* ‡ - 135 */
1673 7 , 67, /* ˆ - 136 */
1674 10 , 22, /* ‰ - 137 */
1675 14 , 145, /* Š - 138 */
1676 7 , 136, /* ‹ - 139 */
1677 14 + 16 , 124, /* Œ - 140 */
1678 6 , 43, /* � - 141 */
1679 6 , 44, /* Ž - 142 */
1680 6 , 45, /* � - 143 */
1681 6 , 46, /* � - 144 */
1682 7 , 121, /* ‘ - 145 */
1683 7 , 122, /* ’ - 146 */
1684 7 , 125, /* “ - 147 */
1685 7 , 126, /* ” - 148 */
1686 10 , 17, /* • - 149 */
1687 6 , 137, /* – - 150 */
1688 6 , 139, /* — - 151 */
1689 7 , 93, /* ˜ - 152 */
1690 14 , 156, /* ™ - 153 */
1691 14 , 145, /* š - 154 */
1692 7 , 137, /* › - 155 */
1693 14 + 16 , 124, /* œ - 156 */
1694 6 , 59, /* � - 157 */
1695 6 , 60, /* ž - 158 */
1696 14 , 167, /* Ÿ - 159 */
1698 7 , 81, /* ¡ - 161 */
1699 10 , 2, /* ¢ - 162 */
1700 10 , 3, /* £ - 163 */
1701 10 , 4, /* ¤ - 164 */
1702 10 , 5, /* ¥ - 165 */
1703 7 , 82, /* ¦ - 166 */
1704 10 , 6, /* § - 167 */
1705 7 , 83, /* ¨ - 168 */
1706 10 , 7, /* © - 169 */
1707 14 , 2, /* ª - 170 */
1708 8 , 24, /* « - 171 */
1709 10 , 8, /* ¬ - 172 */
1710 6 , 131, /* - 173 */
1711 10 , 9, /* ® - 174 */
1712 7 , 84, /* ¯ - 175 */
1713 10 , 10, /* ° - 176 */
1714 8 , 23, /* ± - 177 */
1715 12 , 51, /* ² - 178 */
1716 12 , 70, /* ³ - 179 */
1717 7 , 85, /* ´ - 180 */
1718 10 , 11, /* µ - 181 */
1719 10 , 12, /* ¶ - 182 */
1720 10 , 13, /* · - 183 */
1721 7 , 86, /* ¸ - 184 */
1722 12 , 33, /* ¹ - 185 */
1723 14 , 124, /* º - 186 */
1724 8 , 26, /* » - 187 */
1725 12 , 21, /* ¼ - 188 */
1726 12 , 25, /* ½ - 189 */
1727 12 , 29, /* ¾ - 190 */
1728 7 , 87, /* ¿ - 191 */
1729 14 , 2, /* À - 192 */
1730 14 , 2, /* Á - 193 */
1731 14 , 2, /* Â - 194 */
1732 14 , 2, /* Ã - 195 */
1733 14 , 2, /* Ä - 196 */
1734 14 , 2, /* Å - 197 */
1735 14 + 16 , 2, /* Æ - 198 */
1736 14 , 10, /* Ç - 199 */
1737 14 , 33, /* È - 200 */
1738 14 , 33, /* É - 201 */
1739 14 , 33, /* Ê - 202 */
1740 14 , 33, /* Ë - 203 */
1741 14 , 50, /* Ì - 204 */
1742 14 , 50, /* Í - 205 */
1743 14 , 50, /* Î - 206 */
1744 14 , 50, /* Ï - 207 */
1745 14 , 26, /* Ð - 208 */
1746 14 , 112, /* Ñ - 209 */
1747 14 , 124, /* Ò - 210 */
1748 14 , 124, /* Ó - 211 */
1749 14 , 124, /* Ô - 212 */
1750 14 , 124, /* Õ - 213 */
1751 14 , 124, /* Ö - 214 */
1752 8 , 28, /* × - 215 */
1753 14 , 124, /* Ø - 216 */
1754 14 , 159, /* Ù - 217 */
1755 14 , 159, /* Ú - 218 */
1756 14 , 159, /* Û - 219 */
1757 14 , 159, /* Ü - 220 */
1758 14 , 167, /* Ý - 221 */
1759 14 + 32 , 153, /* Þ - 222 */
1760 14 + 48 , 145, /* ß - 223 */
1761 14 , 2, /* à - 224 */
1762 14 , 2, /* á - 225 */
1763 14 , 2, /* â - 226 */
1764 14 , 2, /* ã - 227 */
1765 14 , 2, /* ä - 228 */
1766 14 , 2, /* å - 229 */
1767 14 + 16 , 2, /* æ - 230 */
1768 14 , 10, /* ç - 231 */
1769 14 , 33, /* è - 232 */
1770 14 , 33, /* é - 233 */
1771 14 , 33, /* ê - 234 */
1772 14 , 33, /* ë - 235 */
1773 14 , 50, /* ì - 236 */
1774 14 , 50, /* í - 237 */
1775 14 , 50, /* î - 238 */
1776 14 , 50, /* ï - 239 */
1777 14 , 26, /* ð - 240 */
1778 14 , 112, /* ñ - 241 */
1779 14 , 124, /* ò - 242 */
1780 14 , 124, /* ó - 243 */
1781 14 , 124, /* ô - 244 */
1782 14 , 124, /* õ - 245 */
1783 14 , 124, /* ö - 246 */
1784 8 , 29, /* ÷ - 247 */
1785 14 , 124, /* ø - 248 */
1786 14 , 159, /* ù - 249 */
1787 14 , 159, /* ú - 250 */
1788 14 , 159, /* û - 251 */
1789 14 , 159, /* ü - 252 */
1790 14 , 167, /* ý - 253 */
1791 14 + 32 , 153, /* þ - 254 */
1792 14 , 167 /* ÿ - 255 */ };
1794 static const unsigned char LCM_Unicode_LUT_2
[] = { 33, 44, 145 };
1796 #define LCM_Diacritic_Start 131
1798 static const unsigned char LCM_Diacritic_LUT
[] = {
1926 /******************************************************************************
1927 * OLE2NLS_isPunctuation [INTERNAL]
1929 static int OLE2NLS_isPunctuation(unsigned char c
)
1931 /* "punctuation character" in this context is a character which is
1932 considered "less important" during word sort comparison.
1933 See LCMapString implementation for the precise definition
1934 of "less important". */
1936 return (LCM_Unicode_LUT
[-2+2*c
]==6);
1939 /******************************************************************************
1940 * OLE2NLS_isNonSpacing [INTERNAL]
1942 static int OLE2NLS_isNonSpacing(unsigned char c
)
1944 /* This function is used by LCMapString32A. Characters
1945 for which it returns true are ignored when mapping a
1946 string with NORM_IGNORENONSPACE */
1947 return ((c
==136) || (c
==170) || (c
==186));
1950 /******************************************************************************
1951 * OLE2NLS_isSymbol [INTERNAL]
1953 static int OLE2NLS_isSymbol(unsigned char c
)
1955 /* This function is used by LCMapString32A. Characters
1956 for which it returns true are ignored when mapping a
1957 string with NORM_IGNORESYMBOLS */
1958 return ( (c
!=0) && !IsCharAlphaNumericA(c
) );
1961 /******************************************************************************
1962 * identity [Internal]
1964 static int identity(int c
)
1969 /*************************************************************************
1970 * LCMapString32A [KERNEL32.492]
1972 * Convert a string, or generate a sort key from it.
1974 * If (mapflags & LCMAP_SORTKEY), the function will generate
1975 * a sort key for the source string. Else, it will convert it
1976 * accordingly to the flags LCMAP_UPPERCASE, LCMAP_LOWERCASE,...
1980 * Success : length of the result string.
1983 * If called with scrlen = -1, the function will compute the length
1984 * of the 0-terminated string strsrc by itself.
1986 * If called with dstlen = 0, returns the buffer length that
1987 * would be required.
1989 * NORM_IGNOREWIDTH means to compare ASCII and wide characters
1990 * as if they are equal.
1991 * In the only code page implemented so far, there may not be
1992 * wide characters in strings passed to LCMapString32A,
1993 * so there is nothing to be done for this flag.
1995 INT WINAPI
LCMapStringA(
1996 LCID lcid
/* locale identifier created with MAKELCID;
1997 LOCALE_SYSTEM_DEFAULT and LOCALE_USER_DEFAULT are
1998 predefined values. */,
1999 DWORD mapflags
/* flags */,
2000 LPCSTR srcstr
/* source buffer */,
2001 INT srclen
/* source length */,
2002 LPSTR dststr
/* destination buffer */,
2003 INT dstlen
/* destination buffer length */)
2007 TRACE(string
,"(0x%04lx,0x%08lx,%s,%d,%p,%d)\n",
2008 lcid
,mapflags
,srcstr
,srclen
,dststr
,dstlen
);
2010 if ( ((dstlen
!=0) && (dststr
==NULL
)) || (srcstr
==NULL
) )
2012 ERR(ole
, "(src=%s,dest=%s): Invalid NULL string\n", srcstr
, dststr
);
2013 SetLastError(ERROR_INVALID_PARAMETER
);
2017 srclen
= lstrlenA(srcstr
) + 1 ; /* (include final '\0') */
2019 #define LCMAPSTRINGA_SUPPORTED_FLAGS (LCMAP_UPPERCASE | \
2023 NORM_IGNORENONSPACE | \
2027 if (mapflags
& ~LCMAPSTRINGA_SUPPORTED_FLAGS
)
2029 FIXME(string
,"(0x%04lx,0x%08lx,%p,%d,%p,%d): "
2030 "unimplemented flags: 0x%08lx\n",
2032 mapflags
& ~LCMAPSTRINGA_SUPPORTED_FLAGS
,
2041 if ( !(mapflags
& LCMAP_SORTKEY
) )
2044 int (*f
)(int) = identity
;
2045 int flag_ignorenonspace
= mapflags
& NORM_IGNORENONSPACE
;
2046 int flag_ignoresymbols
= mapflags
& NORM_IGNORESYMBOLS
;
2048 if (flag_ignorenonspace
|| flag_ignoresymbols
)
2050 /* For some values of mapflags, the length of the resulting
2051 string is not known at this point. Windows does map the string
2052 and does not SetLastError ERROR_INSUFFICIENT_BUFFER in
2056 /* Compute required length */
2057 for (i
=j
=0; i
< srclen
; i
++)
2059 if ( !(flag_ignorenonspace
&& OLE2NLS_isNonSpacing(srcstr
[i
]))
2060 && !(flag_ignoresymbols
&& OLE2NLS_isSymbol(srcstr
[i
])) )
2072 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2076 if (mapflags
& LCMAP_UPPERCASE
)
2078 else if (mapflags
& LCMAP_LOWERCASE
)
2080 /* FIXME: NORM_IGNORENONSPACE requires another conversion */
2081 for (i
=j
=0; (i
<srclen
) && (j
<dstlen
) ; i
++)
2083 if ( !(flag_ignorenonspace
&& OLE2NLS_isNonSpacing(srcstr
[i
]))
2084 && !(flag_ignoresymbols
&& OLE2NLS_isSymbol(srcstr
[i
])) )
2086 dststr
[j
] = (CHAR
) f(srcstr
[i
]);
2093 /* else ... (mapflags & LCMAP_SORTKEY) */
2097 int diacritic_len
=0;
2098 int delayed_punctuation_len
=0;
2099 char *case_component
;
2100 char *diacritic_component
;
2101 char *delayed_punctuation_component
;
2103 int flag_stringsort
= mapflags
& SORT_STRINGSORT
;
2105 /* compute how much room we will need */
2106 for (i
=0;i
<srclen
;i
++)
2109 unsigned char source_char
= srcstr
[i
];
2110 if (source_char
!='\0')
2112 if (flag_stringsort
|| !OLE2NLS_isPunctuation(source_char
))
2115 if ( LCM_Unicode_LUT
[-2+2*source_char
] & ~15 )
2116 unicode_len
++; /* double letter */
2120 delayed_punctuation_len
++;
2124 if (isupper(source_char
))
2125 case_len
=unicode_len
;
2127 ofs
= source_char
- LCM_Diacritic_Start
;
2128 if ((ofs
>=0) && (LCM_Diacritic_LUT
[ofs
]!=2))
2129 diacritic_len
=unicode_len
;
2132 if (mapflags
& NORM_IGNORECASE
)
2134 if (mapflags
& NORM_IGNORENONSPACE
)
2137 room
= 2 * unicode_len
/* "unicode" component */
2138 + diacritic_len
/* "diacritic" component */
2139 + case_len
/* "case" component */
2140 + 4 * delayed_punctuation_len
/* punctuation in word sort mode */
2141 + 4 /* four '\1' separators */
2142 + 1 ; /* terminal '\0' */
2145 else if (dstlen
<room
)
2147 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2151 /*FIXME the Pointercheck should not be nessesary */
2152 if (IsBadWritePtr (dststr
,room
))
2153 { ERR (string
,"bad destination buffer (dststr) : %p,%d\n",dststr
,dstlen
);
2154 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2158 /* locate each component, write separators */
2159 diacritic_component
= dststr
+ 2*unicode_len
;
2160 *diacritic_component
++ = '\1';
2161 case_component
= diacritic_component
+ diacritic_len
;
2162 *case_component
++ = '\1';
2163 delayed_punctuation_component
= case_component
+ case_len
;
2164 *delayed_punctuation_component
++ = '\1';
2165 *delayed_punctuation_component
++ = '\1';
2167 /* read source string char by char, write
2168 corresponding weight in each component. */
2169 for (i
=0,count
=0;i
<srclen
;i
++)
2171 unsigned char source_char
=srcstr
[i
];
2172 if (source_char
!='\0')
2175 type
= LCM_Unicode_LUT
[-2+2*source_char
];
2176 longcode
= type
>> 4;
2178 if (!flag_stringsort
&& OLE2NLS_isPunctuation(source_char
))
2180 UINT16 encrypted_location
= (1<<15) + 7 + 4*count
;
2181 *delayed_punctuation_component
++ = (unsigned char) (encrypted_location
>>8);
2182 *delayed_punctuation_component
++ = (unsigned char) (encrypted_location
&255);
2183 /* big-endian is used here because it lets string comparison be
2184 compatible with numerical comparison */
2186 *delayed_punctuation_component
++ = type
;
2187 *delayed_punctuation_component
++ = LCM_Unicode_LUT
[-1+2*source_char
];
2188 /* assumption : a punctuation character is never a
2189 double or accented letter */
2193 dststr
[2*count
] = type
;
2194 dststr
[2*count
+1] = LCM_Unicode_LUT
[-1+2*source_char
];
2198 case_component
[count
] = ( isupper(source_char
) ? 18 : 2 ) ;
2199 if (count
<diacritic_len
)
2200 diacritic_component
[count
] = 2; /* assumption: a double letter
2201 is never accented */
2204 dststr
[2*count
] = type
;
2205 dststr
[2*count
+1] = *(LCM_Unicode_LUT_2
- 1 + longcode
);
2206 /* 16 in the first column of LCM_Unicode_LUT --> longcode = 1
2207 32 in the first column of LCM_Unicode_LUT --> longcode = 2
2208 48 in the first column of LCM_Unicode_LUT --> longcode = 3 */
2212 case_component
[count
] = ( isupper(source_char
) ? 18 : 2 ) ;
2213 if (count
<diacritic_len
)
2215 int ofs
= source_char
- LCM_Diacritic_Start
;
2216 diacritic_component
[count
] = (ofs
>=0 ? LCM_Diacritic_LUT
[ofs
] : 2);
2222 dststr
[room
-1] = '\0';
2227 /*************************************************************************
2228 * LCMapString32W [KERNEL32.493]
2230 * Convert a string, or generate a sort key from it.
2234 * See LCMapString32A for documentation
2236 INT WINAPI
LCMapStringW(
2237 LCID lcid
,DWORD mapflags
,LPCWSTR srcstr
,INT srclen
,LPWSTR dststr
,
2242 TRACE(string
,"(0x%04lx,0x%08lx,%p,%d,%p,%d)\n",
2243 lcid
,mapflags
,srcstr
,srclen
,dststr
,dstlen
);
2245 if ( ((dstlen
!=0) && (dststr
==NULL
)) || (srcstr
==NULL
) )
2247 ERR(ole
, "(src=%p,dst=%p): Invalid NULL string\n", srcstr
, dststr
);
2248 SetLastError(ERROR_INVALID_PARAMETER
);
2252 srclen
= lstrlenW(srcstr
)+1;
2253 if (mapflags
& LCMAP_SORTKEY
)
2255 FIXME(string
,"(0x%04lx,0x%08lx,%p,%d,%p,%d): "
2256 "unimplemented flags: 0x%08lx\n",
2257 lcid
,mapflags
,srcstr
,srclen
,dststr
,dstlen
,mapflags
);
2262 int (*f
)(int)=identity
;
2266 if (dstlen
<srclen
) {
2267 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2270 if (mapflags
& LCMAP_UPPERCASE
)
2272 else if (mapflags
& LCMAP_LOWERCASE
)
2274 for (i
=0; i
< srclen
; i
++)
2275 dststr
[i
] = (WCHAR
) f(srcstr
[i
]);
2280 /***********************************************************************
2281 * CompareString16 (OLE2NLS.8)
2283 UINT16 WINAPI
CompareString16(DWORD lcid
,DWORD fdwStyle
,
2284 LPCSTR s1
,DWORD l1
,LPCSTR s2
,DWORD l2
)
2286 return (UINT16
)CompareStringA(lcid
,fdwStyle
,s1
,l1
,s2
,l2
);
2289 /******************************************************************************
2290 * CompareString32A [KERNEL32.143]
2291 * Compares two strings using locale
2295 * success: CSTR_LESS_THAN, CSTR_EQUAL, CSTR_GREATER_THAN
2300 * Defaults to a word sort, but uses a string sort if
2301 * SORT_STRINGSORT is set.
2302 * Calls SetLastError for ERROR_INVALID_FLAGS, ERROR_INVALID_PARAMETER.
2306 * This implementation ignores the locale
2310 * Quite inefficient.
2312 UINT WINAPI
CompareStringA(
2313 DWORD lcid
, /* locale ID */
2314 DWORD fdwStyle
, /* comparison-style options */
2315 LPCSTR s1
, /* first string */
2316 DWORD l1
, /* length of first string */
2317 LPCSTR s2
, /* second string */
2318 DWORD l2
) /* length of second string */
2320 int mapstring_flags
;
2324 TRACE(ole
,"%s and %s\n",
2325 debugstr_a (s1
), debugstr_a (s2
));
2327 if ( (s1
==NULL
) || (s2
==NULL
) )
2329 ERR(ole
, "(s1=%s,s2=%s): Invalid NULL string\n", s1
, s2
);
2330 SetLastError(ERROR_INVALID_PARAMETER
);
2334 if(fdwStyle
& NORM_IGNORESYMBOLS
)
2335 FIXME(ole
, "IGNORESYMBOLS not supported\n");
2337 mapstring_flags
= LCMAP_SORTKEY
| fdwStyle
;
2338 len1
= LCMapStringA(lcid
,mapstring_flags
,s1
,l1
,NULL
,0);
2339 len2
= LCMapStringA(lcid
,mapstring_flags
,s2
,l2
,NULL
,0);
2341 if ((len1
==0)||(len2
==0))
2342 return 0; /* something wrong happened */
2344 sk1
= (LPSTR
)HeapAlloc(GetProcessHeap(),0,len1
);
2345 sk2
= (LPSTR
)HeapAlloc(GetProcessHeap(),0,len2
);
2346 if ( (!LCMapStringA(lcid
,mapstring_flags
,s1
,l1
,sk1
,len1
))
2347 || (!LCMapStringA(lcid
,mapstring_flags
,s2
,l2
,sk2
,len2
)) )
2349 ERR(ole
,"Bug in LCmapString32A.\n");
2354 /* strcmp doesn't necessarily return -1, 0, or 1 */
2355 result
= strcmp(sk1
,sk2
);
2357 HeapFree(GetProcessHeap(),0,sk1
);
2358 HeapFree(GetProcessHeap(),0,sk2
);
2365 /* must be greater, if we reach this point */
2369 /******************************************************************************
2370 * CompareString32W [KERNEL32.144]
2371 * This implementation ignores the locale
2372 * FIXME : Does only string sort. Should
2373 * be reimplemented the same way as CompareString32A.
2375 UINT WINAPI
CompareStringW(DWORD lcid
, DWORD fdwStyle
,
2376 LPCWSTR s1
, DWORD l1
, LPCWSTR s2
,DWORD l2
)
2379 if(fdwStyle
& NORM_IGNORENONSPACE
)
2380 FIXME(ole
,"IGNORENONSPACE not supprted\n");
2381 if(fdwStyle
& NORM_IGNORESYMBOLS
)
2382 FIXME(ole
,"IGNORESYMBOLS not supported\n");
2384 /* Is strcmp defaulting to string sort or to word sort?? */
2385 /* FIXME: Handle NORM_STRINGSORT */
2386 l1
= (l1
==-1)?lstrlenW(s1
):l1
;
2387 l2
= (l2
==-1)?lstrlenW(s2
):l2
;
2388 len
= l1
<l2
? l1
:l2
;
2389 ret
= (fdwStyle
& NORM_IGNORECASE
) ?
2390 lstrncmpiW(s1
,s2
,len
) : lstrncmpW(s1
,s2
,len
);
2391 /* not equal, return 1 or 3 */
2392 if(ret
!=0) return ret
+2;
2393 /* same len, return 2 */
2394 if(l1
==l2
) return 2;
2395 /* the longer one is lexically greater */
2396 return (l1
<l2
)? 1 : 3;
2399 /******************************************************************************
2400 * OLE_GetFormatA [Internal]
2403 * If datelen == 0, it should return the reguired string length.
2405 This function implements stuff for GetDateFormat() and
2408 d single-digit (no leading zero) day (of month)
2409 dd two-digit day (of month)
2410 ddd short day-of-week name
2411 dddd long day-of-week name
2412 M single-digit month
2414 MMM short month name
2415 MMMM full month name
2416 y two-digit year, no leading 0
2418 yyyy four-digit year
2420 h hours with no leading zero (12-hour)
2421 hh hours with full two digits
2422 H hours with no leading zero (24-hour)
2423 HH hours with full two digits
2424 m minutes with no leading zero
2425 mm minutes with full two digits
2426 s seconds with no leading zero
2427 ss seconds with full two digits
2428 t time marker (A or P)
2429 tt time marker (AM, PM)
2430 '' used to quote literal characters
2431 '' (within a quoted string) indicates a literal '
2433 These functions REQUIRE valid locale, date, and format.
2435 static INT
OLE_GetFormatA(LCID locale
,
2439 LPCSTR _format
, /*in*/
2444 int count
, type
, inquote
, Overflow
;
2450 const char * _dgfmt
[] = { "%d", "%02d" };
2451 const char ** dgfmt
= _dgfmt
- 1;
2453 /* report, for debugging */
2454 TRACE(ole
, "(0x%lx,0x%lx, 0x%lx, time(d=%d,h=%d,m=%d,s=%d), fmt=%p \'%s\' , %p, len=%d)\n",
2455 locale
, flags
, tflags
,
2456 xtime
->wDay
, xtime
->wHour
, xtime
->wMinute
, xtime
->wSecond
,
2457 _format
, _format
, date
, datelen
);
2460 FIXME(ole
, "datelen = 0, returning 255\n");
2464 /* initalize state variables and output buffer */
2466 count
= 0; inquote
= 0; Overflow
= 0;
2468 date
[0] = buf
[0] = '\0';
2470 strcpy(format
,_format
);
2472 /* alter the formatstring, while it works for all languages now in wine
2473 its possible that it fails when the time looks like ss:mm:hh as example*/
2474 if (tflags
& (TIME_NOMINUTESORSECONDS
))
2475 { if ((pos
= strstr ( format
, ":mm")))
2476 { memcpy ( pos
, pos
+3, strlen(format
)-(pos
-format
)-2 );
2479 if (tflags
& (TIME_NOSECONDS
))
2480 { if ((pos
= strstr ( format
, ":ss")))
2481 { memcpy ( pos
, pos
+3, strlen(format
)-(pos
-format
)-2 );
2485 for (inpos
= 0;; inpos
++) {
2486 /* 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]); */
2488 if (format
[inpos
] == '\'') {
2489 if (format
[inpos
+1] == '\'') {
2491 date
[outpos
++] = '\'';
2494 continue; /* we did nothing to the output */
2496 } else if (format
[inpos
] == '\0') {
2497 date
[outpos
++] = '\0';
2498 if (outpos
> datelen
) Overflow
= 1;
2501 date
[outpos
++] = format
[inpos
];
2502 if (outpos
> datelen
) {
2504 date
[outpos
-1] = '\0'; /* this is the last place where
2505 it's safe to write */
2509 } else if ( (count
&& (format
[inpos
] != type
))
2511 || (count
== 2 && strchr("ghHmst", type
)) )
2515 GetLocaleInfoA(locale
,
2517 + xtime
->wDayOfWeek
- 1,
2519 } else if (count
== 3) {
2520 GetLocaleInfoA(locale
,
2521 LOCALE_SABBREVDAYNAME1
2522 + xtime
->wDayOfWeek
- 1,
2525 sprintf(buf
, dgfmt
[count
], xtime
->wDay
);
2527 } else if (type
== 'M') {
2529 GetLocaleInfoA(locale
,
2530 LOCALE_SABBREVMONTHNAME1
2531 + xtime
->wMonth
- 1,
2533 } else if (count
== 4) {
2534 GetLocaleInfoA(locale
,
2536 + xtime
->wMonth
- 1,
2539 sprintf(buf
, dgfmt
[count
], xtime
->wMonth
);
2541 } else if (type
== 'y') {
2543 sprintf(buf
, "%d", xtime
->wYear
);
2544 } else if (count
== 3) {
2546 WARN(ole
, "unknown format, c=%c, n=%d\n", type
, count
);
2548 sprintf(buf
, dgfmt
[count
], xtime
->wYear
% 100);
2550 } else if (type
== 'g') {
2552 FIXME(ole
, "LOCALE_ICALENDARTYPE unimp.\n");
2556 WARN(ole
, "unknown format, c=%c, n=%d\n", type
, count
);
2558 } else if (type
== 'h') {
2559 /* gives us hours 1:00 -- 12:00 */
2560 sprintf(buf
, dgfmt
[count
], (xtime
->wHour
-1)%12 +1);
2561 } else if (type
== 'H') {
2563 sprintf(buf
, dgfmt
[count
], xtime
->wHour
);
2564 } else if ( type
== 'm') {
2565 sprintf(buf
, dgfmt
[count
], xtime
->wMinute
);
2566 } else if ( type
== 's') {
2567 sprintf(buf
, dgfmt
[count
], xtime
->wSecond
);
2568 } else if (type
== 't') {
2570 sprintf(buf
, "%c", (xtime
->wHour
< 12) ? 'A' : 'P');
2571 } else if (count
== 2) {
2572 /* sprintf(buf, "%s", (xtime->wHour < 12) ? "AM" : "PM"); */
2573 GetLocaleInfoA(locale
,
2575 ? LOCALE_S1159
: LOCALE_S2359
,
2580 /* we need to check the next char in the format string
2581 again, no matter what happened */
2584 /* add the contents of buf to the output */
2585 buflen
= strlen(buf
);
2586 if (outpos
+ buflen
< datelen
) {
2587 date
[outpos
] = '\0'; /* for strcat to hook onto */
2591 date
[outpos
] = '\0';
2592 strncat(date
, buf
, datelen
- outpos
);
2593 date
[datelen
- 1] = '\0';
2594 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2595 WARN(ole
, "insufficient buffer\n");
2599 /* reset the variables we used to keep track of this item */
2602 } else if (format
[inpos
] == '\0') {
2603 /* we can't check for this at the loop-head, because
2604 that breaks the printing of the last format-item */
2605 date
[outpos
] = '\0';
2608 /* continuing a code for an item */
2611 } else if (strchr("hHmstyMdg", format
[inpos
])) {
2612 type
= format
[inpos
];
2615 } else if (format
[inpos
] == '\'') {
2619 date
[outpos
++] = format
[inpos
];
2621 /* now deal with a possible buffer overflow */
2622 if (outpos
>= datelen
) {
2623 date
[datelen
- 1] = '\0';
2624 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2630 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2633 /* finish it off with a string terminator */
2636 if (outpos
> datelen
-1) outpos
= datelen
-1;
2637 date
[outpos
] = '\0';
2639 TRACE(ole
, "OLE_GetFormatA returns string '%s', len %d\n",
2644 /******************************************************************************
2645 * OLE_GetFormatW [INTERNAL]
2647 static INT
OLE_GetFormatW(LCID locale
, DWORD flags
, DWORD tflags
,
2650 LPWSTR output
, INT outlen
)
2653 int count
, type
=0, inquote
;
2654 int Overflow
; /* loop check */
2657 WCHAR arg0
[] = {0}, arg1
[] = {'%','d',0};
2658 WCHAR arg2
[] = {'%','0','2','d',0};
2659 WCHAR
*argarr
[] = {arg0
, arg1
, arg2
};
2660 int datevars
=0, timevars
=0;
2662 /* make a debug report */
2663 TRACE(ole
, "args: 0x%lx, 0x%lx, 0x%lx, time(d=%d,h=%d,m=%d,s=%d), fmt:%s (at %p),
2664 %p with max len %d\n",
2665 locale
, flags
, tflags
,
2666 xtime
->wDay
, xtime
->wHour
, xtime
->wMinute
, xtime
->wSecond
,
2667 debugstr_w(format
), format
, output
, outlen
);
2670 FIXME(ole
, "outlen = 0, returning 255\n");
2674 /* initialize state variables */
2677 inquote
= Overflow
= 0;
2678 /* this is really just a sanity check */
2679 output
[0] = buf
[0] = 0;
2681 /* this loop is the core of the function */
2682 for (inpos
= 0; /* we have several break points */ ; inpos
++) {
2684 if (format
[inpos
] == (WCHAR
) '\'') {
2685 if (format
[inpos
+1] == '\'') {
2687 output
[outpos
++] = '\'';
2692 } else if (format
[inpos
] == 0) {
2693 output
[outpos
++] = 0;
2694 if (outpos
> outlen
) Overflow
= 1;
2695 break; /* normal exit (within a quote) */
2697 output
[outpos
++] = format
[inpos
]; /* copy input */
2698 if (outpos
> outlen
) {
2700 output
[outpos
-1] = 0;
2704 } else if ( (count
&& (format
[inpos
] != type
))
2705 || ( (count
==4 && type
=='y') ||
2706 (count
==4 && type
=='M') ||
2707 (count
==4 && type
=='d') ||
2708 (count
==2 && type
=='g') ||
2709 (count
==2 && type
=='h') ||
2710 (count
==2 && type
=='H') ||
2711 (count
==2 && type
=='m') ||
2712 (count
==2 && type
=='s') ||
2713 (count
==2 && type
=='t') ) ) {
2716 GetLocaleInfoW(locale
,
2717 LOCALE_SDAYNAME1
+ xtime
->wDayOfWeek
-1,
2718 buf
, sizeof(buf
)/sizeof(WCHAR
) );
2719 } else if (count
== 3) {
2720 GetLocaleInfoW(locale
,
2721 LOCALE_SABBREVDAYNAME1
+
2722 xtime
->wDayOfWeek
-1,
2723 buf
, sizeof(buf
)/sizeof(WCHAR
) );
2725 wsnprintfW(buf
, 5, argarr
[count
], xtime
->wDay
);
2727 } else if (type
== 'M') {
2729 GetLocaleInfoW(locale
, LOCALE_SMONTHNAME1
+
2730 xtime
->wMonth
-1, buf
,
2731 sizeof(buf
)/sizeof(WCHAR
) );
2732 } else if (count
== 3) {
2733 GetLocaleInfoW(locale
, LOCALE_SABBREVMONTHNAME1
+
2734 xtime
->wMonth
-1, buf
,
2735 sizeof(buf
)/sizeof(WCHAR
) );
2737 wsnprintfW(buf
, 5, argarr
[count
], xtime
->wMonth
);
2739 } else if (type
== 'y') {
2741 wsnprintfW(buf
, 6, argarr
[1] /* "%d" */,
2743 } else if (count
== 3) {
2744 lstrcpynAtoW(buf
, "yyy", 5);
2746 wsnprintfW(buf
, 6, argarr
[count
],
2747 xtime
->wYear
% 100);
2749 } else if (type
== 'g') {
2751 FIXME(ole
, "LOCALE_ICALENDARTYPE unimplemented\n");
2752 lstrcpynAtoW(buf
, "AD", 5);
2754 /* Win API sez we copy it verbatim */
2755 lstrcpynAtoW(buf
, "g", 5);
2757 } else if (type
== 'h') {
2758 /* hours 1:00-12:00 --- is this right? */
2759 wsnprintfW(buf
, 5, argarr
[count
],
2760 (xtime
->wHour
-1)%12 +1);
2761 } else if (type
== 'H') {
2762 wsnprintfW(buf
, 5, argarr
[count
],
2764 } else if (type
== 'm' ) {
2765 wsnprintfW(buf
, 5, argarr
[count
],
2767 } else if (type
== 's' ) {
2768 wsnprintfW(buf
, 5, argarr
[count
],
2770 } else if (type
== 't') {
2771 GetLocaleInfoW(locale
, (xtime
->wHour
< 12) ?
2772 LOCALE_S1159
: LOCALE_S2359
,
2779 /* no matter what happened, we need to check this next
2780 character the next time we loop through */
2783 /* cat buf onto the output */
2784 outlen
= lstrlenW(buf
);
2785 if (outpos
+ buflen
< outlen
) {
2786 output
[outpos
] = 0; /* a "hook" for strcat */
2787 lstrcatW(output
, buf
);
2791 lstrcatnW(output
, buf
, outlen
- outpos
);
2792 output
[outlen
- 1] = 0;
2794 break; /* Abnormal exit */
2797 /* reset the variables we used this time */
2800 } else if (format
[inpos
] == 0) {
2801 /* we can't check for this at the beginning, because that
2802 would keep us from printing a format spec that ended the
2805 break; /* NORMAL EXIT */
2807 /* how we keep track of the middle of a format spec */
2810 } else if ( (datevars
&& (format
[inpos
]=='d' ||
2811 format
[inpos
]=='M' ||
2812 format
[inpos
]=='y' ||
2813 format
[inpos
]=='g') ) ||
2814 (timevars
&& (format
[inpos
]=='H' ||
2815 format
[inpos
]=='h' ||
2816 format
[inpos
]=='m' ||
2817 format
[inpos
]=='s' ||
2818 format
[inpos
]=='t') ) ) {
2819 type
= format
[inpos
];
2822 } else if (format
[inpos
] == '\'') {
2826 /* unquoted literals */
2827 output
[outpos
++] = format
[inpos
];
2832 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2833 WARN(ole
, " buffer overflow\n");
2836 /* final string terminator and sanity check */
2838 if (outpos
> outlen
-1) outpos
= outlen
-1;
2839 output
[outpos
] = '0';
2841 TRACE(ole
, " returning %s\n", debugstr_w(output
));
2843 return (!Overflow
) ? outlen
: 0;
2848 /******************************************************************************
2849 * GetDateFormat32A [KERNEL32.310]
2850 * Makes an ASCII string of the date
2852 * This function uses format to format the date, or, if format
2853 * is NULL, uses the default for the locale. format is a string
2854 * of literal fields and characters as follows:
2856 * - d single-digit (no leading zero) day (of month)
2857 * - dd two-digit day (of month)
2858 * - ddd short day-of-week name
2859 * - dddd long day-of-week name
2860 * - M single-digit month
2861 * - MM two-digit month
2862 * - MMM short month name
2863 * - MMMM full month name
2864 * - y two-digit year, no leading 0
2865 * - yy two-digit year
2866 * - yyyy four-digit year
2870 INT WINAPI
GetDateFormatA(LCID locale
,DWORD flags
,
2872 LPCSTR format
, LPSTR date
,INT datelen
)
2875 char format_buf
[40];
2878 LPSYSTEMTIME thistime
;
2882 TRACE(ole
,"(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",
2883 locale
,flags
,xtime
,format
,date
,datelen
);
2886 locale
= LOCALE_SYSTEM_DEFAULT
;
2889 if (locale
== LOCALE_SYSTEM_DEFAULT
) {
2890 thislocale
= GetSystemDefaultLCID();
2891 } else if (locale
== LOCALE_USER_DEFAULT
) {
2892 thislocale
= GetUserDefaultLCID();
2894 thislocale
= locale
;
2897 if (xtime
== NULL
) {
2904 if (format
== NULL
) {
2905 GetLocaleInfoA(thislocale
, ((flags
&DATE_LONGDATE
)
2907 : LOCALE_SSHORTDATE
),
2908 format_buf
, sizeof(format_buf
));
2909 thisformat
= format_buf
;
2911 thisformat
= format
;
2915 ret
= OLE_GetFormatA(thislocale
, flags
, 0, thistime
, thisformat
,
2920 "GetDateFormat32A() returning %d, with data=%s\n",
2925 /******************************************************************************
2926 * GetDateFormat32W [KERNEL32.311]
2927 * Makes a Unicode string of the date
2929 * Acts the same as GetDateFormat32A(), except that it's Unicode.
2930 * Accepts & returns sizes as counts of Unicode characters.
2933 INT WINAPI
GetDateFormatW(LCID locale
,DWORD flags
,
2936 LPWSTR date
, INT datelen
)
2938 unsigned short datearr
[] = {'1','9','9','4','-','1','-','1',0};
2940 FIXME(ole
, "STUB (should call OLE_GetFormatW)\n");
2941 lstrcpynW(date
, datearr
, datelen
);
2942 return ( datelen
< 9) ? datelen
: 9;
2947 /**************************************************************************
2948 * EnumDateFormats32A (KERNEL32.198)
2950 BOOL WINAPI
EnumDateFormatsA(
2951 DATEFMT_ENUMPROCA lpDateFmtEnumProc
, LCID Locale
, DWORD dwFlags
)
2953 FIXME(ole
, "Only US English supported\n");
2955 if(!lpDateFmtEnumProc
)
2957 SetLastError(ERROR_INVALID_PARAMETER
);
2963 case DATE_SHORTDATE
:
2964 if(!(*lpDateFmtEnumProc
)("M/d/yy")) return TRUE
;
2965 if(!(*lpDateFmtEnumProc
)("M/d/yyyy")) return TRUE
;
2966 if(!(*lpDateFmtEnumProc
)("MM/dd/yy")) return TRUE
;
2967 if(!(*lpDateFmtEnumProc
)("MM/dd/yyyy")) return TRUE
;
2968 if(!(*lpDateFmtEnumProc
)("yy/MM/dd")) return TRUE
;
2969 if(!(*lpDateFmtEnumProc
)("dd-MMM-yy")) return TRUE
;
2972 if(!(*lpDateFmtEnumProc
)("dddd, MMMM dd, yyyy")) return TRUE
;
2973 if(!(*lpDateFmtEnumProc
)("MMMM dd, yyyy")) return TRUE
;
2974 if(!(*lpDateFmtEnumProc
)("dddd, dd MMMM, yyyy")) return TRUE
;
2975 if(!(*lpDateFmtEnumProc
)("dd MMMM, yyyy")) return TRUE
;
2978 FIXME(ole
, "Unknown date format (%ld)\n", dwFlags
);
2979 SetLastError(ERROR_INVALID_PARAMETER
);
2984 /**************************************************************************
2985 * EnumDateFormats32W (KERNEL32.199)
2987 BOOL WINAPI
EnumDateFormatsW(
2988 DATEFMT_ENUMPROCW lpDateFmtEnumProc
, LCID Locale
, DWORD dwFlags
)
2990 FIXME(ole
, "(%p, %ld, %ld): stub\n", lpDateFmtEnumProc
, Locale
, dwFlags
);
2991 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
2995 /**************************************************************************
2996 * EnumTimeFormats32A (KERNEL32.210)
2998 BOOL WINAPI
EnumTimeFormatsA(
2999 TIMEFMT_ENUMPROCA lpTimeFmtEnumProc
, LCID Locale
, DWORD dwFlags
)
3001 FIXME(ole
, "Only US English supported\n");
3003 if(!lpTimeFmtEnumProc
)
3005 SetLastError(ERROR_INVALID_PARAMETER
);
3011 FIXME(ole
, "Unknown time format (%ld)\n", dwFlags
);
3014 if(!(*lpTimeFmtEnumProc
)("h:mm:ss tt")) return TRUE
;
3015 if(!(*lpTimeFmtEnumProc
)("hh:mm:ss tt")) return TRUE
;
3016 if(!(*lpTimeFmtEnumProc
)("H:mm:ss")) return TRUE
;
3017 if(!(*lpTimeFmtEnumProc
)("HH:mm:ss")) return TRUE
;
3022 /**************************************************************************
3023 * EnumTimeFormats32W (KERNEL32.211)
3025 BOOL WINAPI
EnumTimeFormatsW(
3026 TIMEFMT_ENUMPROCW lpTimeFmtEnumProc
, LCID Locale
, DWORD dwFlags
)
3028 FIXME(ole
, "(%p,%ld,%ld): stub\n", lpTimeFmtEnumProc
, Locale
, dwFlags
);
3029 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
3033 /**************************************************************************
3034 * GetNumberFormat32A (KERNEL32.355)
3036 INT WINAPI
GetNumberFormatA(LCID locale
, DWORD dwflags
,
3037 LPCSTR lpvalue
, const NUMBERFMTA
* lpFormat
,
3038 LPSTR lpNumberStr
, int cchNumber
)
3040 FIXME(file
,"%s: stub, no reformating done\n",lpvalue
);
3042 lstrcpynA( lpNumberStr
, lpvalue
, cchNumber
);
3043 return cchNumber
? lstrlenA( lpNumberStr
) : 0;
3045 /**************************************************************************
3046 * GetNumberFormat32W (KERNEL32.xxx)
3048 INT WINAPI
GetNumberFormatW(LCID locale
, DWORD dwflags
,
3049 LPCWSTR lpvalue
, const NUMBERFMTW
* lpFormat
,
3050 LPWSTR lpNumberStr
, int cchNumber
)
3052 FIXME(file
,"%s: stub, no reformating done\n",debugstr_w(lpvalue
));
3054 lstrcpynW( lpNumberStr
, lpvalue
, cchNumber
);
3055 return cchNumber
? lstrlenW( lpNumberStr
) : 0;
3057 /******************************************************************************
3058 * OLE2NLS_CheckLocale [intern]
3060 static LCID
OLE2NLS_CheckLocale (LCID locale
)
3063 { locale
= LOCALE_SYSTEM_DEFAULT
;
3066 if (locale
== LOCALE_SYSTEM_DEFAULT
)
3067 { return GetSystemDefaultLCID();
3069 else if (locale
== LOCALE_USER_DEFAULT
)
3070 { return GetUserDefaultLCID();
3076 /******************************************************************************
3077 * GetTimeFormat32A [KERNEL32.422]
3078 * Makes an ASCII string of the time
3080 * Formats date according to format, or locale default if format is
3081 * NULL. The format consists of literal characters and fields as follows:
3083 * h hours with no leading zero (12-hour)
3084 * hh hours with full two digits
3085 * H hours with no leading zero (24-hour)
3086 * HH hours with full two digits
3087 * m minutes with no leading zero
3088 * mm minutes with full two digits
3089 * s seconds with no leading zero
3090 * ss seconds with full two digits
3091 * t time marker (A or P)
3092 * tt time marker (AM, PM)
3096 GetTimeFormatA(LCID locale
, /* in */
3097 DWORD flags
, /* in */
3098 LPSYSTEMTIME xtime
, /* in */
3099 LPCSTR format
, /* in */
3100 LPSTR timestr
, /* out */
3101 INT timelen
/* in */)
3102 { char format_buf
[40];
3105 LPSYSTEMTIME thistime
;
3107 DWORD thisflags
=LOCALE_STIMEFORMAT
; /* standart timeformat */
3110 TRACE(ole
,"GetTimeFormat(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",locale
,flags
,xtime
,format
,timestr
,timelen
);
3112 thislocale
= OLE2NLS_CheckLocale ( locale
);
3114 if ( flags
& (TIME_NOTIMEMARKER
| TIME_FORCE24HOURFORMAT
))
3115 { FIXME(ole
,"TIME_NOTIMEMARKER or TIME_FORCE24HOURFORMAT not implemented\n");
3118 flags
&= (TIME_NOSECONDS
| TIME_NOMINUTESORSECONDS
); /* mask for OLE_GetFormatA*/
3121 { if (flags
& LOCALE_NOUSEROVERRIDE
) /*use system default*/
3122 { thislocale
= GetSystemDefaultLCID();
3124 GetLocaleInfoA(thislocale
, thisflags
, format_buf
, sizeof(format_buf
));
3125 thisformat
= format_buf
;
3128 { thisformat
= format
;
3131 if (xtime
== NULL
) /* NULL means use the current local time*/
3132 { GetSystemTime(&t
);
3138 ret
= OLE_GetFormatA(thislocale
, thisflags
, flags
, thistime
, thisformat
,
3144 /******************************************************************************
3145 * GetTimeFormat32W [KERNEL32.423]
3146 * Makes a Unicode string of the time
3149 GetTimeFormatW(LCID locale
, /* in */
3150 DWORD flags
, /* in */
3151 LPSYSTEMTIME xtime
, /* in */
3152 LPCWSTR format
, /* in */
3153 LPWSTR timestr
, /* out */
3154 INT timelen
/* in */)
3155 { WCHAR format_buf
[40];
3158 LPSYSTEMTIME thistime
;
3160 DWORD thisflags
=LOCALE_STIMEFORMAT
; /* standart timeformat */
3163 TRACE(ole
,"GetTimeFormat(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",locale
,flags
,
3164 xtime
,debugstr_w(format
),timestr
,timelen
);
3166 thislocale
= OLE2NLS_CheckLocale ( locale
);
3168 if ( flags
& (TIME_NOTIMEMARKER
| TIME_FORCE24HOURFORMAT
))
3169 { FIXME(ole
,"TIME_NOTIMEMARKER or TIME_FORCE24HOURFORMAT not implemented\n");
3172 flags
&= (TIME_NOSECONDS
| TIME_NOMINUTESORSECONDS
); /* mask for OLE_GetFormatA*/
3175 { if (flags
& LOCALE_NOUSEROVERRIDE
) /*use system default*/
3176 { thislocale
= GetSystemDefaultLCID();
3178 GetLocaleInfoW(thislocale
, thisflags
, format_buf
, 40);
3179 thisformat
= format_buf
;
3182 { thisformat
= format
;
3185 if (xtime
== NULL
) /* NULL means use the current local time*/
3186 { GetSystemTime(&t
);
3193 ret
= OLE_GetFormatW(thislocale
, thisflags
, flags
, thistime
, thisformat
,