4 * Copyright 1995 Martin von Loewis
5 * Copyright 1998 David Lee Lambert
21 struct NLS_langlocale
{
23 struct NLS_localevar
{
29 #define LANG_BEGIN(l,s) { MAKELANGID(l,s), {
31 #define LOCVAL(type,value) {type,value},
35 static const struct NLS_langlocale langlocales
[] = {
36 /* add languages in numerical order of main language (last two digits)
37 * it is much easier to find the missing holes that way */
39 LANG_BEGIN (LANG_CATALAN
, SUBLANG_DEFAULT
) /*0x0403*/
40 #include "nls/cat.nls"
43 LANG_BEGIN (LANG_CZECH
, SUBLANG_DEFAULT
) /*0x0405*/
44 #include "nls/cze.nls"
47 LANG_BEGIN (LANG_DANISH
, SUBLANG_DEFAULT
) /*0x0406*/
48 #include "nls/dan.nls"
51 LANG_BEGIN (LANG_GERMAN
, SUBLANG_GERMAN
) /*0x0407*/
52 #include "nls/deu.nls"
54 LANG_BEGIN (LANG_GERMAN
, SUBLANG_GERMAN_SWISS
) /*0x0807*/
55 #include "nls/des.nls"
57 LANG_BEGIN (LANG_GERMAN
, SUBLANG_GERMAN_AUSTRIAN
) /*0x0C07*/
58 #include "nls/dea.nls"
60 LANG_BEGIN (LANG_GERMAN
, SUBLANG_GERMAN_LUXEMBOURG
) /*0x1007*/
61 #include "nls/del.nls"
63 LANG_BEGIN (LANG_GERMAN
, SUBLANG_GERMAN_LIECHTENSTEIN
) /*0x1407*/
64 #include "nls/dec.nls"
67 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_US
) /*0x0409*/
68 #include "nls/enu.nls"
70 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_UK
) /*0x0809*/
71 #include "nls/eng.nls"
73 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_AUS
) /*0x0C09*/
74 #include "nls/ena.nls"
76 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_CAN
) /*0x1009*/
77 #include "nls/enc.nls"
79 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_NZ
) /*0x1409*/
80 #include "nls/enz.nls"
82 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_EIRE
) /*0x1809*/
83 #include "nls/irl.nls"
85 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_SAFRICA
) /*0x1C09*/
86 #include "nls/ens.nls"
88 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_JAMAICA
) /*0x2009*/
89 #include "nls/enj.nls"
91 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_CARRIBEAN
) /*0x2409*/
92 #include "nls/enb.nls"
94 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_BELIZE
) /*0x2809*/
95 #include "nls/enl.nls"
97 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_TRINIDAD
) /*0x2C09*/
98 #include "nls/ent.nls"
101 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH
) /*0x040a*/
102 #include "nls/esp.nls"
104 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_MEXICAN
) /*0x080a*/
105 #include "nls/esm.nls"
107 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_MODERN
) /*0x0C0a*/
108 #include "nls/esn.nls"
110 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_GUATEMALA
) /*0x100a*/
111 #include "nls/esg.nls"
113 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_COSTARICA
) /*0x140a*/
114 #include "nls/esc.nls"
116 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_PANAMA
) /*0x180a*/
117 #include "nls/esa.nls"
119 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_DOMINICAN
) /*0x1C0A*/
120 #include "nls/esd.nls"
122 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_VENEZUELA
) /*0x200a*/
123 #include "nls/esv.nls"
125 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_COLOMBIA
) /*0x240a*/
126 #include "nls/eso.nls"
128 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_PERU
) /*0x280a*/
129 #include "nls/esr.nls"
131 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_ARGENTINA
) /*0x2c0a*/
132 #include "nls/ess.nls"
134 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_ECUADOR
) /*0x300a*/
135 #include "nls/esf.nls"
137 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_CHILE
) /*0x340a*/
138 #include "nls/esl.nls"
140 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_URUGUAY
) /*0x380a*/
141 #include "nls/esy.nls"
143 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_PARAGUAY
) /*0x3c0a*/
144 #include "nls/esz.nls"
146 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_BOLIVIA
) /*0x400a*/
147 #include "nls/esb.nls"
149 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_EL_SALVADOR
) /*0x440a*/
150 #include "nls/ese.nls"
152 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_HONDURAS
) /*0x480a*/
153 #include "nls/esh.nls"
155 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_NICARAGUA
) /*0x4c0a*/
156 #include "nls/esi.nls"
158 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_PUERTO_RICO
) /*0x500a*/
159 #include "nls/esu.nls"
162 LANG_BEGIN (LANG_FINNISH
, SUBLANG_DEFAULT
) /*0x040B*/
163 #include "nls/fin.nls"
166 LANG_BEGIN (LANG_FRENCH
, SUBLANG_FRENCH
) /*0x040C*/
167 #include "nls/fra.nls"
169 LANG_BEGIN (LANG_FRENCH
, SUBLANG_FRENCH_BELGIAN
) /*0x080C*/
170 #include "nls/frb.nls"
172 LANG_BEGIN (LANG_FRENCH
, SUBLANG_FRENCH_CANADIAN
) /*0x0C0C*/
173 #include "nls/frc.nls"
175 LANG_BEGIN (LANG_FRENCH
, SUBLANG_FRENCH_SWISS
) /*0x100C*/
176 #include "nls/frs.nls"
178 LANG_BEGIN (LANG_FRENCH
, SUBLANG_FRENCH_LUXEMBOURG
) /*0x140C*/
179 #include "nls/frl.nls"
182 LANG_BEGIN (LANG_HUNGARIAN
, SUBLANG_DEFAULT
) /*0x040e*/
183 #include "nls/hun.nls"
186 LANG_BEGIN (LANG_ITALIAN
, SUBLANG_ITALIAN
) /*0x0410*/
187 #include "nls/ita.nls"
189 LANG_BEGIN (LANG_ITALIAN
, SUBLANG_ITALIAN_SWISS
) /*0x0810*/
190 #include "nls/its.nls"
193 LANG_BEGIN (LANG_KOREAN
, SUBLANG_KOREAN
) /*0x0412*/
194 #include "nls/kor.nls"
197 LANG_BEGIN (LANG_NORWEGIAN
, SUBLANG_NORWEGIAN_BOKMAL
) /*0x0414*/
198 #include "nls/nor.nls"
200 LANG_BEGIN (LANG_NORWEGIAN
, SUBLANG_NORWEGIAN_NYNORSK
) /*0x0814*/
201 #include "nls/non.nls"
204 LANG_BEGIN (LANG_POLISH
, SUBLANG_DEFAULT
) /*0x0415*/
205 #include "nls/plk.nls"
208 LANG_BEGIN (LANG_PORTUGUESE
,SUBLANG_PORTUGUESE_BRAZILIAN
) /*0x0416*/
209 #include "nls/ptb.nls"
211 LANG_BEGIN (LANG_PORTUGUESE
,SUBLANG_PORTUGUESE
) /*0x0816*/
212 #include "nls/ptg.nls"
215 LANG_BEGIN (LANG_SLOVAK
, SUBLANG_DEFAULT
) /*0x041b*/
216 #include "nls/sky.nls"
219 LANG_BEGIN (LANG_SWEDISH
, SUBLANG_SWEDISH
) /*0x041d*/
220 #include "nls/sve.nls"
222 LANG_BEGIN (LANG_SWEDISH
, SUBLANG_SWEDISH_FINLAND
) /*0x081d*/
223 #include "nls/svf.nls"
226 LANG_BEGIN (LANG_THAI
, SUBLANG_DEFAULT
) /*0x41e*/
227 #include "nls/tha.nls"
230 LANG_BEGIN (LANG_ESPERANTO
, SUBLANG_DEFAULT
) /*0x048f*/
231 #include "nls/esperanto.nls"
236 /* Locale name to id map. used by EnumSystemLocales, GetLocalInfoA
237 * MUST contain all #defines from winnls.h
238 * last entry has NULL name, 0 id.
240 #define LOCALE_ENTRY(x) {#x,LOCALE_##x}
241 static struct tagLOCALE_NAME2ID
{
244 } locale_name2id
[]= {
245 LOCALE_ENTRY(ILANGUAGE
),
246 LOCALE_ENTRY(SLANGUAGE
),
247 LOCALE_ENTRY(SENGLANGUAGE
),
248 LOCALE_ENTRY(SABBREVLANGNAME
),
249 LOCALE_ENTRY(SNATIVELANGNAME
),
250 LOCALE_ENTRY(ICOUNTRY
),
251 LOCALE_ENTRY(SCOUNTRY
),
252 LOCALE_ENTRY(SENGCOUNTRY
),
253 LOCALE_ENTRY(SABBREVCTRYNAME
),
254 LOCALE_ENTRY(SNATIVECTRYNAME
),
255 LOCALE_ENTRY(IDEFAULTLANGUAGE
),
256 LOCALE_ENTRY(IDEFAULTCOUNTRY
),
257 LOCALE_ENTRY(IDEFAULTCODEPAGE
),
258 LOCALE_ENTRY(IDEFAULTANSICODEPAGE
),
259 LOCALE_ENTRY(IDEFAULTMACCODEPAGE
),
261 LOCALE_ENTRY(IMEASURE
),
262 LOCALE_ENTRY(SDECIMAL
),
263 LOCALE_ENTRY(STHOUSAND
),
264 LOCALE_ENTRY(SGROUPING
),
265 LOCALE_ENTRY(IDIGITS
),
266 LOCALE_ENTRY(ILZERO
),
267 LOCALE_ENTRY(INEGNUMBER
),
268 LOCALE_ENTRY(SNATIVEDIGITS
),
269 LOCALE_ENTRY(SCURRENCY
),
270 LOCALE_ENTRY(SINTLSYMBOL
),
271 LOCALE_ENTRY(SMONDECIMALSEP
),
272 LOCALE_ENTRY(SMONTHOUSANDSEP
),
273 LOCALE_ENTRY(SMONGROUPING
),
274 LOCALE_ENTRY(ICURRDIGITS
),
275 LOCALE_ENTRY(IINTLCURRDIGITS
),
276 LOCALE_ENTRY(ICURRENCY
),
277 LOCALE_ENTRY(INEGCURR
),
280 LOCALE_ENTRY(SSHORTDATE
),
281 LOCALE_ENTRY(SLONGDATE
),
282 LOCALE_ENTRY(STIMEFORMAT
),
284 LOCALE_ENTRY(ILDATE
),
286 LOCALE_ENTRY(ITIMEMARKPOSN
),
287 LOCALE_ENTRY(ICENTURY
),
288 LOCALE_ENTRY(ITLZERO
),
289 LOCALE_ENTRY(IDAYLZERO
),
290 LOCALE_ENTRY(IMONLZERO
),
293 LOCALE_ENTRY(ICALENDARTYPE
),
294 LOCALE_ENTRY(IOPTIONALCALENDAR
),
295 LOCALE_ENTRY(IFIRSTDAYOFWEEK
),
296 LOCALE_ENTRY(IFIRSTWEEKOFYEAR
),
297 LOCALE_ENTRY(SDAYNAME1
),
298 LOCALE_ENTRY(SDAYNAME2
),
299 LOCALE_ENTRY(SDAYNAME3
),
300 LOCALE_ENTRY(SDAYNAME4
),
301 LOCALE_ENTRY(SDAYNAME5
),
302 LOCALE_ENTRY(SDAYNAME6
),
303 LOCALE_ENTRY(SDAYNAME7
),
304 LOCALE_ENTRY(SABBREVDAYNAME1
),
305 LOCALE_ENTRY(SABBREVDAYNAME2
),
306 LOCALE_ENTRY(SABBREVDAYNAME3
),
307 LOCALE_ENTRY(SABBREVDAYNAME4
),
308 LOCALE_ENTRY(SABBREVDAYNAME5
),
309 LOCALE_ENTRY(SABBREVDAYNAME6
),
310 LOCALE_ENTRY(SABBREVDAYNAME7
),
311 LOCALE_ENTRY(SMONTHNAME1
),
312 LOCALE_ENTRY(SMONTHNAME2
),
313 LOCALE_ENTRY(SMONTHNAME3
),
314 LOCALE_ENTRY(SMONTHNAME4
),
315 LOCALE_ENTRY(SMONTHNAME5
),
316 LOCALE_ENTRY(SMONTHNAME6
),
317 LOCALE_ENTRY(SMONTHNAME7
),
318 LOCALE_ENTRY(SMONTHNAME8
),
319 LOCALE_ENTRY(SMONTHNAME9
),
320 LOCALE_ENTRY(SMONTHNAME10
),
321 LOCALE_ENTRY(SMONTHNAME11
),
322 LOCALE_ENTRY(SMONTHNAME12
),
323 LOCALE_ENTRY(SMONTHNAME13
),
324 LOCALE_ENTRY(SABBREVMONTHNAME1
),
325 LOCALE_ENTRY(SABBREVMONTHNAME2
),
326 LOCALE_ENTRY(SABBREVMONTHNAME3
),
327 LOCALE_ENTRY(SABBREVMONTHNAME4
),
328 LOCALE_ENTRY(SABBREVMONTHNAME5
),
329 LOCALE_ENTRY(SABBREVMONTHNAME6
),
330 LOCALE_ENTRY(SABBREVMONTHNAME7
),
331 LOCALE_ENTRY(SABBREVMONTHNAME8
),
332 LOCALE_ENTRY(SABBREVMONTHNAME9
),
333 LOCALE_ENTRY(SABBREVMONTHNAME10
),
334 LOCALE_ENTRY(SABBREVMONTHNAME11
),
335 LOCALE_ENTRY(SABBREVMONTHNAME12
),
336 LOCALE_ENTRY(SABBREVMONTHNAME13
),
337 LOCALE_ENTRY(SPOSITIVESIGN
),
338 LOCALE_ENTRY(SNEGATIVESIGN
),
339 LOCALE_ENTRY(IPOSSIGNPOSN
),
340 LOCALE_ENTRY(INEGSIGNPOSN
),
341 LOCALE_ENTRY(IPOSSYMPRECEDES
),
342 LOCALE_ENTRY(IPOSSEPBYSPACE
),
343 LOCALE_ENTRY(INEGSYMPRECEDES
),
344 LOCALE_ENTRY(INEGSEPBYSPACE
),
345 LOCALE_ENTRY(FONTSIGNATURE
),
346 LOCALE_ENTRY(SISO639LANGNAME
),
347 LOCALE_ENTRY(SISO3166CTRYNAME
),
351 const struct map_lcid2str
{
353 const char *langname
;
355 {0x0401,"Arabic (Saudi Arabia)"},
356 {0x0801,"Arabic (Iraq)"},
357 {0x0c01,"Arabic (Egypt)"},
358 {0x1001,"Arabic (Libya)"},
359 {0x1401,"Arabic (Algeria)"},
360 {0x1801,"Arabic (Morocco)"},
361 {0x1c01,"Arabic (Tunisia)"},
362 {0x2001,"Arabic (Oman)"},
363 {0x2401,"Arabic (Yemen)"},
364 {0x2801,"Arabic (Syria)"},
365 {0x2c01,"Arabic (Jordan)"},
366 {0x3001,"Arabic (Lebanon)"},
367 {0x3401,"Arabic (Kuwait)"},
368 {0x3801,"Arabic (United Arab Emirates)"},
369 {0x3c01,"Arabic (Bahrain)"},
370 {0x4001,"Arabic (Qatar)"},
371 {0x0402,"Bulgarian"},
373 {0x0404,"Chinese (Taiwan)"},
374 {0x0804,"Chinese (People's Republic of China)"},
375 {0x0c04,"Chinese (Hong Kong)"},
376 {0x1004,"Chinese (Singapore)"},
377 {0x1404,"Chinese (Macau)"},
380 {0x0407,"German (Germany)"},
381 {0x0807,"German (Switzerland)"},
382 {0x0c07,"German (Austria)"},
383 {0x1007,"German (Luxembourg)"},
384 {0x1407,"German (Liechtenstein)"},
386 {0x0409,"English (United States)"},
387 {0x0809,"English (United Kingdom)"},
388 {0x0c09,"English (Australia)"},
389 {0x1009,"English (Canada)"},
390 {0x1409,"English (New Zealand)"},
391 {0x1809,"English (Ireland)"},
392 {0x1c09,"English (South Africa)"},
393 {0x2009,"English (Jamaica)"},
394 {0x2409,"English (Caribbean)"},
395 {0x2809,"English (Belize)"},
396 {0x2c09,"English (Trinidad)"},
397 {0x3009,"English (Zimbabwe)"},
398 {0x3409,"English (Philippines)"},
399 {0x040a,"Spanish (Spain, traditional sorting)"},
400 {0x080a,"Spanish (Mexico)"},
401 {0x0c0a,"Spanish (Spain, international sorting)"},
402 {0x100a,"Spanish (Guatemala)"},
403 {0x140a,"Spanish (Costa Rica)"},
404 {0x180a,"Spanish (Panama)"},
405 {0x1c0a,"Spanish (Dominican Republic)"},
406 {0x200a,"Spanish (Venezuela)"},
407 {0x240a,"Spanish (Colombia)"},
408 {0x280a,"Spanish (Peru)"},
409 {0x2c0a,"Spanish (Argentina)"},
410 {0x300a,"Spanish (Ecuador)"},
411 {0x340a,"Spanish (Chile)"},
412 {0x380a,"Spanish (Uruguay)"},
413 {0x3c0a,"Spanish (Paraguay)"},
414 {0x400a,"Spanish (Bolivia)"},
415 {0x440a,"Spanish (El Salvador)"},
416 {0x480a,"Spanish (Honduras)"},
417 {0x4c0a,"Spanish (Nicaragua)"},
418 {0x500a,"Spanish (Puerto Rico)"},
420 {0x040c,"French (France)"},
421 {0x080c,"French (Belgium)"},
422 {0x0c0c,"French (Canada)"},
423 {0x100c,"French (Switzerland)"},
424 {0x140c,"French (Luxembourg)"},
425 {0x180c,"French (Monaco)"},
427 {0x040e,"Hungarian"},
428 {0x040f,"Icelandic"},
429 {0x0410,"Italian (Italy)"},
430 {0x0810,"Italian (Switzerland)"},
432 {0x0412,"Korean (Wansung)"},
433 {0x0812,"Korean (Johab)"},
434 {0x0413,"Dutch (Netherlands)"},
435 {0x0813,"Dutch (Belgium)"},
436 {0x0414,"Norwegian (Bokmal)"},
437 {0x0814,"Norwegian (Nynorsk)"},
439 {0x0416,"Portuguese (Brazil)"},
440 {0x0816,"Portuguese (Portugal)"},
441 {0x0417,"Rhaeto Romanic"},
443 {0x0818,"Moldavian"},
444 {0x0419,"Russian (Russia)"},
445 {0x0819,"Russian (Moldavia)"},
447 {0x081a,"Serbian (latin)"},
448 {0x0c1a,"Serbian (cyrillic)"},
451 {0x041d,"Swedish (Sweden)"},
452 {0x081d,"Swedish (Finland)"},
456 {0x0421,"Indonesian"},
457 {0x0422,"Ukrainian"},
458 {0x0423,"Belarusian"},
462 {0x0427,"Lithuanian (modern)"},
463 {0x0827,"Lithuanian (classic)"},
466 {0x042a,"Vietnamese"},
468 {0x042c,"Azeri (latin)"},
469 {0x082c,"Azeri (cyrillic)"},
472 {0x042f,"Macedonian"},
479 {0x0436,"Afrikaans"},
485 {0x043c,"Irish gaelic"},
486 {0x083c,"Scottish gaelic"},
487 {0x043e,"Malay (Malaysia)"},
488 {0x083e,"Malay (Brunei Darussalam)"},
491 {0x0443,"Uzbek (latin)"},
492 {0x0843,"Uzbek (cyrillic)"},
501 {0x044c,"Malayalam"},
506 {0x048f,"Esperanto"}, /* Non official */
510 {0x0402,"Bulgarisch"},
511 {0x0403,"Katalanisch"},
512 {0x0404,"Traditionales Chinesisch"},
513 {0x0405,"Tschecisch"},
516 {0x0408,"Griechisch"},
517 {0x0409,"Amerikanisches Englisch"},
518 {0x040A,"Kastilisches Spanisch"},
520 {0x040C,"Franzvsisch"},
521 {0x040D,"Hebrdisch"},
522 {0x040E,"Ungarisch"},
523 {0x040F,"Isldndisch"},
524 {0x0410,"Italienisch"},
525 {0x0411,"Japanisch"},
526 {0x0412,"Koreanisch"},
527 {0x0413,"Niederldndisch"},
528 {0x0414,"Norwegisch-Bokmal"},
530 {0x0416,"Brasilianisches Portugiesisch"},
531 {0x0417,"Rdtoromanisch"},
532 {0x0418,"Rumdnisch"},
534 {0x041A,"Kroatoserbisch (lateinisch)"},
535 {0x041B,"Slowenisch"},
536 {0x041C,"Albanisch"},
537 {0x041D,"Schwedisch"},
542 {0x0804,"Vereinfachtes Chinesisch"},
543 {0x0807,"Schweizerdeutsch"},
544 {0x0809,"Britisches Englisch"},
545 {0x080A,"Mexikanisches Spanisch"},
546 {0x080C,"Belgisches Franzvsisch"},
547 {0x0810,"Schweizerisches Italienisch"},
548 {0x0813,"Belgisches Niederldndisch"},
549 {0x0814,"Norgwegisch-Nynorsk"},
550 {0x0816,"Portugiesisch"},
551 {0x081A,"Serbokratisch (kyrillisch)"},
552 {0x0C1C,"Kanadisches Franzvsisch"},
553 {0x100C,"Schweizerisches Franzvsisch"},
554 {0x0000,"Unbekannt"},
557 /***********************************************************************
558 * GetUserDefaultLCID (OLE2NLS.1)
560 LCID WINAPI
GetUserDefaultLCID()
562 return MAKELCID( GetUserDefaultLangID() , SORT_DEFAULT
);
565 /***********************************************************************
566 * GetSystemDefaultLCID (OLE2NLS.2)
568 LCID WINAPI
GetSystemDefaultLCID()
570 return GetUserDefaultLCID();
573 /***********************************************************************
574 * GetUserDefaultLangID (OLE2NLS.3)
576 LANGID WINAPI
GetUserDefaultLangID()
578 /* caching result, if defined from environment, which should (?) not change during a WINE session */
579 static LANGID userLCID
= 0;
580 if (Options
.language
) {
581 return Languages
[Options
.language
].langid
;
586 char *lang
,*country
,*charset
,*dialect
,*next
;
589 buf
=getenv("LANGUAGE");
590 if (!buf
) buf
=getenv("LANG");
591 if (!buf
) buf
=getenv("LC_ALL");
592 if (!buf
) buf
=getenv("LC_MESSAGES");
593 if (!buf
) buf
=getenv("LC_CTYPE");
594 if (!buf
) return userLCID
= MAKELANGID( LANG_ENGLISH
, SUBLANG_DEFAULT
);
596 if (!strcmp(buf
,"POSIX") || !strcmp(buf
,"C")) {
597 return MAKELANGID( LANG_ENGLISH
, SUBLANG_DEFAULT
);
603 next
=strchr(lang
,':'); if (next
) *next
++='\0';
604 dialect
=strchr(lang
,'@'); if (dialect
) *dialect
++='\0';
605 charset
=strchr(lang
,'.'); if (charset
) *charset
++='\0';
606 country
=strchr(lang
,'_'); if (country
) *country
++='\0';
608 ret
=MAIN_GetLanguageID(lang
, country
, charset
, dialect
);
612 } while (lang
&& !ret
);
614 /* FIXME : are strings returned by getenv() to be free()'ed ? */
615 userLCID
= (LANGID
)ret
;
620 /***********************************************************************
621 * GetSystemDefaultLangID (OLE2NLS.4)
623 LANGID WINAPI
GetSystemDefaultLangID()
625 return GetUserDefaultLangID();
628 /******************************************************************************
629 * GetLocaleInfo16 [OLE2NLS.5]
630 * Is the last parameter really WORD for Win16?
632 INT16 WINAPI
GetLocaleInfo16(LCID lcid
,LCTYPE LCType
,LPSTR buf
,INT16 len
)
634 return GetLocaleInfo32A(lcid
,LCType
,buf
,len
);
637 /******************************************************************************
638 * GetLocaleInfo32A [KERNEL32.342]
641 * LANG_NEUTRAL is equal to LOCALE_SYSTEM_DEFAULT
643 INT32 WINAPI
GetLocaleInfo32A(LCID lcid
,LCTYPE LCType
,LPSTR buf
,INT32 len
)
649 TRACE(ole
,"(lcid=0x%lx,lctype=0x%lx,%p,%x)\n",lcid
,LCType
,buf
,len
);
651 if (len
&& (! buf
) ) {
652 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
656 if (lcid
==0 || lcid
== LANG_SYSTEM_DEFAULT
|| (LCType
& LOCALE_NOUSEROVERRIDE
) ) /* 0x00, 0x400 */
658 lcid
= GetSystemDefaultLCID();
660 else if (lcid
== LANG_USER_DEFAULT
) /*0x800*/
662 lcid
= GetUserDefaultLCID();
664 LCType
&= ~(LOCALE_NOUSEROVERRIDE
|LOCALE_USE_CP_ACP
);
666 /* As an option, we could obtain the value from win.ini.
667 This would not match the Wine compile-time option.
668 Also, not all identifiers are available from win.ini */
670 /* If we are through all of this, retLen should not be zero anymore.
671 If it is, the value is not supported */
673 while (locale_name2id
[i
].name
!=NULL
) {
674 if (LCType
== locale_name2id
[i
].id
) {
675 retString
= locale_name2id
[i
].name
;
681 FIXME(ole
,"Unkown LC type %lX\n",LCType
);
686 for (i
=0;(i
<3 && !found
);i
++) {
689 for (j
=0;j
<sizeof(langlocales
)/sizeof(langlocales
[0]);j
++) {
690 if (langlocales
[j
].lang
== lang
) {
693 for (k
=0;k
<sizeof(langlocales
[j
].locvars
)/sizeof(langlocales
[j
].locvars
[0]) && (langlocales
[j
].locvars
[k
].type
);k
++) {
694 if (langlocales
[j
].locvars
[k
].type
== LCType
) {
696 retString
= langlocales
[j
].locvars
[k
].val
;
704 /* language not found, try without a sublanguage*/
705 if (i
==1) lang
=MAKELANGID( PRIMARYLANGID(lang
), SUBLANG_DEFAULT
);
706 /* mask the LC Value */
707 if (i
==2) LCType
&= 0xfff;
711 ERR(ole
,"'%s' not supported for your language (%04X).\n",
712 retString
,(WORD
)lcid
);
713 SetLastError(ERROR_INVALID_PARAMETER
);
716 /* if len=0 return only the length, don't touch the buffer*/
718 lstrcpyn32A(buf
,retString
,len
);
720 return strlen(retString
)+1;
723 /******************************************************************************
724 * GetLocaleInfo32W [KERNEL32.343]
727 INT32 WINAPI
GetLocaleInfo32W(LCID lcid
,LCTYPE LCType
,LPWSTR wbuf
,INT32 len
)
731 if (len
&& (! wbuf
) )
732 { SetLastError(ERROR_INSUFFICIENT_BUFFER
);
736 abuf
= (LPSTR
)HeapAlloc(GetProcessHeap(),0,len
);
737 wlen
= 2 * GetLocaleInfo32A(lcid
, LCType
, abuf
, len
);
739 if (wlen
&& len
) /* if len=0 return only the length*/
740 lstrcpynAtoW(wbuf
,abuf
,len
/2);
742 HeapFree(GetProcessHeap(),0,abuf
);
746 /******************************************************************************
747 * SetLocaleInfoA [KERNEL32.656]
749 BOOL16 WINAPI
SetLocaleInfoA(DWORD lcid
, DWORD lctype
, LPCSTR data
)
751 FIXME(ole
,"(%ld,%ld,%s): stub\n",lcid
,lctype
,data
);
755 /******************************************************************************
756 * IsValidLocale [KERNEL32.489]
758 BOOL32 WINAPI
IsValidLocale(LCID lcid
,DWORD flags
)
760 /* we support ANY language. Well, at least say that...*/
764 /******************************************************************************
765 * EnumSystemLocales32W [KERNEL32.209]
767 BOOL32 WINAPI
EnumSystemLocales32W( LOCALE_ENUMPROC32W lpfnLocaleEnum
,
775 TRACE(win32
,"(%p,%08lx)\n",lpfnLocaleEnum
,flags
);
776 /* see if we can reuse the Win95 registry entries.... */
777 if (ERROR_SUCCESS
==RegOpenKey32A(HKEY_LOCAL_MACHINE
,"System\\CurrentControlSet\\control\\Nls\\Locale\\",&xhkey
)) {
780 if (ERROR_SUCCESS
!=RegEnumKey32W(xhkey
,i
,buffer
,sizeof(buffer
)))
782 if (!lpfnLocaleEnum(buffer
))
791 while (languages
[i
].langid
!=0)
796 sprintf(xbuffer
,"%08lx",(DWORD
)languages
[i
].langid
);
798 cp
= HEAP_strdupAtoW( GetProcessHeap(), 0, xbuffer
);
799 ret
= lpfnLocaleEnum(cp
);
800 HeapFree( GetProcessHeap(), 0, cp
);
807 /******************************************************************************
808 * EnumSystemLocales32A [KERNEL32.208]
810 BOOL32 WINAPI
EnumSystemLocales32A(LOCALE_ENUMPROC32A lpfnLocaleEnum
,
817 TRACE(win32
,"(%p,%08lx)\n",
820 if (ERROR_SUCCESS
==RegOpenKey32A(HKEY_LOCAL_MACHINE
,"System\\CurrentControlSet\\control\\Nls\\Locale\\",&xhkey
)) {
823 if (ERROR_SUCCESS
!=RegEnumKey32A(xhkey
,i
,buffer
,sizeof(buffer
)))
825 if (!lpfnLocaleEnum(buffer
))
833 while (languages
[i
].langid
!=0) {
834 sprintf(buffer
,"%08lx",(DWORD
)languages
[i
].langid
);
835 if (!lpfnLocaleEnum(buffer
))
842 static const unsigned char CT_CType2_LUT
[] = {
843 C2_NOTAPPLICABLE
, /* - 0 */
844 C2_NOTAPPLICABLE
, /* - 1 */
845 C2_NOTAPPLICABLE
, /* - 2 */
846 C2_NOTAPPLICABLE
, /* - 3 */
847 C2_NOTAPPLICABLE
, /* - 4 */
848 C2_NOTAPPLICABLE
, /* - 5 */
849 C2_NOTAPPLICABLE
, /* - 6 */
850 C2_NOTAPPLICABLE
, /* - 7 */
851 C2_NOTAPPLICABLE
, /* - 8 */
852 C2_SEGMENTSEPARATOR
, /* - 9 */
853 C2_NOTAPPLICABLE
, /* - 10 */
854 C2_NOTAPPLICABLE
, /* - 11 */
855 C2_NOTAPPLICABLE
, /* - 12 */
856 C2_NOTAPPLICABLE
, /* - 13 */
857 C2_NOTAPPLICABLE
, /* - 14 */
858 C2_NOTAPPLICABLE
, /* - 15 */
859 C2_NOTAPPLICABLE
, /* - 16 */
860 C2_NOTAPPLICABLE
, /* - 17 */
861 C2_NOTAPPLICABLE
, /* - 18 */
862 C2_NOTAPPLICABLE
, /* - 19 */
863 C2_NOTAPPLICABLE
, /* - 20 */
864 C2_NOTAPPLICABLE
, /* - 21 */
865 C2_NOTAPPLICABLE
, /* - 22 */
866 C2_NOTAPPLICABLE
, /* - 23 */
867 C2_NOTAPPLICABLE
, /* - 24 */
868 C2_NOTAPPLICABLE
, /* - 25 */
869 C2_NOTAPPLICABLE
, /* - 26 */
870 C2_NOTAPPLICABLE
, /* - 27 */
871 C2_NOTAPPLICABLE
, /* - 28 */
872 C2_NOTAPPLICABLE
, /* - 29 */
873 C2_NOTAPPLICABLE
, /* - 30 */
874 C2_NOTAPPLICABLE
, /* - 31 */
875 C2_WHITESPACE
, /* - 32 */
876 C2_OTHERNEUTRAL
, /* ! - 33 */
877 C2_OTHERNEUTRAL
, /* " - 34 */ /* " */
878 C2_EUROPETERMINATOR
, /* # - 35 */
879 C2_EUROPETERMINATOR
, /* $ - 36 */
880 C2_EUROPETERMINATOR
, /* % - 37 */
881 C2_LEFTTORIGHT
, /* & - 38 */
882 C2_OTHERNEUTRAL
, /* ' - 39 */
883 C2_OTHERNEUTRAL
, /* ( - 40 */
884 C2_OTHERNEUTRAL
, /* ) - 41 */
885 C2_OTHERNEUTRAL
, /* * - 42 */
886 C2_EUROPETERMINATOR
, /* + - 43 */
887 C2_COMMONSEPARATOR
, /* , - 44 */
888 C2_EUROPETERMINATOR
, /* - - 45 */
889 C2_EUROPESEPARATOR
, /* . - 46 */
890 C2_EUROPESEPARATOR
, /* / - 47 */
891 C2_EUROPENUMBER
, /* 0 - 48 */
892 C2_EUROPENUMBER
, /* 1 - 49 */
893 C2_EUROPENUMBER
, /* 2 - 50 */
894 C2_EUROPENUMBER
, /* 3 - 51 */
895 C2_EUROPENUMBER
, /* 4 - 52 */
896 C2_EUROPENUMBER
, /* 5 - 53 */
897 C2_EUROPENUMBER
, /* 6 - 54 */
898 C2_EUROPENUMBER
, /* 7 - 55 */
899 C2_EUROPENUMBER
, /* 8 - 56 */
900 C2_EUROPENUMBER
, /* 9 - 57 */
901 C2_COMMONSEPARATOR
, /* : - 58 */
902 C2_OTHERNEUTRAL
, /* ; - 59 */
903 C2_OTHERNEUTRAL
, /* < - 60 */
904 C2_OTHERNEUTRAL
, /* = - 61 */
905 C2_OTHERNEUTRAL
, /* > - 62 */
906 C2_OTHERNEUTRAL
, /* ? - 63 */
907 C2_LEFTTORIGHT
, /* @ - 64 */
908 C2_LEFTTORIGHT
, /* A - 65 */
909 C2_LEFTTORIGHT
, /* B - 66 */
910 C2_LEFTTORIGHT
, /* C - 67 */
911 C2_LEFTTORIGHT
, /* D - 68 */
912 C2_LEFTTORIGHT
, /* E - 69 */
913 C2_LEFTTORIGHT
, /* F - 70 */
914 C2_LEFTTORIGHT
, /* G - 71 */
915 C2_LEFTTORIGHT
, /* H - 72 */
916 C2_LEFTTORIGHT
, /* I - 73 */
917 C2_LEFTTORIGHT
, /* J - 74 */
918 C2_LEFTTORIGHT
, /* K - 75 */
919 C2_LEFTTORIGHT
, /* L - 76 */
920 C2_LEFTTORIGHT
, /* M - 77 */
921 C2_LEFTTORIGHT
, /* N - 78 */
922 C2_LEFTTORIGHT
, /* O - 79 */
923 C2_LEFTTORIGHT
, /* P - 80 */
924 C2_LEFTTORIGHT
, /* Q - 81 */
925 C2_LEFTTORIGHT
, /* R - 82 */
926 C2_LEFTTORIGHT
, /* S - 83 */
927 C2_LEFTTORIGHT
, /* T - 84 */
928 C2_LEFTTORIGHT
, /* U - 85 */
929 C2_LEFTTORIGHT
, /* V - 86 */
930 C2_LEFTTORIGHT
, /* W - 87 */
931 C2_LEFTTORIGHT
, /* X - 88 */
932 C2_LEFTTORIGHT
, /* Y - 89 */
933 C2_LEFTTORIGHT
, /* Z - 90 */
934 C2_OTHERNEUTRAL
, /* [ - 91 */
935 C2_OTHERNEUTRAL
, /* \ - 92 */
936 C2_OTHERNEUTRAL
, /* ] - 93 */
937 C2_OTHERNEUTRAL
, /* ^ - 94 */
938 C2_OTHERNEUTRAL
, /* _ - 95 */
939 C2_OTHERNEUTRAL
, /* ` - 96 */
940 C2_LEFTTORIGHT
, /* a - 97 */
941 C2_LEFTTORIGHT
, /* b - 98 */
942 C2_LEFTTORIGHT
, /* c - 99 */
943 C2_LEFTTORIGHT
, /* d - 100 */
944 C2_LEFTTORIGHT
, /* e - 101 */
945 C2_LEFTTORIGHT
, /* f - 102 */
946 C2_LEFTTORIGHT
, /* g - 103 */
947 C2_LEFTTORIGHT
, /* h - 104 */
948 C2_LEFTTORIGHT
, /* i - 105 */
949 C2_LEFTTORIGHT
, /* j - 106 */
950 C2_LEFTTORIGHT
, /* k - 107 */
951 C2_LEFTTORIGHT
, /* l - 108 */
952 C2_LEFTTORIGHT
, /* m - 109 */
953 C2_LEFTTORIGHT
, /* n - 110 */
954 C2_LEFTTORIGHT
, /* o - 111 */
955 C2_LEFTTORIGHT
, /* p - 112 */
956 C2_LEFTTORIGHT
, /* q - 113 */
957 C2_LEFTTORIGHT
, /* r - 114 */
958 C2_LEFTTORIGHT
, /* s - 115 */
959 C2_LEFTTORIGHT
, /* t - 116 */
960 C2_LEFTTORIGHT
, /* u - 117 */
961 C2_LEFTTORIGHT
, /* v - 118 */
962 C2_LEFTTORIGHT
, /* w - 119 */
963 C2_LEFTTORIGHT
, /* x - 120 */
964 C2_LEFTTORIGHT
, /* y - 121 */
965 C2_LEFTTORIGHT
, /* z - 122 */
966 C2_OTHERNEUTRAL
, /* { - 123 */
967 C2_OTHERNEUTRAL
, /* | - 124 */
968 C2_OTHERNEUTRAL
, /* } - 125 */
969 C2_OTHERNEUTRAL
, /* ~ - 126 */
970 C2_NOTAPPLICABLE
, /* \x7f - 127 */
971 C2_NOTAPPLICABLE
, /* € - 128 */
972 C2_NOTAPPLICABLE
, /* � - 129 */
973 C2_OTHERNEUTRAL
, /* ‚ - 130 */
974 C2_LEFTTORIGHT
, /* ƒ - 131 */
975 C2_OTHERNEUTRAL
, /* „ - 132 */
976 C2_OTHERNEUTRAL
, /* … - 133 */
977 C2_OTHERNEUTRAL
, /* † - 134 */
978 C2_OTHERNEUTRAL
, /* ‡ - 135 */
979 C2_LEFTTORIGHT
, /* ˆ - 136 */
980 C2_EUROPETERMINATOR
, /* ‰ - 137 */
981 C2_LEFTTORIGHT
, /* Š - 138 */
982 C2_OTHERNEUTRAL
, /* ‹ - 139 */
983 C2_LEFTTORIGHT
, /* Œ - 140 */
984 C2_NOTAPPLICABLE
, /* � - 141 */
985 C2_NOTAPPLICABLE
, /* Ž - 142 */
986 C2_NOTAPPLICABLE
, /* � - 143 */
987 C2_NOTAPPLICABLE
, /* � - 144 */
988 C2_OTHERNEUTRAL
, /* ‘ - 145 */
989 C2_OTHERNEUTRAL
, /* ’ - 146 */
990 C2_OTHERNEUTRAL
, /* “ - 147 */
991 C2_OTHERNEUTRAL
, /* ” - 148 */
992 C2_OTHERNEUTRAL
, /* • - 149 */
993 C2_OTHERNEUTRAL
, /* – - 150 */
994 C2_OTHERNEUTRAL
, /* — - 151 */
995 C2_LEFTTORIGHT
, /* ˜ - 152 */
996 C2_OTHERNEUTRAL
, /* ™ - 153 */
997 C2_LEFTTORIGHT
, /* š - 154 */
998 C2_OTHERNEUTRAL
, /* › - 155 */
999 C2_LEFTTORIGHT
, /* œ - 156 */
1000 C2_NOTAPPLICABLE
, /* � - 157 */
1001 C2_NOTAPPLICABLE
, /* ž - 158 */
1002 C2_LEFTTORIGHT
, /* Ÿ - 159 */
1003 C2_WHITESPACE
, /* - 160 */
1004 C2_OTHERNEUTRAL
, /* ¡ - 161 */
1005 C2_EUROPETERMINATOR
, /* ¢ - 162 */
1006 C2_EUROPETERMINATOR
, /* £ - 163 */
1007 C2_EUROPETERMINATOR
, /* ¤ - 164 */
1008 C2_EUROPETERMINATOR
, /* ¥ - 165 */
1009 C2_OTHERNEUTRAL
, /* ¦ - 166 */
1010 C2_OTHERNEUTRAL
, /* § - 167 */
1011 C2_OTHERNEUTRAL
, /* ¨ - 168 */
1012 C2_OTHERNEUTRAL
, /* © - 169 */
1013 C2_OTHERNEUTRAL
, /* ª - 170 */
1014 C2_OTHERNEUTRAL
, /* « - 171 */
1015 C2_OTHERNEUTRAL
, /* ¬ - 172 */
1016 C2_OTHERNEUTRAL
, /* - 173 */
1017 C2_OTHERNEUTRAL
, /* ® - 174 */
1018 C2_OTHERNEUTRAL
, /* ¯ - 175 */
1019 C2_EUROPETERMINATOR
, /* ° - 176 */
1020 C2_EUROPETERMINATOR
, /* ± - 177 */
1021 C2_EUROPENUMBER
, /* ² - 178 */
1022 C2_EUROPENUMBER
, /* ³ - 179 */
1023 C2_OTHERNEUTRAL
, /* ´ - 180 */
1024 C2_OTHERNEUTRAL
, /* µ - 181 */
1025 C2_OTHERNEUTRAL
, /* ¶ - 182 */
1026 C2_OTHERNEUTRAL
, /* · - 183 */
1027 C2_OTHERNEUTRAL
, /* ¸ - 184 */
1028 C2_EUROPENUMBER
, /* ¹ - 185 */
1029 C2_OTHERNEUTRAL
, /* º - 186 */
1030 C2_OTHERNEUTRAL
, /* » - 187 */
1031 C2_OTHERNEUTRAL
, /* ¼ - 188 */
1032 C2_OTHERNEUTRAL
, /* ½ - 189 */
1033 C2_OTHERNEUTRAL
, /* ¾ - 190 */
1034 C2_OTHERNEUTRAL
, /* ¿ - 191 */
1035 C2_LEFTTORIGHT
, /* À - 192 */
1036 C2_LEFTTORIGHT
, /* Á - 193 */
1037 C2_LEFTTORIGHT
, /* Â - 194 */
1038 C2_LEFTTORIGHT
, /* Ã - 195 */
1039 C2_LEFTTORIGHT
, /* Ä - 196 */
1040 C2_LEFTTORIGHT
, /* Å - 197 */
1041 C2_LEFTTORIGHT
, /* Æ - 198 */
1042 C2_LEFTTORIGHT
, /* Ç - 199 */
1043 C2_LEFTTORIGHT
, /* È - 200 */
1044 C2_LEFTTORIGHT
, /* É - 201 */
1045 C2_LEFTTORIGHT
, /* Ê - 202 */
1046 C2_LEFTTORIGHT
, /* Ë - 203 */
1047 C2_LEFTTORIGHT
, /* Ì - 204 */
1048 C2_LEFTTORIGHT
, /* Í - 205 */
1049 C2_LEFTTORIGHT
, /* Î - 206 */
1050 C2_LEFTTORIGHT
, /* Ï - 207 */
1051 C2_LEFTTORIGHT
, /* Ð - 208 */
1052 C2_LEFTTORIGHT
, /* Ñ - 209 */
1053 C2_LEFTTORIGHT
, /* Ò - 210 */
1054 C2_LEFTTORIGHT
, /* Ó - 211 */
1055 C2_LEFTTORIGHT
, /* Ô - 212 */
1056 C2_LEFTTORIGHT
, /* Õ - 213 */
1057 C2_LEFTTORIGHT
, /* Ö - 214 */
1058 C2_OTHERNEUTRAL
, /* × - 215 */
1059 C2_LEFTTORIGHT
, /* Ø - 216 */
1060 C2_LEFTTORIGHT
, /* Ù - 217 */
1061 C2_LEFTTORIGHT
, /* Ú - 218 */
1062 C2_LEFTTORIGHT
, /* Û - 219 */
1063 C2_LEFTTORIGHT
, /* Ü - 220 */
1064 C2_LEFTTORIGHT
, /* Ý - 221 */
1065 C2_LEFTTORIGHT
, /* Þ - 222 */
1066 C2_LEFTTORIGHT
, /* ß - 223 */
1067 C2_LEFTTORIGHT
, /* à - 224 */
1068 C2_LEFTTORIGHT
, /* á - 225 */
1069 C2_LEFTTORIGHT
, /* â - 226 */
1070 C2_LEFTTORIGHT
, /* ã - 227 */
1071 C2_LEFTTORIGHT
, /* ä - 228 */
1072 C2_LEFTTORIGHT
, /* å - 229 */
1073 C2_LEFTTORIGHT
, /* æ - 230 */
1074 C2_LEFTTORIGHT
, /* ç - 231 */
1075 C2_LEFTTORIGHT
, /* è - 232 */
1076 C2_LEFTTORIGHT
, /* é - 233 */
1077 C2_LEFTTORIGHT
, /* ê - 234 */
1078 C2_LEFTTORIGHT
, /* ë - 235 */
1079 C2_LEFTTORIGHT
, /* ì - 236 */
1080 C2_LEFTTORIGHT
, /* í - 237 */
1081 C2_LEFTTORIGHT
, /* î - 238 */
1082 C2_LEFTTORIGHT
, /* ï - 239 */
1083 C2_LEFTTORIGHT
, /* ð - 240 */
1084 C2_LEFTTORIGHT
, /* ñ - 241 */
1085 C2_LEFTTORIGHT
, /* ò - 242 */
1086 C2_LEFTTORIGHT
, /* ó - 243 */
1087 C2_LEFTTORIGHT
, /* ô - 244 */
1088 C2_LEFTTORIGHT
, /* õ - 245 */
1089 C2_LEFTTORIGHT
, /* ö - 246 */
1090 C2_OTHERNEUTRAL
, /* ÷ - 247 */
1091 C2_LEFTTORIGHT
, /* ø - 248 */
1092 C2_LEFTTORIGHT
, /* ù - 249 */
1093 C2_LEFTTORIGHT
, /* ú - 250 */
1094 C2_LEFTTORIGHT
, /* û - 251 */
1095 C2_LEFTTORIGHT
, /* ü - 252 */
1096 C2_LEFTTORIGHT
, /* ý - 253 */
1097 C2_LEFTTORIGHT
, /* þ - 254 */
1098 C2_LEFTTORIGHT
/* ÿ - 255 */
1101 static const WORD CT_CType3_LUT
[] = {
1135 0x0048, /* ! - 33 */
1136 0x0448, /* " - 34 */ /* " */
1137 0x0048, /* # - 35 */
1138 0x0448, /* $ - 36 */
1139 0x0048, /* % - 37 */
1140 0x0048, /* & - 38 */
1141 0x0440, /* ' - 39 */
1142 0x0048, /* ( - 40 */
1143 0x0048, /* ) - 41 */
1144 0x0048, /* * - 42 */
1145 0x0048, /* + - 43 */
1146 0x0048, /* , - 44 */
1147 0x0440, /* - - 45 */
1148 0x0048, /* . - 46 */
1149 0x0448, /* / - 47 */
1150 0x0040, /* 0 - 48 */
1151 0x0040, /* 1 - 49 */
1152 0x0040, /* 2 - 50 */
1153 0x0040, /* 3 - 51 */
1154 0x0040, /* 4 - 52 */
1155 0x0040, /* 5 - 53 */
1156 0x0040, /* 6 - 54 */
1157 0x0040, /* 7 - 55 */
1158 0x0040, /* 8 - 56 */
1159 0x0040, /* 9 - 57 */
1160 0x0048, /* : - 58 */
1161 0x0048, /* ; - 59 */
1162 0x0048, /* < - 60 */
1163 0x0448, /* = - 61 */
1164 0x0048, /* > - 62 */
1165 0x0048, /* ? - 63 */
1166 0x0448, /* @ - 64 */
1167 0x8040, /* A - 65 */
1168 0x8040, /* B - 66 */
1169 0x8040, /* C - 67 */
1170 0x8040, /* D - 68 */
1171 0x8040, /* E - 69 */
1172 0x8040, /* F - 70 */
1173 0x8040, /* G - 71 */
1174 0x8040, /* H - 72 */
1175 0x8040, /* I - 73 */
1176 0x8040, /* J - 74 */
1177 0x8040, /* K - 75 */
1178 0x8040, /* L - 76 */
1179 0x8040, /* M - 77 */
1180 0x8040, /* N - 78 */
1181 0x8040, /* O - 79 */
1182 0x8040, /* P - 80 */
1183 0x8040, /* Q - 81 */
1184 0x8040, /* R - 82 */
1185 0x8040, /* S - 83 */
1186 0x8040, /* T - 84 */
1187 0x8040, /* U - 85 */
1188 0x8040, /* V - 86 */
1189 0x8040, /* W - 87 */
1190 0x8040, /* X - 88 */
1191 0x8040, /* Y - 89 */
1192 0x8040, /* Z - 90 */
1193 0x0048, /* [ - 91 */
1194 0x0448, /* \ - 92 */
1195 0x0048, /* ] - 93 */
1196 0x0448, /* ^ - 94 */
1197 0x0448, /* _ - 95 */
1198 0x0448, /* ` - 96 */
1199 0x8040, /* a - 97 */
1200 0x8040, /* b - 98 */
1201 0x8040, /* c - 99 */
1202 0x8040, /* d - 100 */
1203 0x8040, /* e - 101 */
1204 0x8040, /* f - 102 */
1205 0x8040, /* g - 103 */
1206 0x8040, /* h - 104 */
1207 0x8040, /* i - 105 */
1208 0x8040, /* j - 106 */
1209 0x8040, /* k - 107 */
1210 0x8040, /* l - 108 */
1211 0x8040, /* m - 109 */
1212 0x8040, /* n - 110 */
1213 0x8040, /* o - 111 */
1214 0x8040, /* p - 112 */
1215 0x8040, /* q - 113 */
1216 0x8040, /* r - 114 */
1217 0x8040, /* s - 115 */
1218 0x8040, /* t - 116 */
1219 0x8040, /* u - 117 */
1220 0x8040, /* v - 118 */
1221 0x8040, /* w - 119 */
1222 0x8040, /* x - 120 */
1223 0x8040, /* y - 121 */
1224 0x8040, /* z - 122 */
1225 0x0048, /* { - 123 */
1226 0x0048, /* | - 124 */
1227 0x0048, /* } - 125 */
1228 0x0448, /* ~ - 126 */
1229 0x0000, /* \x7f - 127 */
1230 0x0000, /* € - 128 */
1231 0x0000, /* � - 129 */
1232 0x0008, /* ‚ - 130 */
1233 0x8000, /* ƒ - 131 */
1234 0x0008, /* „ - 132 */
1235 0x0008, /* … - 133 */
1236 0x0008, /* † - 134 */
1237 0x0008, /* ‡ - 135 */
1238 0x0001, /* ˆ - 136 */
1239 0x0008, /* ‰ - 137 */
1240 0x8003, /* Š - 138 */
1241 0x0008, /* ‹ - 139 */
1242 0x8000, /* Œ - 140 */
1243 0x0000, /* � - 141 */
1244 0x0000, /* Ž - 142 */
1245 0x0000, /* � - 143 */
1246 0x0000, /* � - 144 */
1247 0x0088, /* ‘ - 145 */
1248 0x0088, /* ’ - 146 */
1249 0x0088, /* “ - 147 */
1250 0x0088, /* ” - 148 */
1251 0x0008, /* • - 149 */
1252 0x0400, /* – - 150 */
1253 0x0400, /* — - 151 */
1254 0x0408, /* ˜ - 152 */
1255 0x0000, /* ™ - 153 */
1256 0x8003, /* š - 154 */
1257 0x0008, /* › - 155 */
1258 0x8000, /* œ - 156 */
1259 0x0000, /* � - 157 */
1260 0x0000, /* ž - 158 */
1261 0x8003, /* Ÿ - 159 */
1263 0x0008, /* ¡ - 161 */
1264 0x0048, /* ¢ - 162 */
1265 0x0048, /* £ - 163 */
1266 0x0008, /* ¤ - 164 */
1267 0x0048, /* ¥ - 165 */
1268 0x0048, /* ¦ - 166 */
1269 0x0008, /* § - 167 */
1270 0x0408, /* ¨ - 168 */
1271 0x0008, /* © - 169 */
1272 0x0400, /* ª - 170 */
1273 0x0008, /* « - 171 */
1274 0x0048, /* ¬ - 172 */
1275 0x0408, /* - 173 */
1276 0x0008, /* ® - 174 */
1277 0x0448, /* ¯ - 175 */
1278 0x0008, /* ° - 176 */
1279 0x0008, /* ± - 177 */
1280 0x0000, /* ² - 178 */
1281 0x0000, /* ³ - 179 */
1282 0x0408, /* ´ - 180 */
1283 0x0008, /* µ - 181 */
1284 0x0008, /* ¶ - 182 */
1285 0x0008, /* · - 183 */
1286 0x0408, /* ¸ - 184 */
1287 0x0000, /* ¹ - 185 */
1288 0x0400, /* º - 186 */
1289 0x0008, /* » - 187 */
1290 0x0000, /* ¼ - 188 */
1291 0x0000, /* ½ - 189 */
1292 0x0000, /* ¾ - 190 */
1293 0x0008, /* ¿ - 191 */
1294 0x8003, /* À - 192 */
1295 0x8003, /* Á - 193 */
1296 0x8003, /* Â - 194 */
1297 0x8003, /* Ã - 195 */
1298 0x8003, /* Ä - 196 */
1299 0x8003, /* Å - 197 */
1300 0x8000, /* Æ - 198 */
1301 0x8003, /* Ç - 199 */
1302 0x8003, /* È - 200 */
1303 0x8003, /* É - 201 */
1304 0x8003, /* Ê - 202 */
1305 0x8003, /* Ë - 203 */
1306 0x8003, /* Ì - 204 */
1307 0x8003, /* Í - 205 */
1308 0x8003, /* Î - 206 */
1309 0x8003, /* Ï - 207 */
1310 0x8000, /* Ð - 208 */
1311 0x8003, /* Ñ - 209 */
1312 0x8003, /* Ò - 210 */
1313 0x8003, /* Ó - 211 */
1314 0x8003, /* Ô - 212 */
1315 0x8003, /* Õ - 213 */
1316 0x8003, /* Ö - 214 */
1317 0x0008, /* × - 215 */
1318 0x8003, /* Ø - 216 */
1319 0x8003, /* Ù - 217 */
1320 0x8003, /* Ú - 218 */
1321 0x8003, /* Û - 219 */
1322 0x8003, /* Ü - 220 */
1323 0x8003, /* Ý - 221 */
1324 0x8000, /* Þ - 222 */
1325 0x8000, /* ß - 223 */
1326 0x8003, /* à - 224 */
1327 0x8003, /* á - 225 */
1328 0x8003, /* â - 226 */
1329 0x8003, /* ã - 227 */
1330 0x8003, /* ä - 228 */
1331 0x8003, /* å - 229 */
1332 0x8000, /* æ - 230 */
1333 0x8003, /* ç - 231 */
1334 0x8003, /* è - 232 */
1335 0x8003, /* é - 233 */
1336 0x8003, /* ê - 234 */
1337 0x8003, /* ë - 235 */
1338 0x8003, /* ì - 236 */
1339 0x8003, /* í - 237 */
1340 0x8003, /* î - 238 */
1341 0x8003, /* ï - 239 */
1342 0x8000, /* ð - 240 */
1343 0x8003, /* ñ - 241 */
1344 0x8003, /* ò - 242 */
1345 0x8003, /* ó - 243 */
1346 0x8003, /* ô - 244 */
1347 0x8003, /* õ - 245 */
1348 0x8003, /* ö - 246 */
1349 0x0008, /* ÷ - 247 */
1350 0x8003, /* ø - 248 */
1351 0x8003, /* ù - 249 */
1352 0x8003, /* ú - 250 */
1353 0x8003, /* û - 251 */
1354 0x8003, /* ü - 252 */
1355 0x8003, /* ý - 253 */
1356 0x8000, /* þ - 254 */
1357 0x8003 /* ÿ - 255 */
1360 /******************************************************************************
1361 * GetStringType16 [OLE2NLS.7]
1363 BOOL16 WINAPI
GetStringType16(LCID locale
,DWORD dwInfoType
,LPCSTR src
,
1364 INT16 cchSrc
,LPWORD chartype
)
1366 return GetStringTypeEx32A(locale
,dwInfoType
,src
,cchSrc
,chartype
);
1368 /******************************************************************************
1369 * GetStringType32A [KERNEL32.396]
1371 BOOL32 WINAPI
GetStringType32A(LCID locale
,DWORD dwInfoType
,LPCSTR src
,
1372 INT32 cchSrc
,LPWORD chartype
)
1374 return GetStringTypeEx32A(locale
,dwInfoType
,src
,cchSrc
,chartype
);
1377 /******************************************************************************
1378 * GetStringTypeEx32A [KERNEL32.397]
1380 * FIXME: Ignores the locale.
1382 BOOL32 WINAPI
GetStringTypeEx32A(LCID locale
,DWORD dwInfoType
,LPCSTR src
,
1383 INT32 cchSrc
,LPWORD chartype
)
1387 if ((src
==NULL
) || (chartype
==NULL
) || (src
==(LPSTR
)chartype
))
1389 SetLastError(ERROR_INVALID_PARAMETER
);
1394 cchSrc
=lstrlen32A(src
)+1;
1396 switch (dwInfoType
) {
1398 for (i
=0;i
<cchSrc
;i
++)
1401 if (isdigit(src
[i
])) chartype
[i
]|=C1_DIGIT
;
1402 if (isalpha(src
[i
])) chartype
[i
]|=C1_ALPHA
;
1403 if (islower(src
[i
])) chartype
[i
]|=C1_LOWER
;
1404 if (isupper(src
[i
])) chartype
[i
]|=C1_UPPER
;
1405 if (isspace(src
[i
])) chartype
[i
]|=C1_SPACE
;
1406 if (ispunct(src
[i
])) chartype
[i
]|=C1_PUNCT
;
1407 if (iscntrl(src
[i
])) chartype
[i
]|=C1_CNTRL
;
1408 /* FIXME: isblank() is a GNU extension */
1409 /* if (isblank(src[i])) chartype[i]|=C1_BLANK; */
1410 if ((src
[i
] == ' ') || (src
[i
] == '\t')) chartype
[i
]|=C1_BLANK
;
1416 for (i
=0;i
<cchSrc
;i
++)
1418 chartype
[i
]=(WORD
)CT_CType2_LUT
[i
];
1423 for (i
=0;i
<cchSrc
;i
++)
1425 chartype
[i
]=CT_CType3_LUT
[i
];
1430 ERR(ole
,"Unknown dwInfoType:%ld\n",dwInfoType
);
1435 /******************************************************************************
1436 * GetStringType32W [KERNEL32.399]
1439 * Yes, this is missing LCID locale. MS fault.
1441 BOOL32 WINAPI
GetStringType32W(DWORD dwInfoType
,LPCWSTR src
,INT32 cchSrc
,
1444 return GetStringTypeEx32W(0/*defaultlocale*/,dwInfoType
,src
,cchSrc
,chartype
);
1447 /******************************************************************************
1448 * GetStringTypeEx32W [KERNEL32.398]
1450 * FIXME: unicode chars are assumed chars
1452 BOOL32 WINAPI
GetStringTypeEx32W(LCID locale
,DWORD dwInfoType
,LPCWSTR src
,
1453 INT32 cchSrc
,LPWORD chartype
)
1459 cchSrc
=lstrlen32W(src
)+1;
1461 switch (dwInfoType
) {
1463 FIXME(ole
,"CT_CTYPE2 not supported.\n");
1466 FIXME(ole
,"CT_CTYPE3 not supported.\n");
1470 for (i
=0;i
<cchSrc
;i
++) {
1472 if (isdigit(src
[i
])) chartype
[i
]|=C1_DIGIT
;
1473 if (isalpha(src
[i
])) chartype
[i
]|=C1_ALPHA
;
1474 if (islower(src
[i
])) chartype
[i
]|=C1_LOWER
;
1475 if (isupper(src
[i
])) chartype
[i
]|=C1_UPPER
;
1476 if (isspace(src
[i
])) chartype
[i
]|=C1_SPACE
;
1477 if (ispunct(src
[i
])) chartype
[i
]|=C1_PUNCT
;
1478 if (iscntrl(src
[i
])) chartype
[i
]|=C1_CNTRL
;
1479 /* FIXME: isblank() is a GNU extension */
1480 /* if (isblank(src[i])) chartype[i]|=C1_BLANK; */
1481 if ((src
[i
] == ' ') || (src
[i
] == '\t')) chartype
[i
]|=C1_BLANK
;
1487 /*****************************************************************
1488 * VerLanguageName16 [VER.10]
1490 DWORD WINAPI
VerLanguageName16(UINT16 langid
,LPSTR langname
,UINT16 langnamelen
)
1496 TRACE(ver
,"(%d,%p,%d)\n",langid
,langname
,langnamelen
);
1497 /* First, check \System\CurrentControlSet\control\Nls\Locale\<langid>
1498 * from the registry.
1501 "\\System\\CurrentControlSet\\control\\Nls\\Locale\\%08x",
1503 result
= RegQueryValue16(HKEY_LOCAL_MACHINE
, buffer
, langname
,
1504 (LPDWORD
)&langnamelen
);
1505 if (result
== ERROR_SUCCESS
) {
1506 langname
[langnamelen
-1]='\0';
1509 /* if that fails, use the internal table */
1510 for (i
=0;languages
[i
].langid
!=0;i
++)
1511 if (langid
==languages
[i
].langid
)
1513 strncpy(langname
,languages
[i
].langname
,langnamelen
);
1514 langname
[langnamelen
-1]='\0';
1515 return strlen(languages
[i
].langname
);
1518 /*****************************************************************
1519 * VerLanguageName32A [VERSION.9]
1521 DWORD WINAPI
VerLanguageName32A(UINT32 langid
,LPSTR langname
,
1524 return VerLanguageName16(langid
,langname
,langnamelen
);
1527 /*****************************************************************
1528 * VerLanguageName32W [VERSION.10]
1530 DWORD WINAPI
VerLanguageName32W(UINT32 langid
,LPWSTR langname
,
1538 /* First, check \System\CurrentControlSet\control\Nls\Locale\<langid>
1539 * from the registry.
1542 "\\System\\CurrentControlSet\\control\\Nls\\Locale\\%08x",
1544 keyname
= HEAP_strdupAtoW( GetProcessHeap(), 0, buffer
);
1545 result
= RegQueryValue32W(HKEY_LOCAL_MACHINE
, keyname
, langname
,
1546 (LPDWORD
)&langnamelen
);
1547 HeapFree( GetProcessHeap(), 0, keyname
);
1548 if (result
!= ERROR_SUCCESS
) {
1549 /* if that fails, use the internal table */
1550 for (i
=0;languages
[i
].langid
!=0;i
++)
1551 if (langid
==languages
[i
].langid
)
1553 lstrcpyAtoW( langname
, languages
[i
].langname
);
1554 langnamelen
= strlen(languages
[i
].langname
);
1555 /* same as strlenW(langname); */
1560 static const unsigned char LCM_Unicode_LUT
[] = {
1593 7 , 28, /* ! - 33 */
1594 7 , 29, /* " - 34 */ /* " */
1595 7 , 31, /* # - 35 */
1596 7 , 33, /* $ - 36 */
1597 7 , 35, /* % - 37 */
1598 7 , 37, /* & - 38 */
1599 6 , 128, /* ' - 39 */
1600 7 , 39, /* ( - 40 */
1601 7 , 42, /* ) - 41 */
1602 7 , 45, /* * - 42 */
1604 7 , 47, /* , - 44 */
1605 6 , 130, /* - - 45 */
1606 7 , 51, /* . - 46 */
1607 7 , 53, /* / - 47 */
1608 12 , 3, /* 0 - 48 */
1609 12 , 33, /* 1 - 49 */
1610 12 , 51, /* 2 - 50 */
1611 12 , 70, /* 3 - 51 */
1612 12 , 88, /* 4 - 52 */
1613 12 , 106, /* 5 - 53 */
1614 12 , 125, /* 6 - 54 */
1615 12 , 144, /* 7 - 55 */
1616 12 , 162, /* 8 - 56 */
1617 12 , 180, /* 9 - 57 */
1618 7 , 55, /* : - 58 */
1619 7 , 58, /* ; - 59 */
1620 8 , 14, /* < - 60 */
1621 8 , 18, /* = - 61 */
1622 8 , 20, /* > - 62 */
1623 7 , 60, /* ? - 63 */
1624 7 , 62, /* @ - 64 */
1625 14 , 2, /* A - 65 */
1626 14 , 9, /* B - 66 */
1627 14 , 10, /* C - 67 */
1628 14 , 26, /* D - 68 */
1629 14 , 33, /* E - 69 */
1630 14 , 35, /* F - 70 */
1631 14 , 37, /* G - 71 */
1632 14 , 44, /* H - 72 */
1633 14 , 50, /* I - 73 */
1634 14 , 53, /* J - 74 */
1635 14 , 54, /* K - 75 */
1636 14 , 72, /* L - 76 */
1637 14 , 81, /* M - 77 */
1638 14 , 112, /* N - 78 */
1639 14 , 124, /* O - 79 */
1640 14 , 126, /* P - 80 */
1641 14 , 137, /* Q - 81 */
1642 14 , 138, /* R - 82 */
1643 14 , 145, /* S - 83 */
1644 14 , 153, /* T - 84 */
1645 14 , 159, /* U - 85 */
1646 14 , 162, /* V - 86 */
1647 14 , 164, /* W - 87 */
1648 14 , 166, /* X - 88 */
1649 14 , 167, /* Y - 89 */
1650 14 , 169, /* Z - 90 */
1651 7 , 63, /* [ - 91 */
1652 7 , 65, /* \ - 92 */
1653 7 , 66, /* ] - 93 */
1654 7 , 67, /* ^ - 94 */
1655 7 , 68, /* _ - 95 */
1656 7 , 72, /* ` - 96 */
1657 14 , 2, /* a - 97 */
1658 14 , 9, /* b - 98 */
1659 14 , 10, /* c - 99 */
1660 14 , 26, /* d - 100 */
1661 14 , 33, /* e - 101 */
1662 14 , 35, /* f - 102 */
1663 14 , 37, /* g - 103 */
1664 14 , 44, /* h - 104 */
1665 14 , 50, /* i - 105 */
1666 14 , 53, /* j - 106 */
1667 14 , 54, /* k - 107 */
1668 14 , 72, /* l - 108 */
1669 14 , 81, /* m - 109 */
1670 14 , 112, /* n - 110 */
1671 14 , 124, /* o - 111 */
1672 14 , 126, /* p - 112 */
1673 14 , 137, /* q - 113 */
1674 14 , 138, /* r - 114 */
1675 14 , 145, /* s - 115 */
1676 14 , 153, /* t - 116 */
1677 14 , 159, /* u - 117 */
1678 14 , 162, /* v - 118 */
1679 14 , 164, /* w - 119 */
1680 14 , 166, /* x - 120 */
1681 14 , 167, /* y - 121 */
1682 14 , 169, /* z - 122 */
1683 7 , 74, /* { - 123 */
1684 7 , 76, /* | - 124 */
1685 7 , 78, /* } - 125 */
1686 7 , 80, /* ~ - 126 */
1687 6 , 29, /* \x7f - 127 */
1688 6 , 30, /* € - 128 */
1689 6 , 31, /* � - 129 */
1690 7 , 123, /* ‚ - 130 */
1691 14 , 35, /* ƒ - 131 */
1692 7 , 127, /* „ - 132 */
1693 10 , 21, /* … - 133 */
1694 10 , 15, /* † - 134 */
1695 10 , 16, /* ‡ - 135 */
1696 7 , 67, /* ˆ - 136 */
1697 10 , 22, /* ‰ - 137 */
1698 14 , 145, /* Š - 138 */
1699 7 , 136, /* ‹ - 139 */
1700 14 + 16 , 124, /* Œ - 140 */
1701 6 , 43, /* � - 141 */
1702 6 , 44, /* Ž - 142 */
1703 6 , 45, /* � - 143 */
1704 6 , 46, /* � - 144 */
1705 7 , 121, /* ‘ - 145 */
1706 7 , 122, /* ’ - 146 */
1707 7 , 125, /* “ - 147 */
1708 7 , 126, /* ” - 148 */
1709 10 , 17, /* • - 149 */
1710 6 , 137, /* – - 150 */
1711 6 , 139, /* — - 151 */
1712 7 , 93, /* ˜ - 152 */
1713 14 , 156, /* ™ - 153 */
1714 14 , 145, /* š - 154 */
1715 7 , 137, /* › - 155 */
1716 14 + 16 , 124, /* œ - 156 */
1717 6 , 59, /* � - 157 */
1718 6 , 60, /* ž - 158 */
1719 14 , 167, /* Ÿ - 159 */
1721 7 , 81, /* ¡ - 161 */
1722 10 , 2, /* ¢ - 162 */
1723 10 , 3, /* £ - 163 */
1724 10 , 4, /* ¤ - 164 */
1725 10 , 5, /* ¥ - 165 */
1726 7 , 82, /* ¦ - 166 */
1727 10 , 6, /* § - 167 */
1728 7 , 83, /* ¨ - 168 */
1729 10 , 7, /* © - 169 */
1730 14 , 2, /* ª - 170 */
1731 8 , 24, /* « - 171 */
1732 10 , 8, /* ¬ - 172 */
1733 6 , 131, /* - 173 */
1734 10 , 9, /* ® - 174 */
1735 7 , 84, /* ¯ - 175 */
1736 10 , 10, /* ° - 176 */
1737 8 , 23, /* ± - 177 */
1738 12 , 51, /* ² - 178 */
1739 12 , 70, /* ³ - 179 */
1740 7 , 85, /* ´ - 180 */
1741 10 , 11, /* µ - 181 */
1742 10 , 12, /* ¶ - 182 */
1743 10 , 13, /* · - 183 */
1744 7 , 86, /* ¸ - 184 */
1745 12 , 33, /* ¹ - 185 */
1746 14 , 124, /* º - 186 */
1747 8 , 26, /* » - 187 */
1748 12 , 21, /* ¼ - 188 */
1749 12 , 25, /* ½ - 189 */
1750 12 , 29, /* ¾ - 190 */
1751 7 , 87, /* ¿ - 191 */
1752 14 , 2, /* À - 192 */
1753 14 , 2, /* Á - 193 */
1754 14 , 2, /* Â - 194 */
1755 14 , 2, /* Ã - 195 */
1756 14 , 2, /* Ä - 196 */
1757 14 , 2, /* Å - 197 */
1758 14 + 16 , 2, /* Æ - 198 */
1759 14 , 10, /* Ç - 199 */
1760 14 , 33, /* È - 200 */
1761 14 , 33, /* É - 201 */
1762 14 , 33, /* Ê - 202 */
1763 14 , 33, /* Ë - 203 */
1764 14 , 50, /* Ì - 204 */
1765 14 , 50, /* Í - 205 */
1766 14 , 50, /* Î - 206 */
1767 14 , 50, /* Ï - 207 */
1768 14 , 26, /* Ð - 208 */
1769 14 , 112, /* Ñ - 209 */
1770 14 , 124, /* Ò - 210 */
1771 14 , 124, /* Ó - 211 */
1772 14 , 124, /* Ô - 212 */
1773 14 , 124, /* Õ - 213 */
1774 14 , 124, /* Ö - 214 */
1775 8 , 28, /* × - 215 */
1776 14 , 124, /* Ø - 216 */
1777 14 , 159, /* Ù - 217 */
1778 14 , 159, /* Ú - 218 */
1779 14 , 159, /* Û - 219 */
1780 14 , 159, /* Ü - 220 */
1781 14 , 167, /* Ý - 221 */
1782 14 + 32 , 153, /* Þ - 222 */
1783 14 + 48 , 145, /* ß - 223 */
1784 14 , 2, /* à - 224 */
1785 14 , 2, /* á - 225 */
1786 14 , 2, /* â - 226 */
1787 14 , 2, /* ã - 227 */
1788 14 , 2, /* ä - 228 */
1789 14 , 2, /* å - 229 */
1790 14 + 16 , 2, /* æ - 230 */
1791 14 , 10, /* ç - 231 */
1792 14 , 33, /* è - 232 */
1793 14 , 33, /* é - 233 */
1794 14 , 33, /* ê - 234 */
1795 14 , 33, /* ë - 235 */
1796 14 , 50, /* ì - 236 */
1797 14 , 50, /* í - 237 */
1798 14 , 50, /* î - 238 */
1799 14 , 50, /* ï - 239 */
1800 14 , 26, /* ð - 240 */
1801 14 , 112, /* ñ - 241 */
1802 14 , 124, /* ò - 242 */
1803 14 , 124, /* ó - 243 */
1804 14 , 124, /* ô - 244 */
1805 14 , 124, /* õ - 245 */
1806 14 , 124, /* ö - 246 */
1807 8 , 29, /* ÷ - 247 */
1808 14 , 124, /* ø - 248 */
1809 14 , 159, /* ù - 249 */
1810 14 , 159, /* ú - 250 */
1811 14 , 159, /* û - 251 */
1812 14 , 159, /* ü - 252 */
1813 14 , 167, /* ý - 253 */
1814 14 + 32 , 153, /* þ - 254 */
1815 14 , 167 /* ÿ - 255 */ };
1817 static const unsigned char LCM_Unicode_LUT_2
[] = { 33, 44, 145 };
1819 #define LCM_Diacritic_Start 131
1821 static const unsigned char LCM_Diacritic_LUT
[] = {
1949 /******************************************************************************
1950 * OLE2NLS_isPunctuation [INTERNAL]
1952 static int OLE2NLS_isPunctuation(unsigned char c
)
1954 /* "punctuation character" in this context is a character which is
1955 considered "less important" during word sort comparison.
1956 See LCMapString implementation for the precise definition
1957 of "less important". */
1959 return (LCM_Unicode_LUT
[-2+2*c
]==6);
1962 /******************************************************************************
1963 * identity [Internal]
1965 static int identity(int c
)
1970 /*************************************************************************
1971 * LCMapString32A [KERNEL32.492]
1973 * Convert a string, or generate a sort key from it.
1975 * If (mapflags & LCMAP_SORTKEY), the function will generate
1976 * a sort key for the source string. Else, it will convert it
1977 * accordingly to the flags LCMAP_UPPERCASE, LCMAP_LOWERCASE,...
1981 * Success : length of the result string.
1984 * If called with scrlen = -1, the function will compute the length
1985 * of the 0-terminated string strsrc by itself.
1987 * If called with dstlen = 0, returns the buffer length that
1988 * would be required.
1990 * NORM_IGNOREWIDTH means to compare ASCII and Unicode characters
1991 * as if they are equal. Since Wine separates ASCII and Unicode into
1992 * separate functions, we shouldn't have to do anything for this flag.
1993 * I added it to the list of flags that don't need a fixme message
1994 * to make MS Word 95 not print several thousand fixme messages for
1997 INT32 WINAPI
LCMapString32A(
1998 LCID lcid
/* locale identifier created with MAKELCID;
1999 LOCALE_SYSTEM_DEFAULT and LOCALE_USER_DEFAULT are
2000 predefined values. */,
2001 DWORD mapflags
/* flags */,
2002 LPCSTR srcstr
/* source buffer */,
2003 INT32 srclen
/* source length */,
2004 LPSTR dststr
/* destination buffer */,
2005 INT32 dstlen
/* destination buffer length */)
2009 TRACE(string
,"(0x%04lx,0x%08lx,%s,%d,%p,%d)\n",
2010 lcid
,mapflags
,srcstr
,srclen
,dststr
,dstlen
);
2012 if ( ((dstlen
!=0) && (dststr
==NULL
)) || (srcstr
==NULL
) )
2014 ERR(ole
, "(src=%s,dest=%s): Invalid NULL string\n", srcstr
, dststr
);
2015 SetLastError(ERROR_INVALID_PARAMETER
);
2019 srclen
= lstrlen32A(srcstr
) + 1 ; /* (include final '\0') */
2021 if (mapflags
& ~ ( LCMAP_UPPERCASE
| LCMAP_LOWERCASE
| LCMAP_SORTKEY
|
2022 NORM_IGNORECASE
| NORM_IGNORENONSPACE
| SORT_STRINGSORT
|
2025 FIXME(string
,"(0x%04lx,0x%08lx,%p,%d,%p,%d): "
2026 "unimplemented flags: 0x%08lx\n",
2028 mapflags
&~(LCMAP_UPPERCASE
| LCMAP_LOWERCASE
| LCMAP_SORTKEY
|
2029 NORM_IGNORECASE
| NORM_IGNORENONSPACE
| SORT_STRINGSORT
|
2039 if ( !(mapflags
& LCMAP_SORTKEY
) )
2041 int (*f
)(int)=identity
;
2044 return srclen
; /* dstlen=0 means "do nothing but return required length" */
2046 srclen
=dstlen
; /* No, this case is not an error under Windows 95.
2047 And no '\0' gets written. */
2048 if (mapflags
& LCMAP_UPPERCASE
)
2050 else if (mapflags
& LCMAP_LOWERCASE
)
2052 for (i
=0; i
< srclen
; i
++)
2053 dststr
[i
] = (CHAR
) f(srcstr
[i
]);
2057 /* else ... (mapflags & LCMAP_SORTKEY) */
2061 int diacritic_len
=0;
2062 int delayed_punctuation_len
=0;
2063 char *case_component
;
2064 char *diacritic_component
;
2065 char *delayed_punctuation_component
;
2067 int flag_stringsort
= mapflags
& SORT_STRINGSORT
;
2069 /* compute how much room we will need */
2070 for (i
=0;i
<srclen
;i
++)
2073 unsigned char source_char
= srcstr
[i
];
2074 if (source_char
!='\0')
2076 if (flag_stringsort
|| !OLE2NLS_isPunctuation(source_char
))
2079 if ( LCM_Unicode_LUT
[-2+2*source_char
] & ~15 )
2080 unicode_len
++; /* double letter */
2084 delayed_punctuation_len
++;
2088 if (isupper(source_char
))
2089 case_len
=unicode_len
;
2091 ofs
= source_char
- LCM_Diacritic_Start
;
2092 if ((ofs
>=0) && (LCM_Diacritic_LUT
[ofs
]!=2))
2093 diacritic_len
=unicode_len
;
2096 if (mapflags
& NORM_IGNORECASE
)
2098 if (mapflags
& NORM_IGNORENONSPACE
)
2101 room
= 2 * unicode_len
/* "unicode" component */
2102 + diacritic_len
/* "diacritic" component */
2103 + case_len
/* "case" component */
2104 + 4 * delayed_punctuation_len
/* punctuation in word sort mode */
2105 + 4 /* four '\1' separators */
2106 + 1 ; /* terminal '\0' */
2109 else if (dstlen
<room
)
2111 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2115 /*FIXME the Pointercheck should not be nessesary */
2116 if (IsBadWritePtr32 (dststr
,room
))
2117 { ERR (string
,"bad destination buffer (dststr) : %p,%d\n",dststr
,dstlen
);
2118 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2122 /* locate each component, write separators */
2123 diacritic_component
= dststr
+ 2*unicode_len
;
2124 *diacritic_component
++ = '\1';
2125 case_component
= diacritic_component
+ diacritic_len
;
2126 *case_component
++ = '\1';
2127 delayed_punctuation_component
= case_component
+ case_len
;
2128 *delayed_punctuation_component
++ = '\1';
2129 *delayed_punctuation_component
++ = '\1';
2131 /* read source string char by char, write
2132 corresponding weight in each component. */
2133 for (i
=0,count
=0;i
<srclen
;i
++)
2135 unsigned char source_char
=srcstr
[i
];
2136 if (source_char
!='\0')
2139 type
= LCM_Unicode_LUT
[-2+2*source_char
];
2140 longcode
= type
>> 4;
2142 if (!flag_stringsort
&& OLE2NLS_isPunctuation(source_char
))
2144 UINT16 encrypted_location
= (1<<15) + 7 + 4*count
;
2145 *delayed_punctuation_component
++ = (unsigned char) (encrypted_location
>>8);
2146 *delayed_punctuation_component
++ = (unsigned char) (encrypted_location
&255);
2147 /* big-endian is used here because it lets string comparison be
2148 compatible with numerical comparison */
2150 *delayed_punctuation_component
++ = type
;
2151 *delayed_punctuation_component
++ = LCM_Unicode_LUT
[-1+2*source_char
];
2152 /* assumption : a punctuation character is never a
2153 double or accented letter */
2157 dststr
[2*count
] = type
;
2158 dststr
[2*count
+1] = LCM_Unicode_LUT
[-1+2*source_char
];
2162 case_component
[count
] = ( isupper(source_char
) ? 18 : 2 ) ;
2163 if (count
<diacritic_len
)
2164 diacritic_component
[count
] = 2; /* assumption: a double letter
2165 is never accented */
2168 dststr
[2*count
] = type
;
2169 dststr
[2*count
+1] = *(LCM_Unicode_LUT_2
- 1 + longcode
);
2170 /* 16 in the first column of LCM_Unicode_LUT --> longcode = 1
2171 32 in the first column of LCM_Unicode_LUT --> longcode = 2
2172 48 in the first column of LCM_Unicode_LUT --> longcode = 3 */
2176 case_component
[count
] = ( isupper(source_char
) ? 18 : 2 ) ;
2177 if (count
<diacritic_len
)
2179 int ofs
= source_char
- LCM_Diacritic_Start
;
2180 diacritic_component
[count
] = (ofs
>=0 ? LCM_Diacritic_LUT
[ofs
] : 2);
2186 dststr
[room
-1] = '\0';
2191 /*************************************************************************
2192 * LCMapString32W [KERNEL32.493]
2194 * Convert a string, or generate a sort key from it.
2198 * See LCMapString32A for documentation
2200 INT32 WINAPI
LCMapString32W(
2201 LCID lcid
,DWORD mapflags
,LPCWSTR srcstr
,INT32 srclen
,LPWSTR dststr
,
2206 TRACE(string
,"(0x%04lx,0x%08lx,%p,%d,%p,%d)\n",
2207 lcid
,mapflags
,srcstr
,srclen
,dststr
,dstlen
);
2209 if ( ((dstlen
!=0) && (dststr
==NULL
)) || (srcstr
==NULL
) )
2211 ERR(ole
, "(src=%p,dst=%p): Invalid NULL string\n", srcstr
, dststr
);
2212 SetLastError(ERROR_INVALID_PARAMETER
);
2216 srclen
= lstrlen32W(srcstr
)+1;
2217 if (mapflags
& LCMAP_SORTKEY
)
2219 FIXME(string
,"(0x%04lx,0x%08lx,%p,%d,%p,%d): "
2220 "unimplemented flags: 0x%08lx\n",
2221 lcid
,mapflags
,srcstr
,srclen
,dststr
,dstlen
,mapflags
);
2226 int (*f
)(int)=identity
;
2232 if (mapflags
& LCMAP_UPPERCASE
)
2234 else if (mapflags
& LCMAP_LOWERCASE
)
2236 for (i
=0; i
< srclen
; i
++)
2237 dststr
[i
] = (WCHAR
) f(srcstr
[i
]);
2242 /***********************************************************************
2243 * CompareString16 (OLE2NLS.8)
2245 UINT16 WINAPI
CompareString16(DWORD lcid
,DWORD fdwStyle
,
2246 LPCSTR s1
,DWORD l1
,LPCSTR s2
,DWORD l2
)
2248 return (UINT16
)CompareString32A(lcid
,fdwStyle
,s1
,l1
,s2
,l2
);
2251 /******************************************************************************
2252 * CompareString32A [KERNEL32.143]
2253 * Compares two strings using locale
2257 * success: CSTR_LESS_THAN, CSTR_EQUAL, CSTR_GREATER_THAN
2262 * Defaults to a word sort, but uses a string sort if
2263 * SORT_STRINGSORT is set.
2264 * Calls SetLastError for ERROR_INVALID_FLAGS, ERROR_INVALID_PARAMETER.
2268 * This implementation ignores the locale
2272 * Quite inefficient.
2274 UINT32 WINAPI
CompareString32A(
2275 DWORD lcid
, /* locale ID */
2276 DWORD fdwStyle
, /* comparison-style options */
2277 LPCSTR s1
, /* first string */
2278 DWORD l1
, /* length of first string */
2279 LPCSTR s2
, /* second string */
2280 DWORD l2
) /* length of second string */
2282 int mapstring_flags
;
2286 TRACE(ole
,"%s and %s\n",
2287 debugstr_a (s1
), debugstr_a (s2
));
2289 if ( (s1
==NULL
) || (s2
==NULL
) )
2291 ERR(ole
, "(s1=%s,s2=%s): Invalid NULL string\n", s1
, s2
);
2292 SetLastError(ERROR_INVALID_PARAMETER
);
2296 if(fdwStyle
& NORM_IGNORESYMBOLS
)
2297 FIXME(ole
, "IGNORESYMBOLS not supported\n");
2299 mapstring_flags
= LCMAP_SORTKEY
| fdwStyle
;
2300 len1
= LCMapString32A(lcid
,mapstring_flags
,s1
,l1
,NULL
,0);
2301 len2
= LCMapString32A(lcid
,mapstring_flags
,s2
,l2
,NULL
,0);
2303 if ((len1
==0)||(len2
==0))
2304 return 0; /* something wrong happened */
2306 sk1
= (LPSTR
)HeapAlloc(GetProcessHeap(),0,len1
);
2307 sk2
= (LPSTR
)HeapAlloc(GetProcessHeap(),0,len2
);
2308 if ( (!LCMapString32A(lcid
,mapstring_flags
,s1
,l1
,sk1
,len1
))
2309 || (!LCMapString32A(lcid
,mapstring_flags
,s2
,l2
,sk2
,len2
)) )
2311 ERR(ole
,"Bug in LCmapString32A.\n");
2316 /* strcmp doesn't necessarily return -1, 0, or 1 */
2317 result
= strcmp(sk1
,sk2
);
2319 HeapFree(GetProcessHeap(),0,sk1
);
2320 HeapFree(GetProcessHeap(),0,sk2
);
2327 /* must be greater, if we reach this point */
2331 /******************************************************************************
2332 * CompareString32W [KERNEL32.144]
2333 * This implementation ignores the locale
2334 * FIXME : Does only string sort. Should
2335 * be reimplemented the same way as CompareString32A.
2337 UINT32 WINAPI
CompareString32W(DWORD lcid
, DWORD fdwStyle
,
2338 LPCWSTR s1
, DWORD l1
, LPCWSTR s2
,DWORD l2
)
2341 if(fdwStyle
& NORM_IGNORENONSPACE
)
2342 FIXME(ole
,"IGNORENONSPACE not supprted\n");
2343 if(fdwStyle
& NORM_IGNORESYMBOLS
)
2344 FIXME(ole
,"IGNORESYMBOLS not supported\n");
2346 /* Is strcmp defaulting to string sort or to word sort?? */
2347 /* FIXME: Handle NORM_STRINGSORT */
2348 l1
= (l1
==-1)?lstrlen32W(s1
):l1
;
2349 l2
= (l2
==-1)?lstrlen32W(s2
):l2
;
2350 len
= l1
<l2
? l1
:l2
;
2351 ret
= (fdwStyle
& NORM_IGNORECASE
) ?
2352 lstrncmpi32W(s1
,s2
,len
) : lstrncmp32W(s1
,s2
,len
);
2353 /* not equal, return 1 or 3 */
2354 if(ret
!=0) return ret
+2;
2355 /* same len, return 2 */
2356 if(l1
==l2
) return 2;
2357 /* the longer one is lexically greater */
2358 return (l1
<l2
)? 1 : 3;
2361 /******************************************************************************
2362 * OLE_GetFormatA [Internal]
2365 * If datelen == 0, it should return the reguired string length.
2367 This function implements stuff for GetDateFormat() and
2370 d single-digit (no leading zero) day (of month)
2371 dd two-digit day (of month)
2372 ddd short day-of-week name
2373 dddd long day-of-week name
2374 M single-digit month
2376 MMM short month name
2377 MMMM full month name
2378 y two-digit year, no leading 0
2380 yyyy four-digit year
2382 h hours with no leading zero (12-hour)
2383 hh hours with full two digits
2384 H hours with no leading zero (24-hour)
2385 HH hours with full two digits
2386 m minutes with no leading zero
2387 mm minutes with full two digits
2388 s seconds with no leading zero
2389 ss seconds with full two digits
2390 t time marker (A or P)
2391 tt time marker (AM, PM)
2392 '' used to quote literal characters
2393 '' (within a quoted string) indicates a literal '
2395 These functions REQUIRE valid locale, date, and format.
2397 static INT32
OLE_GetFormatA(LCID locale
,
2401 LPCSTR _format
, /*in*/
2405 INT32 inpos
, outpos
;
2406 int count
, type
, inquote
, Overflow
;
2412 const char * _dgfmt
[] = { "%d", "%02d" };
2413 const char ** dgfmt
= _dgfmt
- 1;
2415 /* report, for debugging */
2416 TRACE(ole
, "(0x%lx,0x%lx, 0x%lx, time(d=%d,h=%d,m=%d,s=%d), fmt=%p \'%s\' , %p, len=%d)\n",
2417 locale
, flags
, tflags
,
2418 xtime
->wDay
, xtime
->wHour
, xtime
->wMinute
, xtime
->wSecond
,
2419 _format
, _format
, date
, datelen
);
2422 FIXME(ole
, "datelen = 0, returning 255\n");
2426 /* initalize state variables and output buffer */
2428 count
= 0; inquote
= 0; Overflow
= 0;
2430 date
[0] = buf
[0] = '\0';
2432 strcpy(format
,_format
);
2434 /* alter the formatstring, while it works for all languages now in wine
2435 its possible that it fails when the time looks like ss:mm:hh as example*/
2436 if (tflags
& (TIME_NOMINUTESORSECONDS
))
2437 { if ((pos
= strstr ( format
, ":mm")))
2438 { memcpy ( pos
, pos
+3, strlen(format
)-(pos
-format
)-2 );
2441 if (tflags
& (TIME_NOSECONDS
))
2442 { if ((pos
= strstr ( format
, ":ss")))
2443 { memcpy ( pos
, pos
+3, strlen(format
)-(pos
-format
)-2 );
2447 for (inpos
= 0;; inpos
++) {
2448 /* 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]); */
2450 if (format
[inpos
] == '\'') {
2451 if (format
[inpos
+1] == '\'') {
2453 date
[outpos
++] = '\'';
2456 continue; /* we did nothing to the output */
2458 } else if (format
[inpos
] == '\0') {
2459 date
[outpos
++] = '\0';
2460 if (outpos
> datelen
) Overflow
= 1;
2463 date
[outpos
++] = format
[inpos
];
2464 if (outpos
> datelen
) {
2466 date
[outpos
-1] = '\0'; /* this is the last place where
2467 it's safe to write */
2471 } else if ( (count
&& (format
[inpos
] != type
))
2473 || (count
== 2 && strchr("ghHmst", type
)) )
2477 GetLocaleInfo32A(locale
,
2479 + xtime
->wDayOfWeek
- 1,
2481 } else if (count
== 3) {
2482 GetLocaleInfo32A(locale
,
2483 LOCALE_SABBREVDAYNAME1
2484 + xtime
->wDayOfWeek
- 1,
2487 sprintf(buf
, dgfmt
[count
], xtime
->wDay
);
2489 } else if (type
== 'M') {
2491 GetLocaleInfo32A(locale
,
2492 LOCALE_SABBREVMONTHNAME1
2493 + xtime
->wMonth
- 1,
2495 } else if (count
== 4) {
2496 GetLocaleInfo32A(locale
,
2498 + xtime
->wMonth
- 1,
2501 sprintf(buf
, dgfmt
[count
], xtime
->wMonth
);
2503 } else if (type
== 'y') {
2505 sprintf(buf
, "%d", xtime
->wYear
);
2506 } else if (count
== 3) {
2508 WARN(ole
, "unknown format, c=%c, n=%d\n", type
, count
);
2510 sprintf(buf
, dgfmt
[count
], xtime
->wYear
% 100);
2512 } else if (type
== 'g') {
2514 FIXME(ole
, "LOCALE_ICALENDARTYPE unimp.\n");
2518 WARN(ole
, "unknown format, c=%c, n=%d\n", type
, count
);
2520 } else if (type
== 'h') {
2521 /* gives us hours 1:00 -- 12:00 */
2522 sprintf(buf
, dgfmt
[count
], (xtime
->wHour
-1)%12 +1);
2523 } else if (type
== 'H') {
2525 sprintf(buf
, dgfmt
[count
], xtime
->wHour
);
2526 } else if ( type
== 'm') {
2527 sprintf(buf
, dgfmt
[count
], xtime
->wMinute
);
2528 } else if ( type
== 's') {
2529 sprintf(buf
, dgfmt
[count
], xtime
->wSecond
);
2530 } else if (type
== 't') {
2532 sprintf(buf
, "%c", (xtime
->wHour
< 12) ? 'A' : 'P');
2533 } else if (count
== 2) {
2534 /* sprintf(buf, "%s", (xtime->wHour < 12) ? "AM" : "PM"); */
2535 GetLocaleInfo32A(locale
,
2537 ? LOCALE_S1159
: LOCALE_S2359
,
2542 /* we need to check the next char in the format string
2543 again, no matter what happened */
2546 /* add the contents of buf to the output */
2547 buflen
= strlen(buf
);
2548 if (outpos
+ buflen
< datelen
) {
2549 date
[outpos
] = '\0'; /* for strcat to hook onto */
2553 date
[outpos
] = '\0';
2554 strncat(date
, buf
, datelen
- outpos
);
2555 date
[datelen
- 1] = '\0';
2556 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2557 WARN(ole
, "insufficient buffer\n");
2561 /* reset the variables we used to keep track of this item */
2564 } else if (format
[inpos
] == '\0') {
2565 /* we can't check for this at the loop-head, because
2566 that breaks the printing of the last format-item */
2567 date
[outpos
] = '\0';
2570 /* continuing a code for an item */
2573 } else if (strchr("hHmstyMdg", format
[inpos
])) {
2574 type
= format
[inpos
];
2577 } else if (format
[inpos
] == '\'') {
2581 date
[outpos
++] = format
[inpos
];
2583 /* now deal with a possible buffer overflow */
2584 if (outpos
>= datelen
) {
2585 date
[datelen
- 1] = '\0';
2586 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2592 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2595 /* finish it off with a string terminator */
2598 if (outpos
> datelen
-1) outpos
= datelen
-1;
2599 date
[outpos
] = '\0';
2601 TRACE(ole
, "OLE_GetFormatA returns string '%s', len %d\n",
2606 /******************************************************************************
2607 * OLE_GetFormatW [INTERNAL]
2609 static INT32
OLE_GetFormatW(LCID locale
, DWORD flags
, DWORD tflags
,
2612 LPWSTR output
, INT32 outlen
)
2614 INT32 inpos
, outpos
;
2615 int count
, type
=0, inquote
;
2616 int Overflow
; /* loop check */
2619 WCHAR arg0
[] = {0}, arg1
[] = {'%','d',0};
2620 WCHAR arg2
[] = {'%','0','2','d',0};
2621 WCHAR
*argarr
[] = {arg0
, arg1
, arg2
};
2622 int datevars
=0, timevars
=0;
2624 /* make a debug report */
2625 TRACE(ole
, "args: 0x%lx, 0x%lx, 0x%lx, time(d=%d,h=%d,m=%d,s=%d), fmt:%s (at %p),
2626 %p with max len %d\n",
2627 locale
, flags
, tflags
,
2628 xtime
->wDay
, xtime
->wHour
, xtime
->wMinute
, xtime
->wSecond
,
2629 debugstr_w(format
), format
, output
, outlen
);
2632 FIXME(ole
, "outlen = 0, returning 255\n");
2636 /* initialize state variables */
2639 inquote
= Overflow
= 0;
2640 /* this is really just a sanity check */
2641 output
[0] = buf
[0] = 0;
2643 /* this loop is the core of the function */
2644 for (inpos
= 0; /* we have several break points */ ; inpos
++) {
2646 if (format
[inpos
] == (WCHAR
) '\'') {
2647 if (format
[inpos
+1] == '\'') {
2649 output
[outpos
++] = '\'';
2654 } else if (format
[inpos
] == 0) {
2655 output
[outpos
++] = 0;
2656 if (outpos
> outlen
) Overflow
= 1;
2657 break; /* normal exit (within a quote) */
2659 output
[outpos
++] = format
[inpos
]; /* copy input */
2660 if (outpos
> outlen
) {
2662 output
[outpos
-1] = 0;
2666 } else if ( (count
&& (format
[inpos
] != type
))
2667 || ( (count
==4 && type
=='y') ||
2668 (count
==4 && type
=='M') ||
2669 (count
==4 && type
=='d') ||
2670 (count
==2 && type
=='g') ||
2671 (count
==2 && type
=='h') ||
2672 (count
==2 && type
=='H') ||
2673 (count
==2 && type
=='m') ||
2674 (count
==2 && type
=='s') ||
2675 (count
==2 && type
=='t') ) ) {
2678 GetLocaleInfo32W(locale
,
2679 LOCALE_SDAYNAME1
+ xtime
->wDayOfWeek
-1,
2680 buf
, sizeof(buf
)/sizeof(WCHAR
) );
2681 } else if (count
== 3) {
2682 GetLocaleInfo32W(locale
,
2683 LOCALE_SABBREVDAYNAME1
+
2684 xtime
->wDayOfWeek
-1,
2685 buf
, sizeof(buf
)/sizeof(WCHAR
) );
2687 wsnprintf32W(buf
, 5, argarr
[count
], xtime
->wDay
);
2689 } else if (type
== 'M') {
2691 GetLocaleInfo32W(locale
, LOCALE_SMONTHNAME1
+
2692 xtime
->wMonth
-1, buf
,
2693 sizeof(buf
)/sizeof(WCHAR
) );
2694 } else if (count
== 3) {
2695 GetLocaleInfo32W(locale
, LOCALE_SABBREVMONTHNAME1
+
2696 xtime
->wMonth
-1, buf
,
2697 sizeof(buf
)/sizeof(WCHAR
) );
2699 wsnprintf32W(buf
, 5, argarr
[count
], xtime
->wMonth
);
2701 } else if (type
== 'y') {
2703 wsnprintf32W(buf
, 6, argarr
[1] /* "%d" */,
2705 } else if (count
== 3) {
2706 lstrcpynAtoW(buf
, "yyy", 5);
2708 wsnprintf32W(buf
, 6, argarr
[count
],
2709 xtime
->wYear
% 100);
2711 } else if (type
== 'g') {
2713 FIXME(ole
, "LOCALE_ICALENDARTYPE unimplemented\n");
2714 lstrcpynAtoW(buf
, "AD", 5);
2716 /* Win API sez we copy it verbatim */
2717 lstrcpynAtoW(buf
, "g", 5);
2719 } else if (type
== 'h') {
2720 /* hours 1:00-12:00 --- is this right? */
2721 wsnprintf32W(buf
, 5, argarr
[count
],
2722 (xtime
->wHour
-1)%12 +1);
2723 } else if (type
== 'H') {
2724 wsnprintf32W(buf
, 5, argarr
[count
],
2726 } else if (type
== 'm' ) {
2727 wsnprintf32W(buf
, 5, argarr
[count
],
2729 } else if (type
== 's' ) {
2730 wsnprintf32W(buf
, 5, argarr
[count
],
2732 } else if (type
== 't') {
2733 GetLocaleInfo32W(locale
, (xtime
->wHour
< 12) ?
2734 LOCALE_S1159
: LOCALE_S2359
,
2741 /* no matter what happened, we need to check this next
2742 character the next time we loop through */
2745 /* cat buf onto the output */
2746 outlen
= lstrlen32W(buf
);
2747 if (outpos
+ buflen
< outlen
) {
2748 output
[outpos
] = 0; /* a "hook" for strcat */
2749 lstrcat32W(output
, buf
);
2753 lstrcatn32W(output
, buf
, outlen
- outpos
);
2754 output
[outlen
- 1] = 0;
2756 break; /* Abnormal exit */
2759 /* reset the variables we used this time */
2762 } else if (format
[inpos
] == 0) {
2763 /* we can't check for this at the beginning, because that
2764 would keep us from printing a format spec that ended the
2767 break; /* NORMAL EXIT */
2769 /* how we keep track of the middle of a format spec */
2772 } else if ( (datevars
&& (format
[inpos
]=='d' ||
2773 format
[inpos
]=='M' ||
2774 format
[inpos
]=='y' ||
2775 format
[inpos
]=='g') ) ||
2776 (timevars
&& (format
[inpos
]=='H' ||
2777 format
[inpos
]=='h' ||
2778 format
[inpos
]=='m' ||
2779 format
[inpos
]=='s' ||
2780 format
[inpos
]=='t') ) ) {
2781 type
= format
[inpos
];
2784 } else if (format
[inpos
] == '\'') {
2788 /* unquoted literals */
2789 output
[outpos
++] = format
[inpos
];
2794 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2795 WARN(ole
, " buffer overflow\n");
2798 /* final string terminator and sanity check */
2800 if (outpos
> outlen
-1) outpos
= outlen
-1;
2801 output
[outpos
] = '0';
2803 TRACE(ole
, " returning %s\n", debugstr_w(output
));
2805 return (!Overflow
) ? outlen
: 0;
2810 /******************************************************************************
2811 * GetDateFormat32A [KERNEL32.310]
2812 * Makes an ASCII string of the date
2814 * This function uses format to format the date, or, if format
2815 * is NULL, uses the default for the locale. format is a string
2816 * of literal fields and characters as follows:
2818 * - d single-digit (no leading zero) day (of month)
2819 * - dd two-digit day (of month)
2820 * - ddd short day-of-week name
2821 * - dddd long day-of-week name
2822 * - M single-digit month
2823 * - MM two-digit month
2824 * - MMM short month name
2825 * - MMMM full month name
2826 * - y two-digit year, no leading 0
2827 * - yy two-digit year
2828 * - yyyy four-digit year
2832 INT32 WINAPI
GetDateFormat32A(LCID locale
,DWORD flags
,
2834 LPCSTR format
, LPSTR date
,INT32 datelen
)
2837 char format_buf
[40];
2840 LPSYSTEMTIME thistime
;
2844 TRACE(ole
,"(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",
2845 locale
,flags
,xtime
,format
,date
,datelen
);
2848 locale
= LOCALE_SYSTEM_DEFAULT
;
2851 if (locale
== LOCALE_SYSTEM_DEFAULT
) {
2852 thislocale
= GetSystemDefaultLCID();
2853 } else if (locale
== LOCALE_USER_DEFAULT
) {
2854 thislocale
= GetUserDefaultLCID();
2856 thislocale
= locale
;
2859 if (xtime
== NULL
) {
2866 if (format
== NULL
) {
2867 GetLocaleInfo32A(thislocale
, ((flags
&DATE_LONGDATE
)
2869 : LOCALE_SSHORTDATE
),
2870 format_buf
, sizeof(format_buf
));
2871 thisformat
= format_buf
;
2873 thisformat
= format
;
2877 ret
= OLE_GetFormatA(thislocale
, flags
, 0, thistime
, thisformat
,
2882 "GetDateFormat32A() returning %d, with data=%s\n",
2887 /******************************************************************************
2888 * GetDateFormat32W [KERNEL32.311]
2889 * Makes a Unicode string of the date
2891 * Acts the same as GetDateFormat32A(), except that it's Unicode.
2892 * Accepts & returns sizes as counts of Unicode characters.
2895 INT32 WINAPI
GetDateFormat32W(LCID locale
,DWORD flags
,
2898 LPWSTR date
, INT32 datelen
)
2900 unsigned short datearr
[] = {'1','9','9','4','-','1','-','1',0};
2902 FIXME(ole
, "STUB (should call OLE_GetFormatW)\n");
2903 lstrcpyn32W(date
, datearr
, datelen
);
2904 return ( datelen
< 9) ? datelen
: 9;
2909 /**************************************************************************
2910 * EnumDateFormats32A (KERNEL32.198)
2912 BOOL32 WINAPI
EnumDateFormats32A(
2913 DATEFMT_ENUMPROC32A lpDateFmtEnumProc
, LCID Locale
, DWORD dwFlags
)
2915 FIXME(ole
, "Only US English supported\n");
2917 if(!lpDateFmtEnumProc
)
2919 SetLastError(ERROR_INVALID_PARAMETER
);
2925 case DATE_SHORTDATE
:
2926 if(!(*lpDateFmtEnumProc
)("M/d/yy")) return TRUE
;
2927 if(!(*lpDateFmtEnumProc
)("M/d/yyyy")) return TRUE
;
2928 if(!(*lpDateFmtEnumProc
)("MM/dd/yy")) return TRUE
;
2929 if(!(*lpDateFmtEnumProc
)("MM/dd/yyyy")) return TRUE
;
2930 if(!(*lpDateFmtEnumProc
)("yy/MM/dd")) return TRUE
;
2931 if(!(*lpDateFmtEnumProc
)("dd-MMM-yy")) return TRUE
;
2934 if(!(*lpDateFmtEnumProc
)("dddd, MMMM dd, yyyy")) return TRUE
;
2935 if(!(*lpDateFmtEnumProc
)("MMMM dd, yyyy")) return TRUE
;
2936 if(!(*lpDateFmtEnumProc
)("dddd, dd MMMM, yyyy")) return TRUE
;
2937 if(!(*lpDateFmtEnumProc
)("dd MMMM, yyyy")) return TRUE
;
2940 FIXME(ole
, "Unknown date format (%ld)\n", dwFlags
);
2941 SetLastError(ERROR_INVALID_PARAMETER
);
2946 /**************************************************************************
2947 * EnumDateFormats32W (KERNEL32.199)
2949 BOOL32 WINAPI
EnumDateFormats32W(
2950 DATEFMT_ENUMPROC32W lpDateFmtEnumProc
, LCID Locale
, DWORD dwFlags
)
2952 FIXME(ole
, "(%p, %ld, %ld): stub\n", lpDateFmtEnumProc
, Locale
, dwFlags
);
2953 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
2957 /**************************************************************************
2958 * EnumTimeFormats32A (KERNEL32.210)
2960 BOOL32 WINAPI
EnumTimeFormats32A(
2961 TIMEFMT_ENUMPROC32A lpTimeFmtEnumProc
, LCID Locale
, DWORD dwFlags
)
2963 FIXME(ole
, "Only US English supported\n");
2965 if(!lpTimeFmtEnumProc
)
2967 SetLastError(ERROR_INVALID_PARAMETER
);
2973 FIXME(ole
, "Unknown time format (%ld)\n", dwFlags
);
2976 if(!(*lpTimeFmtEnumProc
)("h:mm:ss tt")) return TRUE
;
2977 if(!(*lpTimeFmtEnumProc
)("hh:mm:ss tt")) return TRUE
;
2978 if(!(*lpTimeFmtEnumProc
)("H:mm:ss")) return TRUE
;
2979 if(!(*lpTimeFmtEnumProc
)("HH:mm:ss")) return TRUE
;
2984 /**************************************************************************
2985 * EnumTimeFormats32W (KERNEL32.211)
2987 BOOL32 WINAPI
EnumTimeFormats32W(
2988 TIMEFMT_ENUMPROC32W lpTimeFmtEnumProc
, LCID Locale
, DWORD dwFlags
)
2990 FIXME(ole
, "(%p,%ld,%ld): stub", lpTimeFmtEnumProc
, Locale
, dwFlags
);
2991 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
2995 /**************************************************************************
2996 * GetNumberFormat32A (KERNEL32.355)
2998 INT32 WINAPI
GetNumberFormat32A(LCID locale
, DWORD dwflags
,
2999 LPCSTR lpvalue
, const NUMBERFMT32A
* lpFormat
,
3000 LPSTR lpNumberStr
, int cchNumber
)
3002 FIXME(file
,"%s: stub, no reformating done\n",lpvalue
);
3004 lstrcpyn32A( lpNumberStr
, lpvalue
, cchNumber
);
3005 return cchNumber
? lstrlen32A( lpNumberStr
) : 0;
3007 /**************************************************************************
3008 * GetNumberFormat32W (KERNEL32.xxx)
3010 INT32 WINAPI
GetNumberFormat32W(LCID locale
, DWORD dwflags
,
3011 LPCWSTR lpvalue
, const NUMBERFMT32W
* lpFormat
,
3012 LPWSTR lpNumberStr
, int cchNumber
)
3014 FIXME(file
,"%s: stub, no reformating done\n",debugstr_w(lpvalue
));
3016 lstrcpyn32W( lpNumberStr
, lpvalue
, cchNumber
);
3017 return cchNumber
? lstrlen32W( lpNumberStr
) : 0;
3019 /******************************************************************************
3020 * OLE2NLS_CheckLocale [intern]
3022 static LCID
OLE2NLS_CheckLocale (LCID locale
)
3025 { locale
= LOCALE_SYSTEM_DEFAULT
;
3028 if (locale
== LOCALE_SYSTEM_DEFAULT
)
3029 { return GetSystemDefaultLCID();
3031 else if (locale
== LOCALE_USER_DEFAULT
)
3032 { return GetUserDefaultLCID();
3038 /******************************************************************************
3039 * GetTimeFormat32A [KERNEL32.422]
3040 * Makes an ASCII string of the time
3042 * Formats date according to format, or locale default if format is
3043 * NULL. The format consists of literal characters and fields as follows:
3045 * h hours with no leading zero (12-hour)
3046 * hh hours with full two digits
3047 * H hours with no leading zero (24-hour)
3048 * HH hours with full two digits
3049 * m minutes with no leading zero
3050 * mm minutes with full two digits
3051 * s seconds with no leading zero
3052 * ss seconds with full two digits
3053 * t time marker (A or P)
3054 * tt time marker (AM, PM)
3058 GetTimeFormat32A(LCID locale
, /* in */
3059 DWORD flags
, /* in */
3060 LPSYSTEMTIME xtime
, /* in */
3061 LPCSTR format
, /* in */
3062 LPSTR timestr
, /* out */
3063 INT32 timelen
/* in */)
3064 { char format_buf
[40];
3067 LPSYSTEMTIME thistime
;
3069 DWORD thisflags
=LOCALE_STIMEFORMAT
; /* standart timeformat */
3072 TRACE(ole
,"GetTimeFormat(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",locale
,flags
,xtime
,format
,timestr
,timelen
);
3074 thislocale
= OLE2NLS_CheckLocale ( locale
);
3076 if ( flags
& (TIME_NOTIMEMARKER
| TIME_FORCE24HOURFORMAT
))
3077 { FIXME(ole
,"TIME_NOTIMEMARKER or TIME_FORCE24HOURFORMAT not implemented\n");
3080 flags
&= (TIME_NOSECONDS
| TIME_NOMINUTESORSECONDS
); /* mask for OLE_GetFormatA*/
3083 { if (flags
& LOCALE_NOUSEROVERRIDE
) /*use system default*/
3084 { thislocale
= GetSystemDefaultLCID();
3086 GetLocaleInfo32A(thislocale
, thisflags
, format_buf
, sizeof(format_buf
));
3087 thisformat
= format_buf
;
3090 { thisformat
= format
;
3093 if (xtime
== NULL
) /* NULL means use the current local time*/
3094 { GetSystemTime(&t
);
3100 ret
= OLE_GetFormatA(thislocale
, thisflags
, flags
, thistime
, thisformat
,
3106 /******************************************************************************
3107 * GetTimeFormat32W [KERNEL32.423]
3108 * Makes a Unicode string of the time
3111 GetTimeFormat32W(LCID locale
, /* in */
3112 DWORD flags
, /* in */
3113 LPSYSTEMTIME xtime
, /* in */
3114 LPCWSTR format
, /* in */
3115 LPWSTR timestr
, /* out */
3116 INT32 timelen
/* in */)
3117 { WCHAR format_buf
[40];
3120 LPSYSTEMTIME thistime
;
3122 DWORD thisflags
=LOCALE_STIMEFORMAT
; /* standart timeformat */
3125 TRACE(ole
,"GetTimeFormat(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",locale
,flags
,
3126 xtime
,debugstr_w(format
),timestr
,timelen
);
3128 thislocale
= OLE2NLS_CheckLocale ( locale
);
3130 if ( flags
& (TIME_NOTIMEMARKER
| TIME_FORCE24HOURFORMAT
))
3131 { FIXME(ole
,"TIME_NOTIMEMARKER or TIME_FORCE24HOURFORMAT not implemented\n");
3134 flags
&= (TIME_NOSECONDS
| TIME_NOMINUTESORSECONDS
); /* mask for OLE_GetFormatA*/
3137 { if (flags
& LOCALE_NOUSEROVERRIDE
) /*use system default*/
3138 { thislocale
= GetSystemDefaultLCID();
3140 GetLocaleInfo32W(thislocale
, thisflags
, format_buf
, 40);
3141 thisformat
= format_buf
;
3144 { thisformat
= format
;
3147 if (xtime
== NULL
) /* NULL means use the current local time*/
3148 { GetSystemTime(&t
);
3155 ret
= OLE_GetFormatW(thislocale
, thisflags
, flags
, thistime
, thisformat
,