4 * Copyright 1995 Martin von Loewis
5 * Copyright 1998 David Lee Lambert
17 #include "debugtools.h"
21 DECLARE_DEBUG_CHANNEL(file
)
22 DECLARE_DEBUG_CHANNEL(ole
)
23 DECLARE_DEBUG_CHANNEL(string
)
24 DECLARE_DEBUG_CHANNEL(win32
)
26 struct NLS_langlocale
{
28 struct NLS_localevar
{
34 #define LANG_BEGIN(l,s) { MAKELANGID(l,s), {
36 #define LOCVAL(type,value) {type,value},
40 static const struct NLS_langlocale langlocales
[] = {
41 /* add languages in numerical order of main language (last two digits)
42 * it is much easier to find the missing holes that way */
44 LANG_BEGIN (LANG_CATALAN
, SUBLANG_DEFAULT
) /*0x0403*/
45 #include "nls/cat.nls"
48 LANG_BEGIN (LANG_CZECH
, SUBLANG_DEFAULT
) /*0x0405*/
49 #include "nls/cze.nls"
52 LANG_BEGIN (LANG_DANISH
, SUBLANG_DEFAULT
) /*0x0406*/
53 #include "nls/dan.nls"
56 LANG_BEGIN (LANG_GERMAN
, SUBLANG_GERMAN
) /*0x0407*/
57 #include "nls/deu.nls"
59 LANG_BEGIN (LANG_GERMAN
, SUBLANG_GERMAN_SWISS
) /*0x0807*/
60 #include "nls/des.nls"
62 LANG_BEGIN (LANG_GERMAN
, SUBLANG_GERMAN_AUSTRIAN
) /*0x0C07*/
63 #include "nls/dea.nls"
65 LANG_BEGIN (LANG_GERMAN
, SUBLANG_GERMAN_LUXEMBOURG
) /*0x1007*/
66 #include "nls/del.nls"
68 LANG_BEGIN (LANG_GERMAN
, SUBLANG_GERMAN_LIECHTENSTEIN
) /*0x1407*/
69 #include "nls/dec.nls"
72 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_US
) /*0x0409*/
73 #include "nls/enu.nls"
75 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_UK
) /*0x0809*/
76 #include "nls/eng.nls"
78 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_AUS
) /*0x0C09*/
79 #include "nls/ena.nls"
81 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_CAN
) /*0x1009*/
82 #include "nls/enc.nls"
84 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_NZ
) /*0x1409*/
85 #include "nls/enz.nls"
87 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_EIRE
) /*0x1809*/
88 #include "nls/irl.nls"
90 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_SAFRICA
) /*0x1C09*/
91 #include "nls/ens.nls"
93 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_JAMAICA
) /*0x2009*/
94 #include "nls/enj.nls"
96 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_CARRIBEAN
) /*0x2409*/
97 #include "nls/enb.nls"
99 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_BELIZE
) /*0x2809*/
100 #include "nls/enl.nls"
102 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_TRINIDAD
) /*0x2C09*/
103 #include "nls/ent.nls"
106 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH
) /*0x040a*/
107 #include "nls/esp.nls"
109 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_MEXICAN
) /*0x080a*/
110 #include "nls/esm.nls"
112 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_MODERN
) /*0x0C0a*/
113 #include "nls/esn.nls"
115 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_GUATEMALA
) /*0x100a*/
116 #include "nls/esg.nls"
118 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_COSTARICA
) /*0x140a*/
119 #include "nls/esc.nls"
121 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_PANAMA
) /*0x180a*/
122 #include "nls/esa.nls"
124 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_DOMINICAN
) /*0x1C0A*/
125 #include "nls/esd.nls"
127 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_VENEZUELA
) /*0x200a*/
128 #include "nls/esv.nls"
130 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_COLOMBIA
) /*0x240a*/
131 #include "nls/eso.nls"
133 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_PERU
) /*0x280a*/
134 #include "nls/esr.nls"
136 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_ARGENTINA
) /*0x2c0a*/
137 #include "nls/ess.nls"
139 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_ECUADOR
) /*0x300a*/
140 #include "nls/esf.nls"
142 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_CHILE
) /*0x340a*/
143 #include "nls/esl.nls"
145 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_URUGUAY
) /*0x380a*/
146 #include "nls/esy.nls"
148 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_PARAGUAY
) /*0x3c0a*/
149 #include "nls/esz.nls"
151 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_BOLIVIA
) /*0x400a*/
152 #include "nls/esb.nls"
154 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_EL_SALVADOR
) /*0x440a*/
155 #include "nls/ese.nls"
157 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_HONDURAS
) /*0x480a*/
158 #include "nls/esh.nls"
160 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_NICARAGUA
) /*0x4c0a*/
161 #include "nls/esi.nls"
163 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_PUERTO_RICO
) /*0x500a*/
164 #include "nls/esu.nls"
167 LANG_BEGIN (LANG_FINNISH
, SUBLANG_DEFAULT
) /*0x040B*/
168 #include "nls/fin.nls"
171 LANG_BEGIN (LANG_FRENCH
, SUBLANG_FRENCH
) /*0x040C*/
172 #include "nls/fra.nls"
174 LANG_BEGIN (LANG_FRENCH
, SUBLANG_FRENCH_BELGIAN
) /*0x080C*/
175 #include "nls/frb.nls"
177 LANG_BEGIN (LANG_FRENCH
, SUBLANG_FRENCH_CANADIAN
) /*0x0C0C*/
178 #include "nls/frc.nls"
180 LANG_BEGIN (LANG_FRENCH
, SUBLANG_FRENCH_SWISS
) /*0x100C*/
181 #include "nls/frs.nls"
183 LANG_BEGIN (LANG_FRENCH
, SUBLANG_FRENCH_LUXEMBOURG
) /*0x140C*/
184 #include "nls/frl.nls"
187 LANG_BEGIN (LANG_HUNGARIAN
, SUBLANG_DEFAULT
) /*0x040e*/
188 #include "nls/hun.nls"
191 LANG_BEGIN (LANG_ITALIAN
, SUBLANG_ITALIAN
) /*0x0410*/
192 #include "nls/ita.nls"
194 LANG_BEGIN (LANG_ITALIAN
, SUBLANG_ITALIAN_SWISS
) /*0x0810*/
195 #include "nls/its.nls"
198 LANG_BEGIN (LANG_KOREAN
, SUBLANG_KOREAN
) /*0x0412*/
199 #include "nls/kor.nls"
202 LANG_BEGIN (LANG_DUTCH
, SUBLANG_DUTCH
) /*0x0413*/
203 #include "nls/nld.nls"
205 LANG_BEGIN (LANG_DUTCH
, SUBLANG_DUTCH_BELGIAN
) /*0x0813*/
206 #include "nls/nlb.nls"
208 LANG_BEGIN (LANG_DUTCH
, SUBLANG_DUTCH_SURINAM
) /*0x0C13*/
209 #include "nls/nls.nls"
212 LANG_BEGIN (LANG_NORWEGIAN
, SUBLANG_NORWEGIAN_BOKMAL
) /*0x0414*/
213 #include "nls/nor.nls"
215 LANG_BEGIN (LANG_NORWEGIAN
, SUBLANG_NORWEGIAN_NYNORSK
) /*0x0814*/
216 #include "nls/non.nls"
219 LANG_BEGIN (LANG_POLISH
, SUBLANG_DEFAULT
) /*0x0415*/
220 #include "nls/plk.nls"
223 LANG_BEGIN (LANG_PORTUGUESE
,SUBLANG_PORTUGUESE_BRAZILIAN
) /*0x0416*/
224 #include "nls/ptb.nls"
226 LANG_BEGIN (LANG_PORTUGUESE
,SUBLANG_PORTUGUESE
) /*0x0816*/
227 #include "nls/ptg.nls"
230 LANG_BEGIN (LANG_RUSSIAN
, SUBLANG_DEFAULT
) /*0x419*/
231 #include "nls/rus.nls"
234 LANG_BEGIN (LANG_SLOVAK
, SUBLANG_DEFAULT
) /*0x041b*/
235 #include "nls/sky.nls"
238 LANG_BEGIN (LANG_SWEDISH
, SUBLANG_SWEDISH
) /*0x041d*/
239 #include "nls/sve.nls"
241 LANG_BEGIN (LANG_SWEDISH
, SUBLANG_SWEDISH_FINLAND
) /*0x081d*/
242 #include "nls/svf.nls"
245 LANG_BEGIN (LANG_THAI
, SUBLANG_DEFAULT
) /*0x41e*/
246 #include "nls/tha.nls"
249 LANG_BEGIN (LANG_ESPERANTO
, SUBLANG_DEFAULT
) /*0x048f*/
250 #include "nls/esperanto.nls"
253 LANG_BEGIN (LANG_WALON
, SUBLANG_DEFAULT
) /*0x0490*/
254 #include "nls/wal.nls"
259 /* Locale name to id map. used by EnumSystemLocales, GetLocalInfoA
260 * MUST contain all #defines from winnls.h
261 * last entry has NULL name, 0 id.
263 #define LOCALE_ENTRY(x) {#x,LOCALE_##x}
264 static struct tagLOCALE_NAME2ID
{
267 } locale_name2id
[]= {
268 LOCALE_ENTRY(ILANGUAGE
),
269 LOCALE_ENTRY(SLANGUAGE
),
270 LOCALE_ENTRY(SENGLANGUAGE
),
271 LOCALE_ENTRY(SABBREVLANGNAME
),
272 LOCALE_ENTRY(SNATIVELANGNAME
),
273 LOCALE_ENTRY(ICOUNTRY
),
274 LOCALE_ENTRY(SCOUNTRY
),
275 LOCALE_ENTRY(SENGCOUNTRY
),
276 LOCALE_ENTRY(SABBREVCTRYNAME
),
277 LOCALE_ENTRY(SNATIVECTRYNAME
),
278 LOCALE_ENTRY(IDEFAULTLANGUAGE
),
279 LOCALE_ENTRY(IDEFAULTCOUNTRY
),
280 LOCALE_ENTRY(IDEFAULTCODEPAGE
),
281 LOCALE_ENTRY(IDEFAULTANSICODEPAGE
),
282 LOCALE_ENTRY(IDEFAULTMACCODEPAGE
),
284 LOCALE_ENTRY(IMEASURE
),
285 LOCALE_ENTRY(SDECIMAL
),
286 LOCALE_ENTRY(STHOUSAND
),
287 LOCALE_ENTRY(SGROUPING
),
288 LOCALE_ENTRY(IDIGITS
),
289 LOCALE_ENTRY(ILZERO
),
290 LOCALE_ENTRY(INEGNUMBER
),
291 LOCALE_ENTRY(SNATIVEDIGITS
),
292 LOCALE_ENTRY(SCURRENCY
),
293 LOCALE_ENTRY(SINTLSYMBOL
),
294 LOCALE_ENTRY(SMONDECIMALSEP
),
295 LOCALE_ENTRY(SMONTHOUSANDSEP
),
296 LOCALE_ENTRY(SMONGROUPING
),
297 LOCALE_ENTRY(ICURRDIGITS
),
298 LOCALE_ENTRY(IINTLCURRDIGITS
),
299 LOCALE_ENTRY(ICURRENCY
),
300 LOCALE_ENTRY(INEGCURR
),
303 LOCALE_ENTRY(SSHORTDATE
),
304 LOCALE_ENTRY(SLONGDATE
),
305 LOCALE_ENTRY(STIMEFORMAT
),
307 LOCALE_ENTRY(ILDATE
),
309 LOCALE_ENTRY(ITIMEMARKPOSN
),
310 LOCALE_ENTRY(ICENTURY
),
311 LOCALE_ENTRY(ITLZERO
),
312 LOCALE_ENTRY(IDAYLZERO
),
313 LOCALE_ENTRY(IMONLZERO
),
316 LOCALE_ENTRY(ICALENDARTYPE
),
317 LOCALE_ENTRY(IOPTIONALCALENDAR
),
318 LOCALE_ENTRY(IFIRSTDAYOFWEEK
),
319 LOCALE_ENTRY(IFIRSTWEEKOFYEAR
),
320 LOCALE_ENTRY(SDAYNAME1
),
321 LOCALE_ENTRY(SDAYNAME2
),
322 LOCALE_ENTRY(SDAYNAME3
),
323 LOCALE_ENTRY(SDAYNAME4
),
324 LOCALE_ENTRY(SDAYNAME5
),
325 LOCALE_ENTRY(SDAYNAME6
),
326 LOCALE_ENTRY(SDAYNAME7
),
327 LOCALE_ENTRY(SABBREVDAYNAME1
),
328 LOCALE_ENTRY(SABBREVDAYNAME2
),
329 LOCALE_ENTRY(SABBREVDAYNAME3
),
330 LOCALE_ENTRY(SABBREVDAYNAME4
),
331 LOCALE_ENTRY(SABBREVDAYNAME5
),
332 LOCALE_ENTRY(SABBREVDAYNAME6
),
333 LOCALE_ENTRY(SABBREVDAYNAME7
),
334 LOCALE_ENTRY(SMONTHNAME1
),
335 LOCALE_ENTRY(SMONTHNAME2
),
336 LOCALE_ENTRY(SMONTHNAME3
),
337 LOCALE_ENTRY(SMONTHNAME4
),
338 LOCALE_ENTRY(SMONTHNAME5
),
339 LOCALE_ENTRY(SMONTHNAME6
),
340 LOCALE_ENTRY(SMONTHNAME7
),
341 LOCALE_ENTRY(SMONTHNAME8
),
342 LOCALE_ENTRY(SMONTHNAME9
),
343 LOCALE_ENTRY(SMONTHNAME10
),
344 LOCALE_ENTRY(SMONTHNAME11
),
345 LOCALE_ENTRY(SMONTHNAME12
),
346 LOCALE_ENTRY(SMONTHNAME13
),
347 LOCALE_ENTRY(SABBREVMONTHNAME1
),
348 LOCALE_ENTRY(SABBREVMONTHNAME2
),
349 LOCALE_ENTRY(SABBREVMONTHNAME3
),
350 LOCALE_ENTRY(SABBREVMONTHNAME4
),
351 LOCALE_ENTRY(SABBREVMONTHNAME5
),
352 LOCALE_ENTRY(SABBREVMONTHNAME6
),
353 LOCALE_ENTRY(SABBREVMONTHNAME7
),
354 LOCALE_ENTRY(SABBREVMONTHNAME8
),
355 LOCALE_ENTRY(SABBREVMONTHNAME9
),
356 LOCALE_ENTRY(SABBREVMONTHNAME10
),
357 LOCALE_ENTRY(SABBREVMONTHNAME11
),
358 LOCALE_ENTRY(SABBREVMONTHNAME12
),
359 LOCALE_ENTRY(SABBREVMONTHNAME13
),
360 LOCALE_ENTRY(SPOSITIVESIGN
),
361 LOCALE_ENTRY(SNEGATIVESIGN
),
362 LOCALE_ENTRY(IPOSSIGNPOSN
),
363 LOCALE_ENTRY(INEGSIGNPOSN
),
364 LOCALE_ENTRY(IPOSSYMPRECEDES
),
365 LOCALE_ENTRY(IPOSSEPBYSPACE
),
366 LOCALE_ENTRY(INEGSYMPRECEDES
),
367 LOCALE_ENTRY(INEGSEPBYSPACE
),
368 LOCALE_ENTRY(FONTSIGNATURE
),
369 LOCALE_ENTRY(SISO639LANGNAME
),
370 LOCALE_ENTRY(SISO3166CTRYNAME
),
374 const struct map_lcid2str
{
376 const char *langname
;
378 {0x0401,"Arabic (Saudi Arabia)"},
379 {0x0801,"Arabic (Iraq)"},
380 {0x0c01,"Arabic (Egypt)"},
381 {0x1001,"Arabic (Libya)"},
382 {0x1401,"Arabic (Algeria)"},
383 {0x1801,"Arabic (Morocco)"},
384 {0x1c01,"Arabic (Tunisia)"},
385 {0x2001,"Arabic (Oman)"},
386 {0x2401,"Arabic (Yemen)"},
387 {0x2801,"Arabic (Syria)"},
388 {0x2c01,"Arabic (Jordan)"},
389 {0x3001,"Arabic (Lebanon)"},
390 {0x3401,"Arabic (Kuwait)"},
391 {0x3801,"Arabic (United Arab Emirates)"},
392 {0x3c01,"Arabic (Bahrain)"},
393 {0x4001,"Arabic (Qatar)"},
394 {0x0402,"Bulgarian"},
396 {0x0404,"Chinese (Taiwan)"},
397 {0x0804,"Chinese (People's Republic of China)"},
398 {0x0c04,"Chinese (Hong Kong)"},
399 {0x1004,"Chinese (Singapore)"},
400 {0x1404,"Chinese (Macau)"},
403 {0x0407,"German (Germany)"},
404 {0x0807,"German (Switzerland)"},
405 {0x0c07,"German (Austria)"},
406 {0x1007,"German (Luxembourg)"},
407 {0x1407,"German (Liechtenstein)"},
409 {0x0409,"English (United States)"},
410 {0x0809,"English (United Kingdom)"},
411 {0x0c09,"English (Australia)"},
412 {0x1009,"English (Canada)"},
413 {0x1409,"English (New Zealand)"},
414 {0x1809,"English (Ireland)"},
415 {0x1c09,"English (South Africa)"},
416 {0x2009,"English (Jamaica)"},
417 {0x2409,"English (Caribbean)"},
418 {0x2809,"English (Belize)"},
419 {0x2c09,"English (Trinidad)"},
420 {0x3009,"English (Zimbabwe)"},
421 {0x3409,"English (Philippines)"},
422 {0x040a,"Spanish (Spain, traditional sorting)"},
423 {0x080a,"Spanish (Mexico)"},
424 {0x0c0a,"Spanish (Spain, international sorting)"},
425 {0x100a,"Spanish (Guatemala)"},
426 {0x140a,"Spanish (Costa Rica)"},
427 {0x180a,"Spanish (Panama)"},
428 {0x1c0a,"Spanish (Dominican Republic)"},
429 {0x200a,"Spanish (Venezuela)"},
430 {0x240a,"Spanish (Colombia)"},
431 {0x280a,"Spanish (Peru)"},
432 {0x2c0a,"Spanish (Argentina)"},
433 {0x300a,"Spanish (Ecuador)"},
434 {0x340a,"Spanish (Chile)"},
435 {0x380a,"Spanish (Uruguay)"},
436 {0x3c0a,"Spanish (Paraguay)"},
437 {0x400a,"Spanish (Bolivia)"},
438 {0x440a,"Spanish (El Salvador)"},
439 {0x480a,"Spanish (Honduras)"},
440 {0x4c0a,"Spanish (Nicaragua)"},
441 {0x500a,"Spanish (Puerto Rico)"},
443 {0x040c,"French (France)"},
444 {0x080c,"French (Belgium)"},
445 {0x0c0c,"French (Canada)"},
446 {0x100c,"French (Switzerland)"},
447 {0x140c,"French (Luxembourg)"},
448 {0x180c,"French (Monaco)"},
450 {0x040e,"Hungarian"},
451 {0x040f,"Icelandic"},
452 {0x0410,"Italian (Italy)"},
453 {0x0810,"Italian (Switzerland)"},
455 {0x0412,"Korean (Wansung)"},
456 {0x0812,"Korean (Johab)"},
457 {0x0413,"Dutch (Netherlands)"},
458 {0x0813,"Dutch (Belgium)"},
459 {0x0414,"Norwegian (Bokmal)"},
460 {0x0814,"Norwegian (Nynorsk)"},
462 {0x0416,"Portuguese (Brazil)"},
463 {0x0816,"Portuguese (Portugal)"},
464 {0x0417,"Rhaeto Romanic"},
466 {0x0818,"Moldavian"},
467 {0x0419,"Russian (Russia)"},
468 {0x0819,"Russian (Moldavia)"},
470 {0x081a,"Serbian (latin)"},
471 {0x0c1a,"Serbian (cyrillic)"},
474 {0x041d,"Swedish (Sweden)"},
475 {0x081d,"Swedish (Finland)"},
479 {0x0421,"Indonesian"},
480 {0x0422,"Ukrainian"},
481 {0x0423,"Belarusian"},
485 {0x0427,"Lithuanian (modern)"},
486 {0x0827,"Lithuanian (classic)"},
489 {0x042a,"Vietnamese"},
491 {0x042c,"Azeri (latin)"},
492 {0x082c,"Azeri (cyrillic)"},
495 {0x042f,"Macedonian"},
502 {0x0436,"Afrikaans"},
508 {0x043c,"Irish gaelic"},
509 {0x083c,"Scottish gaelic"},
510 {0x043e,"Malay (Malaysia)"},
511 {0x083e,"Malay (Brunei Darussalam)"},
514 {0x0443,"Uzbek (latin)"},
515 {0x0843,"Uzbek (cyrillic)"},
524 {0x044c,"Malayalam"},
529 {0x048f,"Esperanto"}, /* Non official */
530 {0x0490,"Walon"}, /* Non official */
534 {0x0402,"Bulgarisch"},
535 {0x0403,"Katalanisch"},
536 {0x0404,"Traditionales Chinesisch"},
537 {0x0405,"Tschecisch"},
540 {0x0408,"Griechisch"},
541 {0x0409,"Amerikanisches Englisch"},
542 {0x040A,"Kastilisches Spanisch"},
544 {0x040C,"Franzvsisch"},
545 {0x040D,"Hebrdisch"},
546 {0x040E,"Ungarisch"},
547 {0x040F,"Isldndisch"},
548 {0x0410,"Italienisch"},
549 {0x0411,"Japanisch"},
550 {0x0412,"Koreanisch"},
551 {0x0413,"Niederldndisch"},
552 {0x0414,"Norwegisch-Bokmal"},
554 {0x0416,"Brasilianisches Portugiesisch"},
555 {0x0417,"Rdtoromanisch"},
556 {0x0418,"Rumdnisch"},
558 {0x041A,"Kroatoserbisch (lateinisch)"},
559 {0x041B,"Slowenisch"},
560 {0x041C,"Albanisch"},
561 {0x041D,"Schwedisch"},
566 {0x0804,"Vereinfachtes Chinesisch"},
567 {0x0807,"Schweizerdeutsch"},
568 {0x0809,"Britisches Englisch"},
569 {0x080A,"Mexikanisches Spanisch"},
570 {0x080C,"Belgisches Franzvsisch"},
571 {0x0810,"Schweizerisches Italienisch"},
572 {0x0813,"Belgisches Niederldndisch"},
573 {0x0814,"Norgwegisch-Nynorsk"},
574 {0x0816,"Portugiesisch"},
575 {0x081A,"Serbokratisch (kyrillisch)"},
576 {0x0C1C,"Kanadisches Franzvsisch"},
577 {0x100C,"Schweizerisches Franzvsisch"},
578 {0x0000,"Unbekannt"},
581 /***********************************************************************
582 * GetUserDefaultLCID (OLE2NLS.1)
584 LCID WINAPI
GetUserDefaultLCID()
586 return MAKELCID( GetUserDefaultLangID() , SORT_DEFAULT
);
589 /***********************************************************************
590 * GetSystemDefaultLCID (OLE2NLS.2)
592 LCID WINAPI
GetSystemDefaultLCID()
594 return GetUserDefaultLCID();
597 /***********************************************************************
598 * GetUserDefaultLangID (OLE2NLS.3)
600 LANGID WINAPI
GetUserDefaultLangID()
602 /* caching result, if defined from environment, which should (?) not change during a WINE session */
603 static LANGID userLCID
= 0;
604 if (Options
.language
) {
605 return Languages
[Options
.language
].langid
;
610 char *lang
,*country
,*charset
,*dialect
,*next
;
613 buf
=getenv("LANGUAGE");
614 if (!buf
) buf
=getenv("LANG");
615 if (!buf
) buf
=getenv("LC_ALL");
616 if (!buf
) buf
=getenv("LC_MESSAGES");
617 if (!buf
) buf
=getenv("LC_CTYPE");
618 if (!buf
) return userLCID
= MAKELANGID( LANG_ENGLISH
, SUBLANG_DEFAULT
);
620 if (!strcmp(buf
,"POSIX") || !strcmp(buf
,"C")) {
621 return MAKELANGID( LANG_ENGLISH
, SUBLANG_DEFAULT
);
627 next
=strchr(lang
,':'); if (next
) *next
++='\0';
628 dialect
=strchr(lang
,'@'); if (dialect
) *dialect
++='\0';
629 charset
=strchr(lang
,'.'); if (charset
) *charset
++='\0';
630 country
=strchr(lang
,'_'); if (country
) *country
++='\0';
632 ret
=MAIN_GetLanguageID(lang
, country
, charset
, dialect
);
636 } while (lang
&& !ret
);
638 /* FIXME : are strings returned by getenv() to be free()'ed ? */
639 userLCID
= (LANGID
)ret
;
644 /***********************************************************************
645 * GetSystemDefaultLangID (OLE2NLS.4)
647 LANGID WINAPI
GetSystemDefaultLangID()
649 return GetUserDefaultLangID();
652 /******************************************************************************
653 * GetLocaleInfo16 [OLE2NLS.5]
654 * Is the last parameter really WORD for Win16?
656 INT16 WINAPI
GetLocaleInfo16(LCID lcid
,LCTYPE LCType
,LPSTR buf
,INT16 len
)
658 return GetLocaleInfoA(lcid
,LCType
,buf
,len
);
660 /******************************************************************************
661 * ConvertDefaultLocale32 [KERNEL32.147]
663 LCID WINAPI
ConvertDefaultLocale32 (LCID lcid
)
665 { case LOCALE_SYSTEM_DEFAULT
:
666 return GetSystemDefaultLCID();
667 case LOCALE_USER_DEFAULT
:
668 return GetUserDefaultLCID();
670 return MAKELCID (LANG_NEUTRAL
, SUBLANG_NEUTRAL
);
672 return MAKELANGID( PRIMARYLANGID(lcid
), SUBLANG_NEUTRAL
);
674 /******************************************************************************
675 * GetLocaleInfo32A [KERNEL32.342]
678 * LANG_NEUTRAL is equal to LOCALE_SYSTEM_DEFAULT
680 * MS online documentation states that the string returned is NULL terminated
681 * except for LOCALE_FONTSIGNATURE which "will return a non-NULL
682 * terminated string".
684 INT WINAPI
GetLocaleInfoA(LCID lcid
,LCTYPE LCType
,LPSTR buf
,INT len
)
690 TRACE_(ole
)("(lcid=0x%lx,lctype=0x%lx,%p,%x)\n",lcid
,LCType
,buf
,len
);
692 if (len
&& (! buf
) ) {
693 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
697 if (lcid
==0 || lcid
== LANG_SYSTEM_DEFAULT
|| (LCType
& LOCALE_NOUSEROVERRIDE
) ) /* 0x00, 0x400 */
699 lcid
= GetSystemDefaultLCID();
701 else if (lcid
== LANG_USER_DEFAULT
) /*0x800*/
703 lcid
= GetUserDefaultLCID();
705 LCType
&= ~(LOCALE_NOUSEROVERRIDE
|LOCALE_USE_CP_ACP
);
707 /* As an option, we could obtain the value from win.ini.
708 This would not match the Wine compile-time option.
709 Also, not all identifiers are available from win.ini */
711 /* If we are through all of this, retLen should not be zero anymore.
712 If it is, the value is not supported */
714 while (locale_name2id
[i
].name
!=NULL
) {
715 if (LCType
== locale_name2id
[i
].id
) {
716 retString
= locale_name2id
[i
].name
;
722 FIXME_(ole
)("Unkown LC type %lX\n",LCType
);
727 for (i
=0;(i
<3 && !found
);i
++) {
730 for (j
=0;j
<sizeof(langlocales
)/sizeof(langlocales
[0]);j
++) {
731 if (langlocales
[j
].lang
== lang
) {
734 for (k
=0;k
<sizeof(langlocales
[j
].locvars
)/sizeof(langlocales
[j
].locvars
[0]) && (langlocales
[j
].locvars
[k
].type
);k
++) {
735 if (langlocales
[j
].locvars
[k
].type
== LCType
) {
737 retString
= langlocales
[j
].locvars
[k
].val
;
745 /* language not found, try without a sublanguage*/
746 if (i
==1) lang
=MAKELANGID( PRIMARYLANGID(lang
), SUBLANG_DEFAULT
);
747 /* mask the LC Value */
748 if (i
==2) LCType
&= 0xfff;
752 ERR_(ole
)("'%s' not supported for your language (%04X).\n",
753 retString
,(WORD
)lcid
);
754 SetLastError(ERROR_INVALID_PARAMETER
);
757 /* a FONTSIGNATURE is not a string, just 6 DWORDs */
758 if (LCType
== LOCALE_FONTSIGNATURE
) {
760 memcpy(buf
, retString
, (len
<=sizeof(FONTSIGNATURE
))?len
:sizeof(FONTSIGNATURE
));
761 return sizeof(FONTSIGNATURE
);
763 /* if len=0 return only the length, don't touch the buffer*/
764 if (len
) lstrcpynA(buf
,retString
,len
);
765 return strlen(retString
)+1;
768 /******************************************************************************
769 * GetLocaleInfo32W [KERNEL32.343]
772 * MS documentation states that len "specifies the size, in bytes (ANSI version)
773 * or characters (Unicode version), of" wbuf. Thus the number returned is
774 * the same between GetLocaleInfo32W and GetLocaleInfo32A.
776 INT WINAPI
GetLocaleInfoW(LCID lcid
,LCTYPE LCType
,LPWSTR wbuf
,INT len
)
780 if (len
&& (! wbuf
) )
781 { SetLastError(ERROR_INSUFFICIENT_BUFFER
);
785 abuf
= (LPSTR
)HeapAlloc(GetProcessHeap(),0,len
);
786 wlen
= GetLocaleInfoA(lcid
, LCType
, abuf
, len
);
788 if (wlen
&& len
) /* if len=0 return only the length*/
789 lstrcpynAtoW(wbuf
,abuf
,len
);
791 HeapFree(GetProcessHeap(),0,abuf
);
795 /******************************************************************************
796 * SetLocaleInfoA [KERNEL32.656]
798 BOOL16 WINAPI
SetLocaleInfoA(DWORD lcid
, DWORD lctype
, LPCSTR data
)
800 FIXME_(ole
)("(%ld,%ld,%s): stub\n",lcid
,lctype
,data
);
804 /******************************************************************************
805 * IsValidLocale [KERNEL32.489]
807 BOOL WINAPI
IsValidLocale(LCID lcid
,DWORD flags
)
809 /* we support ANY language. Well, at least say that...*/
813 /******************************************************************************
814 * EnumSystemLocales32W [KERNEL32.209]
816 BOOL WINAPI
EnumSystemLocalesW( LOCALE_ENUMPROCW lpfnLocaleEnum
,
824 TRACE_(win32
)("(%p,%08lx)\n",lpfnLocaleEnum
,flags
);
825 /* see if we can reuse the Win95 registry entries.... */
826 if (ERROR_SUCCESS
==RegOpenKeyA(HKEY_LOCAL_MACHINE
,"System\\CurrentControlSet\\control\\Nls\\Locale\\",&xhkey
)) {
829 if (ERROR_SUCCESS
!=RegEnumKeyW(xhkey
,i
,buffer
,sizeof(buffer
)))
831 if (!lpfnLocaleEnum(buffer
))
840 while (languages
[i
].langid
!=0)
845 sprintf(xbuffer
,"%08lx",(DWORD
)languages
[i
].langid
);
847 cp
= HEAP_strdupAtoW( GetProcessHeap(), 0, xbuffer
);
848 ret
= lpfnLocaleEnum(cp
);
849 HeapFree( GetProcessHeap(), 0, cp
);
856 /******************************************************************************
857 * EnumSystemLocales32A [KERNEL32.208]
859 BOOL WINAPI
EnumSystemLocalesA(LOCALE_ENUMPROCA lpfnLocaleEnum
,
866 TRACE_(win32
)("(%p,%08lx)\n",
869 if (ERROR_SUCCESS
==RegOpenKeyA(HKEY_LOCAL_MACHINE
,"System\\CurrentControlSet\\control\\Nls\\Locale\\",&xhkey
)) {
872 if (ERROR_SUCCESS
!=RegEnumKeyA(xhkey
,i
,buffer
,sizeof(buffer
)))
874 if (!lpfnLocaleEnum(buffer
))
882 while (languages
[i
].langid
!=0) {
883 sprintf(buffer
,"%08lx",(DWORD
)languages
[i
].langid
);
884 if (!lpfnLocaleEnum(buffer
))
891 static const unsigned char CT_CType2_LUT
[] = {
892 C2_NOTAPPLICABLE
, /* - 0 */
893 C2_NOTAPPLICABLE
, /* - 1 */
894 C2_NOTAPPLICABLE
, /* - 2 */
895 C2_NOTAPPLICABLE
, /* - 3 */
896 C2_NOTAPPLICABLE
, /* - 4 */
897 C2_NOTAPPLICABLE
, /* - 5 */
898 C2_NOTAPPLICABLE
, /* - 6 */
899 C2_NOTAPPLICABLE
, /* - 7 */
900 C2_NOTAPPLICABLE
, /* - 8 */
901 C2_SEGMENTSEPARATOR
, /* - 9 */
902 C2_NOTAPPLICABLE
, /* - 10 */
903 C2_NOTAPPLICABLE
, /* - 11 */
904 C2_NOTAPPLICABLE
, /* - 12 */
905 C2_NOTAPPLICABLE
, /* - 13 */
906 C2_NOTAPPLICABLE
, /* - 14 */
907 C2_NOTAPPLICABLE
, /* - 15 */
908 C2_NOTAPPLICABLE
, /* - 16 */
909 C2_NOTAPPLICABLE
, /* - 17 */
910 C2_NOTAPPLICABLE
, /* - 18 */
911 C2_NOTAPPLICABLE
, /* - 19 */
912 C2_NOTAPPLICABLE
, /* - 20 */
913 C2_NOTAPPLICABLE
, /* - 21 */
914 C2_NOTAPPLICABLE
, /* - 22 */
915 C2_NOTAPPLICABLE
, /* - 23 */
916 C2_NOTAPPLICABLE
, /* - 24 */
917 C2_NOTAPPLICABLE
, /* - 25 */
918 C2_NOTAPPLICABLE
, /* - 26 */
919 C2_NOTAPPLICABLE
, /* - 27 */
920 C2_NOTAPPLICABLE
, /* - 28 */
921 C2_NOTAPPLICABLE
, /* - 29 */
922 C2_NOTAPPLICABLE
, /* - 30 */
923 C2_NOTAPPLICABLE
, /* - 31 */
924 C2_WHITESPACE
, /* - 32 */
925 C2_OTHERNEUTRAL
, /* ! - 33 */
926 C2_OTHERNEUTRAL
, /* " - 34 */ /* " */
927 C2_EUROPETERMINATOR
, /* # - 35 */
928 C2_EUROPETERMINATOR
, /* $ - 36 */
929 C2_EUROPETERMINATOR
, /* % - 37 */
930 C2_LEFTTORIGHT
, /* & - 38 */
931 C2_OTHERNEUTRAL
, /* ' - 39 */
932 C2_OTHERNEUTRAL
, /* ( - 40 */
933 C2_OTHERNEUTRAL
, /* ) - 41 */
934 C2_OTHERNEUTRAL
, /* * - 42 */
935 C2_EUROPETERMINATOR
, /* + - 43 */
936 C2_COMMONSEPARATOR
, /* , - 44 */
937 C2_EUROPETERMINATOR
, /* - - 45 */
938 C2_EUROPESEPARATOR
, /* . - 46 */
939 C2_EUROPESEPARATOR
, /* / - 47 */
940 C2_EUROPENUMBER
, /* 0 - 48 */
941 C2_EUROPENUMBER
, /* 1 - 49 */
942 C2_EUROPENUMBER
, /* 2 - 50 */
943 C2_EUROPENUMBER
, /* 3 - 51 */
944 C2_EUROPENUMBER
, /* 4 - 52 */
945 C2_EUROPENUMBER
, /* 5 - 53 */
946 C2_EUROPENUMBER
, /* 6 - 54 */
947 C2_EUROPENUMBER
, /* 7 - 55 */
948 C2_EUROPENUMBER
, /* 8 - 56 */
949 C2_EUROPENUMBER
, /* 9 - 57 */
950 C2_COMMONSEPARATOR
, /* : - 58 */
951 C2_OTHERNEUTRAL
, /* ; - 59 */
952 C2_OTHERNEUTRAL
, /* < - 60 */
953 C2_OTHERNEUTRAL
, /* = - 61 */
954 C2_OTHERNEUTRAL
, /* > - 62 */
955 C2_OTHERNEUTRAL
, /* ? - 63 */
956 C2_LEFTTORIGHT
, /* @ - 64 */
957 C2_LEFTTORIGHT
, /* A - 65 */
958 C2_LEFTTORIGHT
, /* B - 66 */
959 C2_LEFTTORIGHT
, /* C - 67 */
960 C2_LEFTTORIGHT
, /* D - 68 */
961 C2_LEFTTORIGHT
, /* E - 69 */
962 C2_LEFTTORIGHT
, /* F - 70 */
963 C2_LEFTTORIGHT
, /* G - 71 */
964 C2_LEFTTORIGHT
, /* H - 72 */
965 C2_LEFTTORIGHT
, /* I - 73 */
966 C2_LEFTTORIGHT
, /* J - 74 */
967 C2_LEFTTORIGHT
, /* K - 75 */
968 C2_LEFTTORIGHT
, /* L - 76 */
969 C2_LEFTTORIGHT
, /* M - 77 */
970 C2_LEFTTORIGHT
, /* N - 78 */
971 C2_LEFTTORIGHT
, /* O - 79 */
972 C2_LEFTTORIGHT
, /* P - 80 */
973 C2_LEFTTORIGHT
, /* Q - 81 */
974 C2_LEFTTORIGHT
, /* R - 82 */
975 C2_LEFTTORIGHT
, /* S - 83 */
976 C2_LEFTTORIGHT
, /* T - 84 */
977 C2_LEFTTORIGHT
, /* U - 85 */
978 C2_LEFTTORIGHT
, /* V - 86 */
979 C2_LEFTTORIGHT
, /* W - 87 */
980 C2_LEFTTORIGHT
, /* X - 88 */
981 C2_LEFTTORIGHT
, /* Y - 89 */
982 C2_LEFTTORIGHT
, /* Z - 90 */
983 C2_OTHERNEUTRAL
, /* [ - 91 */
984 C2_OTHERNEUTRAL
, /* \ - 92 */
985 C2_OTHERNEUTRAL
, /* ] - 93 */
986 C2_OTHERNEUTRAL
, /* ^ - 94 */
987 C2_OTHERNEUTRAL
, /* _ - 95 */
988 C2_OTHERNEUTRAL
, /* ` - 96 */
989 C2_LEFTTORIGHT
, /* a - 97 */
990 C2_LEFTTORIGHT
, /* b - 98 */
991 C2_LEFTTORIGHT
, /* c - 99 */
992 C2_LEFTTORIGHT
, /* d - 100 */
993 C2_LEFTTORIGHT
, /* e - 101 */
994 C2_LEFTTORIGHT
, /* f - 102 */
995 C2_LEFTTORIGHT
, /* g - 103 */
996 C2_LEFTTORIGHT
, /* h - 104 */
997 C2_LEFTTORIGHT
, /* i - 105 */
998 C2_LEFTTORIGHT
, /* j - 106 */
999 C2_LEFTTORIGHT
, /* k - 107 */
1000 C2_LEFTTORIGHT
, /* l - 108 */
1001 C2_LEFTTORIGHT
, /* m - 109 */
1002 C2_LEFTTORIGHT
, /* n - 110 */
1003 C2_LEFTTORIGHT
, /* o - 111 */
1004 C2_LEFTTORIGHT
, /* p - 112 */
1005 C2_LEFTTORIGHT
, /* q - 113 */
1006 C2_LEFTTORIGHT
, /* r - 114 */
1007 C2_LEFTTORIGHT
, /* s - 115 */
1008 C2_LEFTTORIGHT
, /* t - 116 */
1009 C2_LEFTTORIGHT
, /* u - 117 */
1010 C2_LEFTTORIGHT
, /* v - 118 */
1011 C2_LEFTTORIGHT
, /* w - 119 */
1012 C2_LEFTTORIGHT
, /* x - 120 */
1013 C2_LEFTTORIGHT
, /* y - 121 */
1014 C2_LEFTTORIGHT
, /* z - 122 */
1015 C2_OTHERNEUTRAL
, /* { - 123 */
1016 C2_OTHERNEUTRAL
, /* | - 124 */
1017 C2_OTHERNEUTRAL
, /* } - 125 */
1018 C2_OTHERNEUTRAL
, /* ~ - 126 */
1019 C2_NOTAPPLICABLE
, /* \x7f - 127 */
1020 C2_NOTAPPLICABLE
, /* € - 128 */
1021 C2_NOTAPPLICABLE
, /* � - 129 */
1022 C2_OTHERNEUTRAL
, /* ‚ - 130 */
1023 C2_LEFTTORIGHT
, /* ƒ - 131 */
1024 C2_OTHERNEUTRAL
, /* „ - 132 */
1025 C2_OTHERNEUTRAL
, /* … - 133 */
1026 C2_OTHERNEUTRAL
, /* † - 134 */
1027 C2_OTHERNEUTRAL
, /* ‡ - 135 */
1028 C2_LEFTTORIGHT
, /* ˆ - 136 */
1029 C2_EUROPETERMINATOR
, /* ‰ - 137 */
1030 C2_LEFTTORIGHT
, /* Š - 138 */
1031 C2_OTHERNEUTRAL
, /* ‹ - 139 */
1032 C2_LEFTTORIGHT
, /* Œ - 140 */
1033 C2_NOTAPPLICABLE
, /* � - 141 */
1034 C2_NOTAPPLICABLE
, /* Ž - 142 */
1035 C2_NOTAPPLICABLE
, /* � - 143 */
1036 C2_NOTAPPLICABLE
, /* � - 144 */
1037 C2_OTHERNEUTRAL
, /* ‘ - 145 */
1038 C2_OTHERNEUTRAL
, /* ’ - 146 */
1039 C2_OTHERNEUTRAL
, /* “ - 147 */
1040 C2_OTHERNEUTRAL
, /* ” - 148 */
1041 C2_OTHERNEUTRAL
, /* • - 149 */
1042 C2_OTHERNEUTRAL
, /* – - 150 */
1043 C2_OTHERNEUTRAL
, /* — - 151 */
1044 C2_LEFTTORIGHT
, /* ˜ - 152 */
1045 C2_OTHERNEUTRAL
, /* ™ - 153 */
1046 C2_LEFTTORIGHT
, /* š - 154 */
1047 C2_OTHERNEUTRAL
, /* › - 155 */
1048 C2_LEFTTORIGHT
, /* œ - 156 */
1049 C2_NOTAPPLICABLE
, /* � - 157 */
1050 C2_NOTAPPLICABLE
, /* ž - 158 */
1051 C2_LEFTTORIGHT
, /* Ÿ - 159 */
1052 C2_WHITESPACE
, /* - 160 */
1053 C2_OTHERNEUTRAL
, /* ¡ - 161 */
1054 C2_EUROPETERMINATOR
, /* ¢ - 162 */
1055 C2_EUROPETERMINATOR
, /* £ - 163 */
1056 C2_EUROPETERMINATOR
, /* ¤ - 164 */
1057 C2_EUROPETERMINATOR
, /* ¥ - 165 */
1058 C2_OTHERNEUTRAL
, /* ¦ - 166 */
1059 C2_OTHERNEUTRAL
, /* § - 167 */
1060 C2_OTHERNEUTRAL
, /* ¨ - 168 */
1061 C2_OTHERNEUTRAL
, /* © - 169 */
1062 C2_OTHERNEUTRAL
, /* ª - 170 */
1063 C2_OTHERNEUTRAL
, /* « - 171 */
1064 C2_OTHERNEUTRAL
, /* ¬ - 172 */
1065 C2_OTHERNEUTRAL
, /* - 173 */
1066 C2_OTHERNEUTRAL
, /* ® - 174 */
1067 C2_OTHERNEUTRAL
, /* ¯ - 175 */
1068 C2_EUROPETERMINATOR
, /* ° - 176 */
1069 C2_EUROPETERMINATOR
, /* ± - 177 */
1070 C2_EUROPENUMBER
, /* ² - 178 */
1071 C2_EUROPENUMBER
, /* ³ - 179 */
1072 C2_OTHERNEUTRAL
, /* ´ - 180 */
1073 C2_OTHERNEUTRAL
, /* µ - 181 */
1074 C2_OTHERNEUTRAL
, /* ¶ - 182 */
1075 C2_OTHERNEUTRAL
, /* · - 183 */
1076 C2_OTHERNEUTRAL
, /* ¸ - 184 */
1077 C2_EUROPENUMBER
, /* ¹ - 185 */
1078 C2_OTHERNEUTRAL
, /* º - 186 */
1079 C2_OTHERNEUTRAL
, /* » - 187 */
1080 C2_OTHERNEUTRAL
, /* ¼ - 188 */
1081 C2_OTHERNEUTRAL
, /* ½ - 189 */
1082 C2_OTHERNEUTRAL
, /* ¾ - 190 */
1083 C2_OTHERNEUTRAL
, /* ¿ - 191 */
1084 C2_LEFTTORIGHT
, /* À - 192 */
1085 C2_LEFTTORIGHT
, /* Á - 193 */
1086 C2_LEFTTORIGHT
, /* Â - 194 */
1087 C2_LEFTTORIGHT
, /* Ã - 195 */
1088 C2_LEFTTORIGHT
, /* Ä - 196 */
1089 C2_LEFTTORIGHT
, /* Å - 197 */
1090 C2_LEFTTORIGHT
, /* Æ - 198 */
1091 C2_LEFTTORIGHT
, /* Ç - 199 */
1092 C2_LEFTTORIGHT
, /* È - 200 */
1093 C2_LEFTTORIGHT
, /* É - 201 */
1094 C2_LEFTTORIGHT
, /* Ê - 202 */
1095 C2_LEFTTORIGHT
, /* Ë - 203 */
1096 C2_LEFTTORIGHT
, /* Ì - 204 */
1097 C2_LEFTTORIGHT
, /* Í - 205 */
1098 C2_LEFTTORIGHT
, /* Î - 206 */
1099 C2_LEFTTORIGHT
, /* Ï - 207 */
1100 C2_LEFTTORIGHT
, /* Ð - 208 */
1101 C2_LEFTTORIGHT
, /* Ñ - 209 */
1102 C2_LEFTTORIGHT
, /* Ò - 210 */
1103 C2_LEFTTORIGHT
, /* Ó - 211 */
1104 C2_LEFTTORIGHT
, /* Ô - 212 */
1105 C2_LEFTTORIGHT
, /* Õ - 213 */
1106 C2_LEFTTORIGHT
, /* Ö - 214 */
1107 C2_OTHERNEUTRAL
, /* × - 215 */
1108 C2_LEFTTORIGHT
, /* Ø - 216 */
1109 C2_LEFTTORIGHT
, /* Ù - 217 */
1110 C2_LEFTTORIGHT
, /* Ú - 218 */
1111 C2_LEFTTORIGHT
, /* Û - 219 */
1112 C2_LEFTTORIGHT
, /* Ü - 220 */
1113 C2_LEFTTORIGHT
, /* Ý - 221 */
1114 C2_LEFTTORIGHT
, /* Þ - 222 */
1115 C2_LEFTTORIGHT
, /* ß - 223 */
1116 C2_LEFTTORIGHT
, /* à - 224 */
1117 C2_LEFTTORIGHT
, /* á - 225 */
1118 C2_LEFTTORIGHT
, /* â - 226 */
1119 C2_LEFTTORIGHT
, /* ã - 227 */
1120 C2_LEFTTORIGHT
, /* ä - 228 */
1121 C2_LEFTTORIGHT
, /* å - 229 */
1122 C2_LEFTTORIGHT
, /* æ - 230 */
1123 C2_LEFTTORIGHT
, /* ç - 231 */
1124 C2_LEFTTORIGHT
, /* è - 232 */
1125 C2_LEFTTORIGHT
, /* é - 233 */
1126 C2_LEFTTORIGHT
, /* ê - 234 */
1127 C2_LEFTTORIGHT
, /* ë - 235 */
1128 C2_LEFTTORIGHT
, /* ì - 236 */
1129 C2_LEFTTORIGHT
, /* í - 237 */
1130 C2_LEFTTORIGHT
, /* î - 238 */
1131 C2_LEFTTORIGHT
, /* ï - 239 */
1132 C2_LEFTTORIGHT
, /* ð - 240 */
1133 C2_LEFTTORIGHT
, /* ñ - 241 */
1134 C2_LEFTTORIGHT
, /* ò - 242 */
1135 C2_LEFTTORIGHT
, /* ó - 243 */
1136 C2_LEFTTORIGHT
, /* ô - 244 */
1137 C2_LEFTTORIGHT
, /* õ - 245 */
1138 C2_LEFTTORIGHT
, /* ö - 246 */
1139 C2_OTHERNEUTRAL
, /* ÷ - 247 */
1140 C2_LEFTTORIGHT
, /* ø - 248 */
1141 C2_LEFTTORIGHT
, /* ù - 249 */
1142 C2_LEFTTORIGHT
, /* ú - 250 */
1143 C2_LEFTTORIGHT
, /* û - 251 */
1144 C2_LEFTTORIGHT
, /* ü - 252 */
1145 C2_LEFTTORIGHT
, /* ý - 253 */
1146 C2_LEFTTORIGHT
, /* þ - 254 */
1147 C2_LEFTTORIGHT
/* ÿ - 255 */
1150 const WORD OLE2NLS_CT_CType3_LUT
[] = {
1184 0x0048, /* ! - 33 */
1185 0x0448, /* " - 34 */ /* " */
1186 0x0048, /* # - 35 */
1187 0x0448, /* $ - 36 */
1188 0x0048, /* % - 37 */
1189 0x0048, /* & - 38 */
1190 0x0440, /* ' - 39 */
1191 0x0048, /* ( - 40 */
1192 0x0048, /* ) - 41 */
1193 0x0048, /* * - 42 */
1194 0x0048, /* + - 43 */
1195 0x0048, /* , - 44 */
1196 0x0440, /* - - 45 */
1197 0x0048, /* . - 46 */
1198 0x0448, /* / - 47 */
1199 0x0040, /* 0 - 48 */
1200 0x0040, /* 1 - 49 */
1201 0x0040, /* 2 - 50 */
1202 0x0040, /* 3 - 51 */
1203 0x0040, /* 4 - 52 */
1204 0x0040, /* 5 - 53 */
1205 0x0040, /* 6 - 54 */
1206 0x0040, /* 7 - 55 */
1207 0x0040, /* 8 - 56 */
1208 0x0040, /* 9 - 57 */
1209 0x0048, /* : - 58 */
1210 0x0048, /* ; - 59 */
1211 0x0048, /* < - 60 */
1212 0x0448, /* = - 61 */
1213 0x0048, /* > - 62 */
1214 0x0048, /* ? - 63 */
1215 0x0448, /* @ - 64 */
1216 0x8040, /* A - 65 */
1217 0x8040, /* B - 66 */
1218 0x8040, /* C - 67 */
1219 0x8040, /* D - 68 */
1220 0x8040, /* E - 69 */
1221 0x8040, /* F - 70 */
1222 0x8040, /* G - 71 */
1223 0x8040, /* H - 72 */
1224 0x8040, /* I - 73 */
1225 0x8040, /* J - 74 */
1226 0x8040, /* K - 75 */
1227 0x8040, /* L - 76 */
1228 0x8040, /* M - 77 */
1229 0x8040, /* N - 78 */
1230 0x8040, /* O - 79 */
1231 0x8040, /* P - 80 */
1232 0x8040, /* Q - 81 */
1233 0x8040, /* R - 82 */
1234 0x8040, /* S - 83 */
1235 0x8040, /* T - 84 */
1236 0x8040, /* U - 85 */
1237 0x8040, /* V - 86 */
1238 0x8040, /* W - 87 */
1239 0x8040, /* X - 88 */
1240 0x8040, /* Y - 89 */
1241 0x8040, /* Z - 90 */
1242 0x0048, /* [ - 91 */
1243 0x0448, /* \ - 92 */
1244 0x0048, /* ] - 93 */
1245 0x0448, /* ^ - 94 */
1246 0x0448, /* _ - 95 */
1247 0x0448, /* ` - 96 */
1248 0x8040, /* a - 97 */
1249 0x8040, /* b - 98 */
1250 0x8040, /* c - 99 */
1251 0x8040, /* d - 100 */
1252 0x8040, /* e - 101 */
1253 0x8040, /* f - 102 */
1254 0x8040, /* g - 103 */
1255 0x8040, /* h - 104 */
1256 0x8040, /* i - 105 */
1257 0x8040, /* j - 106 */
1258 0x8040, /* k - 107 */
1259 0x8040, /* l - 108 */
1260 0x8040, /* m - 109 */
1261 0x8040, /* n - 110 */
1262 0x8040, /* o - 111 */
1263 0x8040, /* p - 112 */
1264 0x8040, /* q - 113 */
1265 0x8040, /* r - 114 */
1266 0x8040, /* s - 115 */
1267 0x8040, /* t - 116 */
1268 0x8040, /* u - 117 */
1269 0x8040, /* v - 118 */
1270 0x8040, /* w - 119 */
1271 0x8040, /* x - 120 */
1272 0x8040, /* y - 121 */
1273 0x8040, /* z - 122 */
1274 0x0048, /* { - 123 */
1275 0x0048, /* | - 124 */
1276 0x0048, /* } - 125 */
1277 0x0448, /* ~ - 126 */
1278 0x0000, /* \x7f - 127 */
1279 0x0000, /* € - 128 */
1280 0x0000, /* � - 129 */
1281 0x0008, /* ‚ - 130 */
1282 0x8000, /* ƒ - 131 */
1283 0x0008, /* „ - 132 */
1284 0x0008, /* … - 133 */
1285 0x0008, /* † - 134 */
1286 0x0008, /* ‡ - 135 */
1287 0x0001, /* ˆ - 136 */
1288 0x0008, /* ‰ - 137 */
1289 0x8003, /* Š - 138 */
1290 0x0008, /* ‹ - 139 */
1291 0x8000, /* Œ - 140 */
1292 0x0000, /* � - 141 */
1293 0x0000, /* Ž - 142 */
1294 0x0000, /* � - 143 */
1295 0x0000, /* � - 144 */
1296 0x0088, /* ‘ - 145 */
1297 0x0088, /* ’ - 146 */
1298 0x0088, /* “ - 147 */
1299 0x0088, /* ” - 148 */
1300 0x0008, /* • - 149 */
1301 0x0400, /* – - 150 */
1302 0x0400, /* — - 151 */
1303 0x0408, /* ˜ - 152 */
1304 0x0000, /* ™ - 153 */
1305 0x8003, /* š - 154 */
1306 0x0008, /* › - 155 */
1307 0x8000, /* œ - 156 */
1308 0x0000, /* � - 157 */
1309 0x0000, /* ž - 158 */
1310 0x8003, /* Ÿ - 159 */
1312 0x0008, /* ¡ - 161 */
1313 0x0048, /* ¢ - 162 */
1314 0x0048, /* £ - 163 */
1315 0x0008, /* ¤ - 164 */
1316 0x0048, /* ¥ - 165 */
1317 0x0048, /* ¦ - 166 */
1318 0x0008, /* § - 167 */
1319 0x0408, /* ¨ - 168 */
1320 0x0008, /* © - 169 */
1321 0x0400, /* ª - 170 */
1322 0x0008, /* « - 171 */
1323 0x0048, /* ¬ - 172 */
1324 0x0408, /* - 173 */
1325 0x0008, /* ® - 174 */
1326 0x0448, /* ¯ - 175 */
1327 0x0008, /* ° - 176 */
1328 0x0008, /* ± - 177 */
1329 0x0000, /* ² - 178 */
1330 0x0000, /* ³ - 179 */
1331 0x0408, /* ´ - 180 */
1332 0x0008, /* µ - 181 */
1333 0x0008, /* ¶ - 182 */
1334 0x0008, /* · - 183 */
1335 0x0408, /* ¸ - 184 */
1336 0x0000, /* ¹ - 185 */
1337 0x0400, /* º - 186 */
1338 0x0008, /* » - 187 */
1339 0x0000, /* ¼ - 188 */
1340 0x0000, /* ½ - 189 */
1341 0x0000, /* ¾ - 190 */
1342 0x0008, /* ¿ - 191 */
1343 0x8003, /* À - 192 */
1344 0x8003, /* Á - 193 */
1345 0x8003, /* Â - 194 */
1346 0x8003, /* Ã - 195 */
1347 0x8003, /* Ä - 196 */
1348 0x8003, /* Å - 197 */
1349 0x8000, /* Æ - 198 */
1350 0x8003, /* Ç - 199 */
1351 0x8003, /* È - 200 */
1352 0x8003, /* É - 201 */
1353 0x8003, /* Ê - 202 */
1354 0x8003, /* Ë - 203 */
1355 0x8003, /* Ì - 204 */
1356 0x8003, /* Í - 205 */
1357 0x8003, /* Î - 206 */
1358 0x8003, /* Ï - 207 */
1359 0x8000, /* Ð - 208 */
1360 0x8003, /* Ñ - 209 */
1361 0x8003, /* Ò - 210 */
1362 0x8003, /* Ó - 211 */
1363 0x8003, /* Ô - 212 */
1364 0x8003, /* Õ - 213 */
1365 0x8003, /* Ö - 214 */
1366 0x0008, /* × - 215 */
1367 0x8003, /* Ø - 216 */
1368 0x8003, /* Ù - 217 */
1369 0x8003, /* Ú - 218 */
1370 0x8003, /* Û - 219 */
1371 0x8003, /* Ü - 220 */
1372 0x8003, /* Ý - 221 */
1373 0x8000, /* Þ - 222 */
1374 0x8000, /* ß - 223 */
1375 0x8003, /* à - 224 */
1376 0x8003, /* á - 225 */
1377 0x8003, /* â - 226 */
1378 0x8003, /* ã - 227 */
1379 0x8003, /* ä - 228 */
1380 0x8003, /* å - 229 */
1381 0x8000, /* æ - 230 */
1382 0x8003, /* ç - 231 */
1383 0x8003, /* è - 232 */
1384 0x8003, /* é - 233 */
1385 0x8003, /* ê - 234 */
1386 0x8003, /* ë - 235 */
1387 0x8003, /* ì - 236 */
1388 0x8003, /* í - 237 */
1389 0x8003, /* î - 238 */
1390 0x8003, /* ï - 239 */
1391 0x8000, /* ð - 240 */
1392 0x8003, /* ñ - 241 */
1393 0x8003, /* ò - 242 */
1394 0x8003, /* ó - 243 */
1395 0x8003, /* ô - 244 */
1396 0x8003, /* õ - 245 */
1397 0x8003, /* ö - 246 */
1398 0x0008, /* ÷ - 247 */
1399 0x8003, /* ø - 248 */
1400 0x8003, /* ù - 249 */
1401 0x8003, /* ú - 250 */
1402 0x8003, /* û - 251 */
1403 0x8003, /* ü - 252 */
1404 0x8003, /* ý - 253 */
1405 0x8000, /* þ - 254 */
1406 0x8003 /* ÿ - 255 */
1409 /******************************************************************************
1410 * GetStringType16 [OLE2NLS.7]
1412 BOOL16 WINAPI
GetStringType16(LCID locale
,DWORD dwInfoType
,LPCSTR src
,
1413 INT16 cchSrc
,LPWORD chartype
)
1415 return GetStringTypeExA(locale
,dwInfoType
,src
,cchSrc
,chartype
);
1417 /******************************************************************************
1418 * GetStringType32A [KERNEL32.396]
1420 BOOL WINAPI
GetStringTypeA(LCID locale
,DWORD dwInfoType
,LPCSTR src
,
1421 INT cchSrc
,LPWORD chartype
)
1423 return GetStringTypeExA(locale
,dwInfoType
,src
,cchSrc
,chartype
);
1426 /******************************************************************************
1427 * GetStringTypeEx32A [KERNEL32.397]
1429 * FIXME: Ignores the locale.
1431 BOOL WINAPI
GetStringTypeExA(LCID locale
,DWORD dwInfoType
,LPCSTR src
,
1432 INT cchSrc
,LPWORD chartype
)
1436 if ((src
==NULL
) || (chartype
==NULL
) || (src
==(LPSTR
)chartype
))
1438 SetLastError(ERROR_INVALID_PARAMETER
);
1443 cchSrc
=lstrlenA(src
)+1;
1445 switch (dwInfoType
) {
1447 for (i
=0;i
<cchSrc
;i
++)
1450 if (isdigit(src
[i
])) chartype
[i
]|=C1_DIGIT
;
1451 if (isalpha(src
[i
])) chartype
[i
]|=C1_ALPHA
;
1452 if (islower(src
[i
])) chartype
[i
]|=C1_LOWER
;
1453 if (isupper(src
[i
])) chartype
[i
]|=C1_UPPER
;
1454 if (isspace(src
[i
])) chartype
[i
]|=C1_SPACE
;
1455 if (ispunct(src
[i
])) chartype
[i
]|=C1_PUNCT
;
1456 if (iscntrl(src
[i
])) chartype
[i
]|=C1_CNTRL
;
1457 /* FIXME: isblank() is a GNU extension */
1458 /* if (isblank(src[i])) chartype[i]|=C1_BLANK; */
1459 if ((src
[i
] == ' ') || (src
[i
] == '\t')) chartype
[i
]|=C1_BLANK
;
1465 for (i
=0;i
<cchSrc
;i
++)
1467 chartype
[i
]=(WORD
)CT_CType2_LUT
[i
];
1472 for (i
=0;i
<cchSrc
;i
++)
1474 chartype
[i
]=OLE2NLS_CT_CType3_LUT
[i
];
1479 ERR_(ole
)("Unknown dwInfoType:%ld\n",dwInfoType
);
1484 /******************************************************************************
1485 * GetStringType32W [KERNEL32.399]
1488 * Yes, this is missing LCID locale. MS fault.
1490 BOOL WINAPI
GetStringTypeW(DWORD dwInfoType
,LPCWSTR src
,INT cchSrc
,
1493 return GetStringTypeExW(0/*defaultlocale*/,dwInfoType
,src
,cchSrc
,chartype
);
1496 /******************************************************************************
1497 * GetStringTypeEx32W [KERNEL32.398]
1499 * FIXME: unicode chars are assumed chars
1501 BOOL WINAPI
GetStringTypeExW(LCID locale
,DWORD dwInfoType
,LPCWSTR src
,
1502 INT cchSrc
,LPWORD chartype
)
1508 cchSrc
=lstrlenW(src
)+1;
1510 switch (dwInfoType
) {
1512 FIXME_(ole
)("CT_CTYPE2 not supported.\n");
1515 FIXME_(ole
)("CT_CTYPE3 not supported.\n");
1519 for (i
=0;i
<cchSrc
;i
++) {
1521 if (isdigit(src
[i
])) chartype
[i
]|=C1_DIGIT
;
1522 if (isalpha(src
[i
])) chartype
[i
]|=C1_ALPHA
;
1523 if (islower(src
[i
])) chartype
[i
]|=C1_LOWER
;
1524 if (isupper(src
[i
])) chartype
[i
]|=C1_UPPER
;
1525 if (isspace(src
[i
])) chartype
[i
]|=C1_SPACE
;
1526 if (ispunct(src
[i
])) chartype
[i
]|=C1_PUNCT
;
1527 if (iscntrl(src
[i
])) chartype
[i
]|=C1_CNTRL
;
1528 /* FIXME: isblank() is a GNU extension */
1529 /* if (isblank(src[i])) chartype[i]|=C1_BLANK; */
1530 if ((src
[i
] == ' ') || (src
[i
] == '\t')) chartype
[i
]|=C1_BLANK
;
1536 /*****************************************************************
1537 * WINE_GetLanguageName [internal]
1539 * FIXME: Windows keeps language names in a string table
1540 * resource in VER.DLL ...
1542 LPCSTR
WINE_GetLanguageName( UINT langid
)
1545 for ( i
= 0; languages
[i
].langid
!= 0; i
++ )
1546 if ( langid
== languages
[i
].langid
)
1549 return languages
[i
].langname
;
1552 static const unsigned char LCM_Unicode_LUT
[] = {
1585 7 , 28, /* ! - 33 */
1586 7 , 29, /* " - 34 */ /* " */
1587 7 , 31, /* # - 35 */
1588 7 , 33, /* $ - 36 */
1589 7 , 35, /* % - 37 */
1590 7 , 37, /* & - 38 */
1591 6 , 128, /* ' - 39 */
1592 7 , 39, /* ( - 40 */
1593 7 , 42, /* ) - 41 */
1594 7 , 45, /* * - 42 */
1596 7 , 47, /* , - 44 */
1597 6 , 130, /* - - 45 */
1598 7 , 51, /* . - 46 */
1599 7 , 53, /* / - 47 */
1600 12 , 3, /* 0 - 48 */
1601 12 , 33, /* 1 - 49 */
1602 12 , 51, /* 2 - 50 */
1603 12 , 70, /* 3 - 51 */
1604 12 , 88, /* 4 - 52 */
1605 12 , 106, /* 5 - 53 */
1606 12 , 125, /* 6 - 54 */
1607 12 , 144, /* 7 - 55 */
1608 12 , 162, /* 8 - 56 */
1609 12 , 180, /* 9 - 57 */
1610 7 , 55, /* : - 58 */
1611 7 , 58, /* ; - 59 */
1612 8 , 14, /* < - 60 */
1613 8 , 18, /* = - 61 */
1614 8 , 20, /* > - 62 */
1615 7 , 60, /* ? - 63 */
1616 7 , 62, /* @ - 64 */
1617 14 , 2, /* A - 65 */
1618 14 , 9, /* B - 66 */
1619 14 , 10, /* C - 67 */
1620 14 , 26, /* D - 68 */
1621 14 , 33, /* E - 69 */
1622 14 , 35, /* F - 70 */
1623 14 , 37, /* G - 71 */
1624 14 , 44, /* H - 72 */
1625 14 , 50, /* I - 73 */
1626 14 , 53, /* J - 74 */
1627 14 , 54, /* K - 75 */
1628 14 , 72, /* L - 76 */
1629 14 , 81, /* M - 77 */
1630 14 , 112, /* N - 78 */
1631 14 , 124, /* O - 79 */
1632 14 , 126, /* P - 80 */
1633 14 , 137, /* Q - 81 */
1634 14 , 138, /* R - 82 */
1635 14 , 145, /* S - 83 */
1636 14 , 153, /* T - 84 */
1637 14 , 159, /* U - 85 */
1638 14 , 162, /* V - 86 */
1639 14 , 164, /* W - 87 */
1640 14 , 166, /* X - 88 */
1641 14 , 167, /* Y - 89 */
1642 14 , 169, /* Z - 90 */
1643 7 , 63, /* [ - 91 */
1644 7 , 65, /* \ - 92 */
1645 7 , 66, /* ] - 93 */
1646 7 , 67, /* ^ - 94 */
1647 7 , 68, /* _ - 95 */
1648 7 , 72, /* ` - 96 */
1649 14 , 2, /* a - 97 */
1650 14 , 9, /* b - 98 */
1651 14 , 10, /* c - 99 */
1652 14 , 26, /* d - 100 */
1653 14 , 33, /* e - 101 */
1654 14 , 35, /* f - 102 */
1655 14 , 37, /* g - 103 */
1656 14 , 44, /* h - 104 */
1657 14 , 50, /* i - 105 */
1658 14 , 53, /* j - 106 */
1659 14 , 54, /* k - 107 */
1660 14 , 72, /* l - 108 */
1661 14 , 81, /* m - 109 */
1662 14 , 112, /* n - 110 */
1663 14 , 124, /* o - 111 */
1664 14 , 126, /* p - 112 */
1665 14 , 137, /* q - 113 */
1666 14 , 138, /* r - 114 */
1667 14 , 145, /* s - 115 */
1668 14 , 153, /* t - 116 */
1669 14 , 159, /* u - 117 */
1670 14 , 162, /* v - 118 */
1671 14 , 164, /* w - 119 */
1672 14 , 166, /* x - 120 */
1673 14 , 167, /* y - 121 */
1674 14 , 169, /* z - 122 */
1675 7 , 74, /* { - 123 */
1676 7 , 76, /* | - 124 */
1677 7 , 78, /* } - 125 */
1678 7 , 80, /* ~ - 126 */
1679 6 , 29, /* \x7f - 127 */
1680 6 , 30, /* € - 128 */
1681 6 , 31, /* � - 129 */
1682 7 , 123, /* ‚ - 130 */
1683 14 , 35, /* ƒ - 131 */
1684 7 , 127, /* „ - 132 */
1685 10 , 21, /* … - 133 */
1686 10 , 15, /* † - 134 */
1687 10 , 16, /* ‡ - 135 */
1688 7 , 67, /* ˆ - 136 */
1689 10 , 22, /* ‰ - 137 */
1690 14 , 145, /* Š - 138 */
1691 7 , 136, /* ‹ - 139 */
1692 14 + 16 , 124, /* Œ - 140 */
1693 6 , 43, /* � - 141 */
1694 6 , 44, /* Ž - 142 */
1695 6 , 45, /* � - 143 */
1696 6 , 46, /* � - 144 */
1697 7 , 121, /* ‘ - 145 */
1698 7 , 122, /* ’ - 146 */
1699 7 , 125, /* “ - 147 */
1700 7 , 126, /* ” - 148 */
1701 10 , 17, /* • - 149 */
1702 6 , 137, /* – - 150 */
1703 6 , 139, /* — - 151 */
1704 7 , 93, /* ˜ - 152 */
1705 14 , 156, /* ™ - 153 */
1706 14 , 145, /* š - 154 */
1707 7 , 137, /* › - 155 */
1708 14 + 16 , 124, /* œ - 156 */
1709 6 , 59, /* � - 157 */
1710 6 , 60, /* ž - 158 */
1711 14 , 167, /* Ÿ - 159 */
1713 7 , 81, /* ¡ - 161 */
1714 10 , 2, /* ¢ - 162 */
1715 10 , 3, /* £ - 163 */
1716 10 , 4, /* ¤ - 164 */
1717 10 , 5, /* ¥ - 165 */
1718 7 , 82, /* ¦ - 166 */
1719 10 , 6, /* § - 167 */
1720 7 , 83, /* ¨ - 168 */
1721 10 , 7, /* © - 169 */
1722 14 , 2, /* ª - 170 */
1723 8 , 24, /* « - 171 */
1724 10 , 8, /* ¬ - 172 */
1725 6 , 131, /* - 173 */
1726 10 , 9, /* ® - 174 */
1727 7 , 84, /* ¯ - 175 */
1728 10 , 10, /* ° - 176 */
1729 8 , 23, /* ± - 177 */
1730 12 , 51, /* ² - 178 */
1731 12 , 70, /* ³ - 179 */
1732 7 , 85, /* ´ - 180 */
1733 10 , 11, /* µ - 181 */
1734 10 , 12, /* ¶ - 182 */
1735 10 , 13, /* · - 183 */
1736 7 , 86, /* ¸ - 184 */
1737 12 , 33, /* ¹ - 185 */
1738 14 , 124, /* º - 186 */
1739 8 , 26, /* » - 187 */
1740 12 , 21, /* ¼ - 188 */
1741 12 , 25, /* ½ - 189 */
1742 12 , 29, /* ¾ - 190 */
1743 7 , 87, /* ¿ - 191 */
1744 14 , 2, /* À - 192 */
1745 14 , 2, /* Á - 193 */
1746 14 , 2, /* Â - 194 */
1747 14 , 2, /* Ã - 195 */
1748 14 , 2, /* Ä - 196 */
1749 14 , 2, /* Å - 197 */
1750 14 + 16 , 2, /* Æ - 198 */
1751 14 , 10, /* Ç - 199 */
1752 14 , 33, /* È - 200 */
1753 14 , 33, /* É - 201 */
1754 14 , 33, /* Ê - 202 */
1755 14 , 33, /* Ë - 203 */
1756 14 , 50, /* Ì - 204 */
1757 14 , 50, /* Í - 205 */
1758 14 , 50, /* Î - 206 */
1759 14 , 50, /* Ï - 207 */
1760 14 , 26, /* Ð - 208 */
1761 14 , 112, /* Ñ - 209 */
1762 14 , 124, /* Ò - 210 */
1763 14 , 124, /* Ó - 211 */
1764 14 , 124, /* Ô - 212 */
1765 14 , 124, /* Õ - 213 */
1766 14 , 124, /* Ö - 214 */
1767 8 , 28, /* × - 215 */
1768 14 , 124, /* Ø - 216 */
1769 14 , 159, /* Ù - 217 */
1770 14 , 159, /* Ú - 218 */
1771 14 , 159, /* Û - 219 */
1772 14 , 159, /* Ü - 220 */
1773 14 , 167, /* Ý - 221 */
1774 14 + 32 , 153, /* Þ - 222 */
1775 14 + 48 , 145, /* ß - 223 */
1776 14 , 2, /* à - 224 */
1777 14 , 2, /* á - 225 */
1778 14 , 2, /* â - 226 */
1779 14 , 2, /* ã - 227 */
1780 14 , 2, /* ä - 228 */
1781 14 , 2, /* å - 229 */
1782 14 + 16 , 2, /* æ - 230 */
1783 14 , 10, /* ç - 231 */
1784 14 , 33, /* è - 232 */
1785 14 , 33, /* é - 233 */
1786 14 , 33, /* ê - 234 */
1787 14 , 33, /* ë - 235 */
1788 14 , 50, /* ì - 236 */
1789 14 , 50, /* í - 237 */
1790 14 , 50, /* î - 238 */
1791 14 , 50, /* ï - 239 */
1792 14 , 26, /* ð - 240 */
1793 14 , 112, /* ñ - 241 */
1794 14 , 124, /* ò - 242 */
1795 14 , 124, /* ó - 243 */
1796 14 , 124, /* ô - 244 */
1797 14 , 124, /* õ - 245 */
1798 14 , 124, /* ö - 246 */
1799 8 , 29, /* ÷ - 247 */
1800 14 , 124, /* ø - 248 */
1801 14 , 159, /* ù - 249 */
1802 14 , 159, /* ú - 250 */
1803 14 , 159, /* û - 251 */
1804 14 , 159, /* ü - 252 */
1805 14 , 167, /* ý - 253 */
1806 14 + 32 , 153, /* þ - 254 */
1807 14 , 167 /* ÿ - 255 */ };
1809 static const unsigned char LCM_Unicode_LUT_2
[] = { 33, 44, 145 };
1811 #define LCM_Diacritic_Start 131
1813 static const unsigned char LCM_Diacritic_LUT
[] = {
1941 /******************************************************************************
1942 * OLE2NLS_isPunctuation [INTERNAL]
1944 static int OLE2NLS_isPunctuation(unsigned char c
)
1946 /* "punctuation character" in this context is a character which is
1947 considered "less important" during word sort comparison.
1948 See LCMapString implementation for the precise definition
1949 of "less important". */
1951 return (LCM_Unicode_LUT
[-2+2*c
]==6);
1954 /******************************************************************************
1955 * OLE2NLS_isNonSpacing [INTERNAL]
1957 static int OLE2NLS_isNonSpacing(unsigned char c
)
1959 /* This function is used by LCMapString32A. Characters
1960 for which it returns true are ignored when mapping a
1961 string with NORM_IGNORENONSPACE */
1962 return ((c
==136) || (c
==170) || (c
==186));
1965 /******************************************************************************
1966 * OLE2NLS_isSymbol [INTERNAL]
1968 static int OLE2NLS_isSymbol(unsigned char c
)
1970 /* This function is used by LCMapString32A. Characters
1971 for which it returns true are ignored when mapping a
1972 string with NORM_IGNORESYMBOLS */
1973 return ( (c
!=0) && !IsCharAlphaNumericA(c
) );
1976 /******************************************************************************
1977 * identity [Internal]
1979 static int identity(int c
)
1984 /*************************************************************************
1985 * LCMapString32A [KERNEL32.492]
1987 * Convert a string, or generate a sort key from it.
1989 * If (mapflags & LCMAP_SORTKEY), the function will generate
1990 * a sort key for the source string. Else, it will convert it
1991 * accordingly to the flags LCMAP_UPPERCASE, LCMAP_LOWERCASE,...
1995 * Success : length of the result string.
1998 * If called with scrlen = -1, the function will compute the length
1999 * of the 0-terminated string strsrc by itself.
2001 * If called with dstlen = 0, returns the buffer length that
2002 * would be required.
2004 * NORM_IGNOREWIDTH means to compare ASCII and wide characters
2005 * as if they are equal.
2006 * In the only code page implemented so far, there may not be
2007 * wide characters in strings passed to LCMapString32A,
2008 * so there is nothing to be done for this flag.
2010 INT WINAPI
LCMapStringA(
2011 LCID lcid
/* locale identifier created with MAKELCID;
2012 LOCALE_SYSTEM_DEFAULT and LOCALE_USER_DEFAULT are
2013 predefined values. */,
2014 DWORD mapflags
/* flags */,
2015 LPCSTR srcstr
/* source buffer */,
2016 INT srclen
/* source length */,
2017 LPSTR dststr
/* destination buffer */,
2018 INT dstlen
/* destination buffer length */)
2022 TRACE_(string
)("(0x%04lx,0x%08lx,%s,%d,%p,%d)\n",
2023 lcid
,mapflags
,srcstr
,srclen
,dststr
,dstlen
);
2025 if ( ((dstlen
!=0) && (dststr
==NULL
)) || (srcstr
==NULL
) )
2027 ERR_(ole
)("(src=%s,dest=%s): Invalid NULL string\n", srcstr
, dststr
);
2028 SetLastError(ERROR_INVALID_PARAMETER
);
2032 srclen
= lstrlenA(srcstr
) + 1 ; /* (include final '\0') */
2034 #define LCMAPSTRINGA_SUPPORTED_FLAGS (LCMAP_UPPERCASE | \
2038 NORM_IGNORENONSPACE | \
2042 if (mapflags
& ~LCMAPSTRINGA_SUPPORTED_FLAGS
)
2044 FIXME_(string
)("(0x%04lx,0x%08lx,%p,%d,%p,%d): "
2045 "unimplemented flags: 0x%08lx\n",
2052 mapflags
& ~LCMAPSTRINGA_SUPPORTED_FLAGS
2056 if ( !(mapflags
& LCMAP_SORTKEY
) )
2059 int (*f
)(int) = identity
;
2060 int flag_ignorenonspace
= mapflags
& NORM_IGNORENONSPACE
;
2061 int flag_ignoresymbols
= mapflags
& NORM_IGNORESYMBOLS
;
2063 if (flag_ignorenonspace
|| flag_ignoresymbols
)
2065 /* For some values of mapflags, the length of the resulting
2066 string is not known at this point. Windows does map the string
2067 and does not SetLastError ERROR_INSUFFICIENT_BUFFER in
2071 /* Compute required length */
2072 for (i
=j
=0; i
< srclen
; i
++)
2074 if ( !(flag_ignorenonspace
&& OLE2NLS_isNonSpacing(srcstr
[i
]))
2075 && !(flag_ignoresymbols
&& OLE2NLS_isSymbol(srcstr
[i
])) )
2087 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2091 if (mapflags
& LCMAP_UPPERCASE
)
2093 else if (mapflags
& LCMAP_LOWERCASE
)
2095 /* FIXME: NORM_IGNORENONSPACE requires another conversion */
2096 for (i
=j
=0; (i
<srclen
) && (j
<dstlen
) ; i
++)
2098 if ( !(flag_ignorenonspace
&& OLE2NLS_isNonSpacing(srcstr
[i
]))
2099 && !(flag_ignoresymbols
&& OLE2NLS_isSymbol(srcstr
[i
])) )
2101 dststr
[j
] = (CHAR
) f(srcstr
[i
]);
2108 /* else ... (mapflags & LCMAP_SORTKEY) */
2112 int diacritic_len
=0;
2113 int delayed_punctuation_len
=0;
2114 char *case_component
;
2115 char *diacritic_component
;
2116 char *delayed_punctuation_component
;
2118 int flag_stringsort
= mapflags
& SORT_STRINGSORT
;
2120 /* compute how much room we will need */
2121 for (i
=0;i
<srclen
;i
++)
2124 unsigned char source_char
= srcstr
[i
];
2125 if (source_char
!='\0')
2127 if (flag_stringsort
|| !OLE2NLS_isPunctuation(source_char
))
2130 if ( LCM_Unicode_LUT
[-2+2*source_char
] & ~15 )
2131 unicode_len
++; /* double letter */
2135 delayed_punctuation_len
++;
2139 if (isupper(source_char
))
2140 case_len
=unicode_len
;
2142 ofs
= source_char
- LCM_Diacritic_Start
;
2143 if ((ofs
>=0) && (LCM_Diacritic_LUT
[ofs
]!=2))
2144 diacritic_len
=unicode_len
;
2147 if (mapflags
& NORM_IGNORECASE
)
2149 if (mapflags
& NORM_IGNORENONSPACE
)
2152 room
= 2 * unicode_len
/* "unicode" component */
2153 + diacritic_len
/* "diacritic" component */
2154 + case_len
/* "case" component */
2155 + 4 * delayed_punctuation_len
/* punctuation in word sort mode */
2156 + 4 /* four '\1' separators */
2157 + 1 ; /* terminal '\0' */
2160 else if (dstlen
<room
)
2162 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2166 /*FIXME the Pointercheck should not be nessesary */
2167 if (IsBadWritePtr (dststr
,room
))
2168 { ERR_(string
)("bad destination buffer (dststr) : %p,%d\n",dststr
,dstlen
);
2169 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2173 /* locate each component, write separators */
2174 diacritic_component
= dststr
+ 2*unicode_len
;
2175 *diacritic_component
++ = '\1';
2176 case_component
= diacritic_component
+ diacritic_len
;
2177 *case_component
++ = '\1';
2178 delayed_punctuation_component
= case_component
+ case_len
;
2179 *delayed_punctuation_component
++ = '\1';
2180 *delayed_punctuation_component
++ = '\1';
2182 /* read source string char by char, write
2183 corresponding weight in each component. */
2184 for (i
=0,count
=0;i
<srclen
;i
++)
2186 unsigned char source_char
=srcstr
[i
];
2187 if (source_char
!='\0')
2190 type
= LCM_Unicode_LUT
[-2+2*source_char
];
2191 longcode
= type
>> 4;
2193 if (!flag_stringsort
&& OLE2NLS_isPunctuation(source_char
))
2195 UINT16 encrypted_location
= (1<<15) + 7 + 4*count
;
2196 *delayed_punctuation_component
++ = (unsigned char) (encrypted_location
>>8);
2197 *delayed_punctuation_component
++ = (unsigned char) (encrypted_location
&255);
2198 /* big-endian is used here because it lets string comparison be
2199 compatible with numerical comparison */
2201 *delayed_punctuation_component
++ = type
;
2202 *delayed_punctuation_component
++ = LCM_Unicode_LUT
[-1+2*source_char
];
2203 /* assumption : a punctuation character is never a
2204 double or accented letter */
2208 dststr
[2*count
] = type
;
2209 dststr
[2*count
+1] = LCM_Unicode_LUT
[-1+2*source_char
];
2213 case_component
[count
] = ( isupper(source_char
) ? 18 : 2 ) ;
2214 if (count
<diacritic_len
)
2215 diacritic_component
[count
] = 2; /* assumption: a double letter
2216 is never accented */
2219 dststr
[2*count
] = type
;
2220 dststr
[2*count
+1] = *(LCM_Unicode_LUT_2
- 1 + longcode
);
2221 /* 16 in the first column of LCM_Unicode_LUT --> longcode = 1
2222 32 in the first column of LCM_Unicode_LUT --> longcode = 2
2223 48 in the first column of LCM_Unicode_LUT --> longcode = 3 */
2227 case_component
[count
] = ( isupper(source_char
) ? 18 : 2 ) ;
2228 if (count
<diacritic_len
)
2230 int ofs
= source_char
- LCM_Diacritic_Start
;
2231 diacritic_component
[count
] = (ofs
>=0 ? LCM_Diacritic_LUT
[ofs
] : 2);
2237 dststr
[room
-1] = '\0';
2242 /*************************************************************************
2243 * LCMapString32W [KERNEL32.493]
2245 * Convert a string, or generate a sort key from it.
2249 * See LCMapString32A for documentation
2251 INT WINAPI
LCMapStringW(
2252 LCID lcid
,DWORD mapflags
,LPCWSTR srcstr
,INT srclen
,LPWSTR dststr
,
2257 TRACE_(string
)("(0x%04lx,0x%08lx,%p,%d,%p,%d)\n",
2258 lcid
,mapflags
,srcstr
,srclen
,dststr
,dstlen
);
2260 if ( ((dstlen
!=0) && (dststr
==NULL
)) || (srcstr
==NULL
) )
2262 ERR_(ole
)("(src=%p,dst=%p): Invalid NULL string\n", srcstr
, dststr
);
2263 SetLastError(ERROR_INVALID_PARAMETER
);
2267 srclen
= lstrlenW(srcstr
)+1;
2268 if (mapflags
& LCMAP_SORTKEY
)
2270 FIXME_(string
)("(0x%04lx,0x%08lx,%p,%d,%p,%d): "
2271 "unimplemented flags: 0x%08lx\n",
2272 lcid
,mapflags
,srcstr
,srclen
,dststr
,dstlen
,mapflags
);
2277 int (*f
)(int)=identity
;
2281 if (dstlen
<srclen
) {
2282 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2285 if (mapflags
& LCMAP_UPPERCASE
)
2287 else if (mapflags
& LCMAP_LOWERCASE
)
2289 for (i
=0; i
< srclen
; i
++)
2290 dststr
[i
] = (WCHAR
) f(srcstr
[i
]);
2295 /***********************************************************************
2296 * CompareString16 (OLE2NLS.8)
2298 UINT16 WINAPI
CompareString16(DWORD lcid
,DWORD fdwStyle
,
2299 LPCSTR s1
,DWORD l1
,LPCSTR s2
,DWORD l2
)
2301 return (UINT16
)CompareStringA(lcid
,fdwStyle
,s1
,l1
,s2
,l2
);
2304 /******************************************************************************
2305 * CompareString32A [KERNEL32.143]
2306 * Compares two strings using locale
2310 * success: CSTR_LESS_THAN, CSTR_EQUAL, CSTR_GREATER_THAN
2315 * Defaults to a word sort, but uses a string sort if
2316 * SORT_STRINGSORT is set.
2317 * Calls SetLastError for ERROR_INVALID_FLAGS, ERROR_INVALID_PARAMETER.
2321 * This implementation ignores the locale
2325 * Quite inefficient.
2327 UINT WINAPI
CompareStringA(
2328 DWORD lcid
, /* locale ID */
2329 DWORD fdwStyle
, /* comparison-style options */
2330 LPCSTR s1
, /* first string */
2331 DWORD l1
, /* length of first string */
2332 LPCSTR s2
, /* second string */
2333 DWORD l2
) /* length of second string */
2335 int mapstring_flags
;
2339 TRACE_(ole
)("%s and %s\n",
2340 debugstr_a (s1
), debugstr_a (s2
));
2342 if ( (s1
==NULL
) || (s2
==NULL
) )
2344 ERR_(ole
)("(s1=%s,s2=%s): Invalid NULL string\n", s1
, s2
);
2345 SetLastError(ERROR_INVALID_PARAMETER
);
2349 if(fdwStyle
& NORM_IGNORESYMBOLS
)
2350 FIXME_(ole
)("IGNORESYMBOLS not supported\n");
2352 mapstring_flags
= LCMAP_SORTKEY
| fdwStyle
;
2353 len1
= LCMapStringA(lcid
,mapstring_flags
,s1
,l1
,NULL
,0);
2354 len2
= LCMapStringA(lcid
,mapstring_flags
,s2
,l2
,NULL
,0);
2356 if ((len1
==0)||(len2
==0))
2357 return 0; /* something wrong happened */
2359 sk1
= (LPSTR
)HeapAlloc(GetProcessHeap(),0,len1
);
2360 sk2
= (LPSTR
)HeapAlloc(GetProcessHeap(),0,len2
);
2361 if ( (!LCMapStringA(lcid
,mapstring_flags
,s1
,l1
,sk1
,len1
))
2362 || (!LCMapStringA(lcid
,mapstring_flags
,s2
,l2
,sk2
,len2
)) )
2364 ERR_(ole
)("Bug in LCmapString32A.\n");
2369 /* strcmp doesn't necessarily return -1, 0, or 1 */
2370 result
= strcmp(sk1
,sk2
);
2372 HeapFree(GetProcessHeap(),0,sk1
);
2373 HeapFree(GetProcessHeap(),0,sk2
);
2380 /* must be greater, if we reach this point */
2384 /******************************************************************************
2385 * CompareString32W [KERNEL32.144]
2386 * This implementation ignores the locale
2387 * FIXME : Does only string sort. Should
2388 * be reimplemented the same way as CompareString32A.
2390 UINT WINAPI
CompareStringW(DWORD lcid
, DWORD fdwStyle
,
2391 LPCWSTR s1
, DWORD l1
, LPCWSTR s2
,DWORD l2
)
2394 if(fdwStyle
& NORM_IGNORENONSPACE
)
2395 FIXME_(ole
)("IGNORENONSPACE not supprted\n");
2396 if(fdwStyle
& NORM_IGNORESYMBOLS
)
2397 FIXME_(ole
)("IGNORESYMBOLS not supported\n");
2399 /* Is strcmp defaulting to string sort or to word sort?? */
2400 /* FIXME: Handle NORM_STRINGSORT */
2401 l1
= (l1
==-1)?lstrlenW(s1
):l1
;
2402 l2
= (l2
==-1)?lstrlenW(s2
):l2
;
2403 len
= l1
<l2
? l1
:l2
;
2404 ret
= (fdwStyle
& NORM_IGNORECASE
) ?
2405 CRTDLL__wcsnicmp(s1
,s2
,len
) : CRTDLL_wcsncmp(s1
,s2
,len
);
2406 /* not equal, return 1 or 3 */
2407 if(ret
!=0) return ret
+2;
2408 /* same len, return 2 */
2409 if(l1
==l2
) return 2;
2410 /* the longer one is lexically greater */
2411 return (l1
<l2
)? 1 : 3;
2414 /******************************************************************************
2415 * OLE_GetFormatA [Internal]
2418 * If datelen == 0, it should return the reguired string length.
2420 This function implements stuff for GetDateFormat() and
2423 d single-digit (no leading zero) day (of month)
2424 dd two-digit day (of month)
2425 ddd short day-of-week name
2426 dddd long day-of-week name
2427 M single-digit month
2429 MMM short month name
2430 MMMM full month name
2431 y two-digit year, no leading 0
2433 yyyy four-digit year
2435 h hours with no leading zero (12-hour)
2436 hh hours with full two digits
2437 H hours with no leading zero (24-hour)
2438 HH hours with full two digits
2439 m minutes with no leading zero
2440 mm minutes with full two digits
2441 s seconds with no leading zero
2442 ss seconds with full two digits
2443 t time marker (A or P)
2444 tt time marker (AM, PM)
2445 '' used to quote literal characters
2446 '' (within a quoted string) indicates a literal '
2448 These functions REQUIRE valid locale, date, and format.
2450 static INT
OLE_GetFormatA(LCID locale
,
2454 LPCSTR _format
, /*in*/
2459 int count
, type
, inquote
, Overflow
;
2465 const char * _dgfmt
[] = { "%d", "%02d" };
2466 const char ** dgfmt
= _dgfmt
- 1;
2468 /* report, for debugging */
2469 TRACE_(ole
)("(0x%lx,0x%lx, 0x%lx, time(d=%d,h=%d,m=%d,s=%d), fmt=%p \'%s\' , %p, len=%d)\n",
2470 locale
, flags
, tflags
,
2471 xtime
->wDay
, xtime
->wHour
, xtime
->wMinute
, xtime
->wSecond
,
2472 _format
, _format
, date
, datelen
);
2475 FIXME_(ole
)("datelen = 0, returning 255\n");
2479 /* initalize state variables and output buffer */
2481 count
= 0; inquote
= 0; Overflow
= 0;
2483 date
[0] = buf
[0] = '\0';
2485 strcpy(format
,_format
);
2487 /* alter the formatstring, while it works for all languages now in wine
2488 its possible that it fails when the time looks like ss:mm:hh as example*/
2489 if (tflags
& (TIME_NOMINUTESORSECONDS
))
2490 { if ((pos
= strstr ( format
, ":mm")))
2491 { memcpy ( pos
, pos
+3, strlen(format
)-(pos
-format
)-2 );
2494 if (tflags
& (TIME_NOSECONDS
))
2495 { if ((pos
= strstr ( format
, ":ss")))
2496 { memcpy ( pos
, pos
+3, strlen(format
)-(pos
-format
)-2 );
2500 for (inpos
= 0;; inpos
++) {
2501 /* 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]); */
2503 if (format
[inpos
] == '\'') {
2504 if (format
[inpos
+1] == '\'') {
2506 date
[outpos
++] = '\'';
2509 continue; /* we did nothing to the output */
2511 } else if (format
[inpos
] == '\0') {
2512 date
[outpos
++] = '\0';
2513 if (outpos
> datelen
) Overflow
= 1;
2516 date
[outpos
++] = format
[inpos
];
2517 if (outpos
> datelen
) {
2519 date
[outpos
-1] = '\0'; /* this is the last place where
2520 it's safe to write */
2524 } else if ( (count
&& (format
[inpos
] != type
))
2526 || (count
== 2 && strchr("ghHmst", type
)) )
2530 GetLocaleInfoA(locale
,
2532 + xtime
->wDayOfWeek
- 1,
2534 } else if (count
== 3) {
2535 GetLocaleInfoA(locale
,
2536 LOCALE_SABBREVDAYNAME1
2537 + xtime
->wDayOfWeek
- 1,
2540 sprintf(buf
, dgfmt
[count
], xtime
->wDay
);
2542 } else if (type
== 'M') {
2544 GetLocaleInfoA(locale
,
2545 LOCALE_SABBREVMONTHNAME1
2546 + xtime
->wMonth
- 1,
2548 } else if (count
== 4) {
2549 GetLocaleInfoA(locale
,
2551 + xtime
->wMonth
- 1,
2554 sprintf(buf
, dgfmt
[count
], xtime
->wMonth
);
2556 } else if (type
== 'y') {
2558 sprintf(buf
, "%d", xtime
->wYear
);
2559 } else if (count
== 3) {
2561 WARN_(ole
)("unknown format, c=%c, n=%d\n", type
, count
);
2563 sprintf(buf
, dgfmt
[count
], xtime
->wYear
% 100);
2565 } else if (type
== 'g') {
2567 FIXME_(ole
)("LOCALE_ICALENDARTYPE unimp.\n");
2571 WARN_(ole
)("unknown format, c=%c, n=%d\n", type
, count
);
2573 } else if (type
== 'h') {
2574 /* gives us hours 1:00 -- 12:00 */
2575 sprintf(buf
, dgfmt
[count
], (xtime
->wHour
-1)%12 +1);
2576 } else if (type
== 'H') {
2578 sprintf(buf
, dgfmt
[count
], xtime
->wHour
);
2579 } else if ( type
== 'm') {
2580 sprintf(buf
, dgfmt
[count
], xtime
->wMinute
);
2581 } else if ( type
== 's') {
2582 sprintf(buf
, dgfmt
[count
], xtime
->wSecond
);
2583 } else if (type
== 't') {
2585 sprintf(buf
, "%c", (xtime
->wHour
< 12) ? 'A' : 'P');
2586 } else if (count
== 2) {
2587 /* sprintf(buf, "%s", (xtime->wHour < 12) ? "AM" : "PM"); */
2588 GetLocaleInfoA(locale
,
2590 ? LOCALE_S1159
: LOCALE_S2359
,
2595 /* we need to check the next char in the format string
2596 again, no matter what happened */
2599 /* add the contents of buf to the output */
2600 buflen
= strlen(buf
);
2601 if (outpos
+ buflen
< datelen
) {
2602 date
[outpos
] = '\0'; /* for strcat to hook onto */
2606 date
[outpos
] = '\0';
2607 strncat(date
, buf
, datelen
- outpos
);
2608 date
[datelen
- 1] = '\0';
2609 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2610 WARN_(ole
)("insufficient buffer\n");
2614 /* reset the variables we used to keep track of this item */
2617 } else if (format
[inpos
] == '\0') {
2618 /* we can't check for this at the loop-head, because
2619 that breaks the printing of the last format-item */
2620 date
[outpos
] = '\0';
2623 /* continuing a code for an item */
2626 } else if (strchr("hHmstyMdg", format
[inpos
])) {
2627 type
= format
[inpos
];
2630 } else if (format
[inpos
] == '\'') {
2634 date
[outpos
++] = format
[inpos
];
2636 /* now deal with a possible buffer overflow */
2637 if (outpos
>= datelen
) {
2638 date
[datelen
- 1] = '\0';
2639 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2645 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2648 /* finish it off with a string terminator */
2651 if (outpos
> datelen
-1) outpos
= datelen
-1;
2652 date
[outpos
] = '\0';
2654 TRACE_(ole
)("OLE_GetFormatA returns string '%s', len %d\n",
2659 /******************************************************************************
2660 * OLE_GetFormatW [INTERNAL]
2662 static INT
OLE_GetFormatW(LCID locale
, DWORD flags
, DWORD tflags
,
2665 LPWSTR output
, INT outlen
)
2668 int count
, type
=0, inquote
;
2669 int Overflow
; /* loop check */
2672 WCHAR arg0
[] = {0}, arg1
[] = {'%','d',0};
2673 WCHAR arg2
[] = {'%','0','2','d',0};
2675 int datevars
=0, timevars
=0;
2681 /* make a debug report */
2682 TRACE_(ole
)("args: 0x%lx, 0x%lx, 0x%lx, time(d=%d,h=%d,m=%d,s=%d), fmt:%s (at %p), "
2683 "%p with max len %d\n",
2684 locale
, flags
, tflags
,
2685 xtime
->wDay
, xtime
->wHour
, xtime
->wMinute
, xtime
->wSecond
,
2686 debugstr_w(format
), format
, output
, outlen
);
2689 FIXME_(ole
)("outlen = 0, returning 255\n");
2693 /* initialize state variables */
2696 inquote
= Overflow
= 0;
2697 /* this is really just a sanity check */
2698 output
[0] = buf
[0] = 0;
2700 /* this loop is the core of the function */
2701 for (inpos
= 0; /* we have several break points */ ; inpos
++) {
2703 if (format
[inpos
] == (WCHAR
) '\'') {
2704 if (format
[inpos
+1] == '\'') {
2706 output
[outpos
++] = '\'';
2711 } else if (format
[inpos
] == 0) {
2712 output
[outpos
++] = 0;
2713 if (outpos
> outlen
) Overflow
= 1;
2714 break; /* normal exit (within a quote) */
2716 output
[outpos
++] = format
[inpos
]; /* copy input */
2717 if (outpos
> outlen
) {
2719 output
[outpos
-1] = 0;
2723 } else if ( (count
&& (format
[inpos
] != type
))
2724 || ( (count
==4 && type
=='y') ||
2725 (count
==4 && type
=='M') ||
2726 (count
==4 && type
=='d') ||
2727 (count
==2 && type
=='g') ||
2728 (count
==2 && type
=='h') ||
2729 (count
==2 && type
=='H') ||
2730 (count
==2 && type
=='m') ||
2731 (count
==2 && type
=='s') ||
2732 (count
==2 && type
=='t') ) ) {
2735 GetLocaleInfoW(locale
,
2736 LOCALE_SDAYNAME1
+ xtime
->wDayOfWeek
-1,
2737 buf
, sizeof(buf
)/sizeof(WCHAR
) );
2738 } else if (count
== 3) {
2739 GetLocaleInfoW(locale
,
2740 LOCALE_SABBREVDAYNAME1
+
2741 xtime
->wDayOfWeek
-1,
2742 buf
, sizeof(buf
)/sizeof(WCHAR
) );
2744 wsnprintfW(buf
, 5, argarr
[count
], xtime
->wDay
);
2746 } else if (type
== 'M') {
2748 GetLocaleInfoW(locale
, LOCALE_SMONTHNAME1
+
2749 xtime
->wMonth
-1, buf
,
2750 sizeof(buf
)/sizeof(WCHAR
) );
2751 } else if (count
== 3) {
2752 GetLocaleInfoW(locale
, LOCALE_SABBREVMONTHNAME1
+
2753 xtime
->wMonth
-1, buf
,
2754 sizeof(buf
)/sizeof(WCHAR
) );
2756 wsnprintfW(buf
, 5, argarr
[count
], xtime
->wMonth
);
2758 } else if (type
== 'y') {
2760 wsnprintfW(buf
, 6, argarr
[1] /* "%d" */,
2762 } else if (count
== 3) {
2763 lstrcpynAtoW(buf
, "yyy", 5);
2765 wsnprintfW(buf
, 6, argarr
[count
],
2766 xtime
->wYear
% 100);
2768 } else if (type
== 'g') {
2770 FIXME_(ole
)("LOCALE_ICALENDARTYPE unimplemented\n");
2771 lstrcpynAtoW(buf
, "AD", 5);
2773 /* Win API sez we copy it verbatim */
2774 lstrcpynAtoW(buf
, "g", 5);
2776 } else if (type
== 'h') {
2777 /* hours 1:00-12:00 --- is this right? */
2778 wsnprintfW(buf
, 5, argarr
[count
],
2779 (xtime
->wHour
-1)%12 +1);
2780 } else if (type
== 'H') {
2781 wsnprintfW(buf
, 5, argarr
[count
],
2783 } else if (type
== 'm' ) {
2784 wsnprintfW(buf
, 5, argarr
[count
],
2786 } else if (type
== 's' ) {
2787 wsnprintfW(buf
, 5, argarr
[count
],
2789 } else if (type
== 't') {
2790 GetLocaleInfoW(locale
, (xtime
->wHour
< 12) ?
2791 LOCALE_S1159
: LOCALE_S2359
,
2798 /* no matter what happened, we need to check this next
2799 character the next time we loop through */
2802 /* cat buf onto the output */
2803 outlen
= lstrlenW(buf
);
2804 if (outpos
+ buflen
< outlen
) {
2805 lstrcpyW( output
+ outpos
, buf
);
2808 lstrcpynW( output
+ outpos
, buf
, outlen
- outpos
);
2810 break; /* Abnormal exit */
2813 /* reset the variables we used this time */
2816 } else if (format
[inpos
] == 0) {
2817 /* we can't check for this at the beginning, because that
2818 would keep us from printing a format spec that ended the
2821 break; /* NORMAL EXIT */
2823 /* how we keep track of the middle of a format spec */
2826 } else if ( (datevars
&& (format
[inpos
]=='d' ||
2827 format
[inpos
]=='M' ||
2828 format
[inpos
]=='y' ||
2829 format
[inpos
]=='g') ) ||
2830 (timevars
&& (format
[inpos
]=='H' ||
2831 format
[inpos
]=='h' ||
2832 format
[inpos
]=='m' ||
2833 format
[inpos
]=='s' ||
2834 format
[inpos
]=='t') ) ) {
2835 type
= format
[inpos
];
2838 } else if (format
[inpos
] == '\'') {
2842 /* unquoted literals */
2843 output
[outpos
++] = format
[inpos
];
2848 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2849 WARN_(ole
)(" buffer overflow\n");
2852 /* final string terminator and sanity check */
2854 if (outpos
> outlen
-1) outpos
= outlen
-1;
2855 output
[outpos
] = '0';
2857 TRACE_(ole
)(" returning %s\n", debugstr_w(output
));
2859 return (!Overflow
) ? outlen
: 0;
2864 /******************************************************************************
2865 * GetDateFormat32A [KERNEL32.310]
2866 * Makes an ASCII string of the date
2868 * This function uses format to format the date, or, if format
2869 * is NULL, uses the default for the locale. format is a string
2870 * of literal fields and characters as follows:
2872 * - d single-digit (no leading zero) day (of month)
2873 * - dd two-digit day (of month)
2874 * - ddd short day-of-week name
2875 * - dddd long day-of-week name
2876 * - M single-digit month
2877 * - MM two-digit month
2878 * - MMM short month name
2879 * - MMMM full month name
2880 * - y two-digit year, no leading 0
2881 * - yy two-digit year
2882 * - yyyy four-digit year
2886 INT WINAPI
GetDateFormatA(LCID locale
,DWORD flags
,
2888 LPCSTR format
, LPSTR date
,INT datelen
)
2891 char format_buf
[40];
2894 LPSYSTEMTIME thistime
;
2898 TRACE_(ole
)("(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",
2899 locale
,flags
,xtime
,format
,date
,datelen
);
2902 locale
= LOCALE_SYSTEM_DEFAULT
;
2905 if (locale
== LOCALE_SYSTEM_DEFAULT
) {
2906 thislocale
= GetSystemDefaultLCID();
2907 } else if (locale
== LOCALE_USER_DEFAULT
) {
2908 thislocale
= GetUserDefaultLCID();
2910 thislocale
= locale
;
2913 if (xtime
== NULL
) {
2920 if (format
== NULL
) {
2921 GetLocaleInfoA(thislocale
, ((flags
&DATE_LONGDATE
)
2923 : LOCALE_SSHORTDATE
),
2924 format_buf
, sizeof(format_buf
));
2925 thisformat
= format_buf
;
2927 thisformat
= format
;
2931 ret
= OLE_GetFormatA(thislocale
, flags
, 0, thistime
, thisformat
,
2936 "GetDateFormat32A() returning %d, with data=%s\n",
2941 /******************************************************************************
2942 * GetDateFormat32W [KERNEL32.311]
2943 * Makes a Unicode string of the date
2945 * Acts the same as GetDateFormat32A(), except that it's Unicode.
2946 * Accepts & returns sizes as counts of Unicode characters.
2949 INT WINAPI
GetDateFormatW(LCID locale
,DWORD flags
,
2952 LPWSTR date
, INT datelen
)
2954 unsigned short datearr
[] = {'1','9','9','4','-','1','-','1',0};
2956 FIXME_(ole
)("STUB (should call OLE_GetFormatW)\n");
2957 lstrcpynW(date
, datearr
, datelen
);
2958 return ( datelen
< 9) ? datelen
: 9;
2963 /**************************************************************************
2964 * EnumDateFormats32A (KERNEL32.198)
2966 BOOL WINAPI
EnumDateFormatsA(
2967 DATEFMT_ENUMPROCA lpDateFmtEnumProc
, LCID Locale
, DWORD dwFlags
)
2969 FIXME_(ole
)("Only US English supported\n");
2971 if(!lpDateFmtEnumProc
)
2973 SetLastError(ERROR_INVALID_PARAMETER
);
2979 case DATE_SHORTDATE
:
2980 if(!(*lpDateFmtEnumProc
)("M/d/yy")) return TRUE
;
2981 if(!(*lpDateFmtEnumProc
)("M/d/yyyy")) return TRUE
;
2982 if(!(*lpDateFmtEnumProc
)("MM/dd/yy")) return TRUE
;
2983 if(!(*lpDateFmtEnumProc
)("MM/dd/yyyy")) return TRUE
;
2984 if(!(*lpDateFmtEnumProc
)("yy/MM/dd")) return TRUE
;
2985 if(!(*lpDateFmtEnumProc
)("dd-MMM-yy")) return TRUE
;
2988 if(!(*lpDateFmtEnumProc
)("dddd, MMMM dd, yyyy")) return TRUE
;
2989 if(!(*lpDateFmtEnumProc
)("MMMM dd, yyyy")) return TRUE
;
2990 if(!(*lpDateFmtEnumProc
)("dddd, dd MMMM, yyyy")) return TRUE
;
2991 if(!(*lpDateFmtEnumProc
)("dd MMMM, yyyy")) return TRUE
;
2994 FIXME_(ole
)("Unknown date format (%ld)\n", dwFlags
);
2995 SetLastError(ERROR_INVALID_PARAMETER
);
3000 /**************************************************************************
3001 * EnumDateFormats32W (KERNEL32.199)
3003 BOOL WINAPI
EnumDateFormatsW(
3004 DATEFMT_ENUMPROCW lpDateFmtEnumProc
, LCID Locale
, DWORD dwFlags
)
3006 FIXME_(ole
)("(%p, %ld, %ld): stub\n", lpDateFmtEnumProc
, Locale
, dwFlags
);
3007 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
3011 /**************************************************************************
3012 * EnumTimeFormats32A (KERNEL32.210)
3014 BOOL WINAPI
EnumTimeFormatsA(
3015 TIMEFMT_ENUMPROCA lpTimeFmtEnumProc
, LCID Locale
, DWORD dwFlags
)
3017 FIXME_(ole
)("Only US English supported\n");
3019 if(!lpTimeFmtEnumProc
)
3021 SetLastError(ERROR_INVALID_PARAMETER
);
3027 FIXME_(ole
)("Unknown time format (%ld)\n", dwFlags
);
3030 if(!(*lpTimeFmtEnumProc
)("h:mm:ss tt")) return TRUE
;
3031 if(!(*lpTimeFmtEnumProc
)("hh:mm:ss tt")) return TRUE
;
3032 if(!(*lpTimeFmtEnumProc
)("H:mm:ss")) return TRUE
;
3033 if(!(*lpTimeFmtEnumProc
)("HH:mm:ss")) return TRUE
;
3038 /**************************************************************************
3039 * EnumTimeFormats32W (KERNEL32.211)
3041 BOOL WINAPI
EnumTimeFormatsW(
3042 TIMEFMT_ENUMPROCW lpTimeFmtEnumProc
, LCID Locale
, DWORD dwFlags
)
3044 FIXME_(ole
)("(%p,%ld,%ld): stub\n", lpTimeFmtEnumProc
, Locale
, dwFlags
);
3045 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
3049 /**************************************************************************
3050 * GetNumberFormat32A (KERNEL32.355)
3052 INT WINAPI
GetNumberFormatA(LCID locale
, DWORD dwflags
,
3053 LPCSTR lpvalue
, const NUMBERFMTA
* lpFormat
,
3054 LPSTR lpNumberStr
, int cchNumber
)
3056 FIXME_(file
)("%s: stub, no reformating done\n",lpvalue
);
3058 lstrcpynA( lpNumberStr
, lpvalue
, cchNumber
);
3059 return cchNumber
? lstrlenA( lpNumberStr
) : 0;
3061 /**************************************************************************
3062 * GetNumberFormat32W (KERNEL32.xxx)
3064 INT WINAPI
GetNumberFormatW(LCID locale
, DWORD dwflags
,
3065 LPCWSTR lpvalue
, const NUMBERFMTW
* lpFormat
,
3066 LPWSTR lpNumberStr
, int cchNumber
)
3068 FIXME_(file
)("%s: stub, no reformating done\n",debugstr_w(lpvalue
));
3070 lstrcpynW( lpNumberStr
, lpvalue
, cchNumber
);
3071 return cchNumber
? lstrlenW( lpNumberStr
) : 0;
3073 /******************************************************************************
3074 * OLE2NLS_CheckLocale [intern]
3076 static LCID
OLE2NLS_CheckLocale (LCID locale
)
3079 { locale
= LOCALE_SYSTEM_DEFAULT
;
3082 if (locale
== LOCALE_SYSTEM_DEFAULT
)
3083 { return GetSystemDefaultLCID();
3085 else if (locale
== LOCALE_USER_DEFAULT
)
3086 { return GetUserDefaultLCID();
3092 /******************************************************************************
3093 * GetTimeFormat32A [KERNEL32.422]
3094 * Makes an ASCII string of the time
3096 * Formats date according to format, or locale default if format is
3097 * NULL. The format consists of literal characters and fields as follows:
3099 * h hours with no leading zero (12-hour)
3100 * hh hours with full two digits
3101 * H hours with no leading zero (24-hour)
3102 * HH hours with full two digits
3103 * m minutes with no leading zero
3104 * mm minutes with full two digits
3105 * s seconds with no leading zero
3106 * ss seconds with full two digits
3107 * t time marker (A or P)
3108 * tt time marker (AM, PM)
3112 GetTimeFormatA(LCID locale
, /* in */
3113 DWORD flags
, /* in */
3114 LPSYSTEMTIME xtime
, /* in */
3115 LPCSTR format
, /* in */
3116 LPSTR timestr
, /* out */
3117 INT timelen
/* in */)
3118 { char format_buf
[40];
3121 LPSYSTEMTIME thistime
;
3123 DWORD thisflags
=LOCALE_STIMEFORMAT
; /* standart timeformat */
3126 TRACE_(ole
)("GetTimeFormat(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",locale
,flags
,xtime
,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 GetLocaleInfoA(thislocale
, thisflags
, format_buf
, sizeof(format_buf
));
3141 thisformat
= format_buf
;
3144 { thisformat
= format
;
3147 if (xtime
== NULL
) /* NULL means use the current local time*/
3154 ret
= OLE_GetFormatA(thislocale
, thisflags
, flags
, thistime
, thisformat
,
3160 /******************************************************************************
3161 * GetTimeFormat32W [KERNEL32.423]
3162 * Makes a Unicode string of the time
3165 GetTimeFormatW(LCID locale
, /* in */
3166 DWORD flags
, /* in */
3167 LPSYSTEMTIME xtime
, /* in */
3168 LPCWSTR format
, /* in */
3169 LPWSTR timestr
, /* out */
3170 INT timelen
/* in */)
3171 { WCHAR format_buf
[40];
3174 LPSYSTEMTIME thistime
;
3176 DWORD thisflags
=LOCALE_STIMEFORMAT
; /* standart timeformat */
3179 TRACE_(ole
)("GetTimeFormat(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",locale
,flags
,
3180 xtime
,debugstr_w(format
),timestr
,timelen
);
3182 thislocale
= OLE2NLS_CheckLocale ( locale
);
3184 if ( flags
& (TIME_NOTIMEMARKER
| TIME_FORCE24HOURFORMAT
))
3185 { FIXME_(ole
)("TIME_NOTIMEMARKER or TIME_FORCE24HOURFORMAT not implemented\n");
3188 flags
&= (TIME_NOSECONDS
| TIME_NOMINUTESORSECONDS
); /* mask for OLE_GetFormatA*/
3191 { if (flags
& LOCALE_NOUSEROVERRIDE
) /*use system default*/
3192 { thislocale
= GetSystemDefaultLCID();
3194 GetLocaleInfoW(thislocale
, thisflags
, format_buf
, 40);
3195 thisformat
= format_buf
;
3198 { thisformat
= format
;
3201 if (xtime
== NULL
) /* NULL means use the current local time*/
3202 { GetSystemTime(&t
);
3209 ret
= OLE_GetFormatW(thislocale
, thisflags
, flags
, thistime
, thisformat
,
3214 /******************************************************************************
3215 * EnumCalendarInfoA [KERNEL32.196]
3217 BOOL WINAPI
EnumCalendarInfoA(
3218 CALINFO_ENUMPROCA calinfoproc
,LCID locale
,CALID calendar
,CALTYPE caltype
3220 FIXME_(ole
)("(%p,0x%04lx,0x%08lx,0x%08lx),stub!\n",calinfoproc
,locale
,calendar
,caltype
);