4 * Copyright 1995 Martin von Loewis
5 * Copyright 1998 David Lee Lambert
18 #include "debugtools.h"
22 DEFAULT_DEBUG_CHANNEL(ole
)
23 DECLARE_DEBUG_CHANNEL(file
)
24 DECLARE_DEBUG_CHANNEL(string
)
25 DECLARE_DEBUG_CHANNEL(win32
)
27 struct NLS_langlocale
{
29 struct NLS_localevar
{
35 static LPVOID lpNLSInfo
= NULL
;
37 #define LANG_BEGIN(l,s) { MAKELANGID(l,s), {
39 #define LOCVAL(type,value) {type,value},
43 static const struct NLS_langlocale langlocales
[] = {
44 /* add languages in numerical order of main language (last two digits)
45 * it is much easier to find the missing holes that way */
47 LANG_BEGIN (LANG_CATALAN
, SUBLANG_DEFAULT
) /*0x0403*/
48 #include "nls/cat.nls"
51 LANG_BEGIN (LANG_CZECH
, SUBLANG_DEFAULT
) /*0x0405*/
52 #include "nls/cze.nls"
55 LANG_BEGIN (LANG_DANISH
, SUBLANG_DEFAULT
) /*0x0406*/
56 #include "nls/dan.nls"
59 LANG_BEGIN (LANG_GERMAN
, SUBLANG_GERMAN
) /*0x0407*/
60 #include "nls/deu.nls"
62 LANG_BEGIN (LANG_GERMAN
, SUBLANG_GERMAN_SWISS
) /*0x0807*/
63 #include "nls/des.nls"
65 LANG_BEGIN (LANG_GERMAN
, SUBLANG_GERMAN_AUSTRIAN
) /*0x0C07*/
66 #include "nls/dea.nls"
68 LANG_BEGIN (LANG_GERMAN
, SUBLANG_GERMAN_LUXEMBOURG
) /*0x1007*/
69 #include "nls/del.nls"
71 LANG_BEGIN (LANG_GERMAN
, SUBLANG_GERMAN_LIECHTENSTEIN
) /*0x1407*/
72 #include "nls/dec.nls"
75 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_US
) /*0x0409*/
76 #include "nls/enu.nls"
78 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_UK
) /*0x0809*/
79 #include "nls/eng.nls"
81 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_AUS
) /*0x0C09*/
82 #include "nls/ena.nls"
84 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_CAN
) /*0x1009*/
85 #include "nls/enc.nls"
87 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_NZ
) /*0x1409*/
88 #include "nls/enz.nls"
90 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_EIRE
) /*0x1809*/
91 #include "nls/irl.nls"
93 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_SAFRICA
) /*0x1C09*/
94 #include "nls/ens.nls"
96 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_JAMAICA
) /*0x2009*/
97 #include "nls/enj.nls"
99 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_CARRIBEAN
) /*0x2409*/
100 #include "nls/enb.nls"
102 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_BELIZE
) /*0x2809*/
103 #include "nls/enl.nls"
105 LANG_BEGIN (LANG_ENGLISH
, SUBLANG_ENGLISH_TRINIDAD
) /*0x2C09*/
106 #include "nls/ent.nls"
109 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH
) /*0x040a*/
110 #include "nls/esp.nls"
112 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_MEXICAN
) /*0x080a*/
113 #include "nls/esm.nls"
115 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_MODERN
) /*0x0C0a*/
116 #include "nls/esn.nls"
118 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_GUATEMALA
) /*0x100a*/
119 #include "nls/esg.nls"
121 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_COSTARICA
) /*0x140a*/
122 #include "nls/esc.nls"
124 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_PANAMA
) /*0x180a*/
125 #include "nls/esa.nls"
127 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_DOMINICAN
) /*0x1C0A*/
128 #include "nls/esd.nls"
130 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_VENEZUELA
) /*0x200a*/
131 #include "nls/esv.nls"
133 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_COLOMBIA
) /*0x240a*/
134 #include "nls/eso.nls"
136 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_PERU
) /*0x280a*/
137 #include "nls/esr.nls"
139 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_ARGENTINA
) /*0x2c0a*/
140 #include "nls/ess.nls"
142 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_ECUADOR
) /*0x300a*/
143 #include "nls/esf.nls"
145 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_CHILE
) /*0x340a*/
146 #include "nls/esl.nls"
148 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_URUGUAY
) /*0x380a*/
149 #include "nls/esy.nls"
151 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_PARAGUAY
) /*0x3c0a*/
152 #include "nls/esz.nls"
154 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_BOLIVIA
) /*0x400a*/
155 #include "nls/esb.nls"
157 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_EL_SALVADOR
) /*0x440a*/
158 #include "nls/ese.nls"
160 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_HONDURAS
) /*0x480a*/
161 #include "nls/esh.nls"
163 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_NICARAGUA
) /*0x4c0a*/
164 #include "nls/esi.nls"
166 LANG_BEGIN (LANG_SPANISH
, SUBLANG_SPANISH_PUERTO_RICO
) /*0x500a*/
167 #include "nls/esu.nls"
170 LANG_BEGIN (LANG_FINNISH
, SUBLANG_DEFAULT
) /*0x040B*/
171 #include "nls/fin.nls"
174 LANG_BEGIN (LANG_FRENCH
, SUBLANG_FRENCH
) /*0x040C*/
175 #include "nls/fra.nls"
177 LANG_BEGIN (LANG_FRENCH
, SUBLANG_FRENCH_BELGIAN
) /*0x080C*/
178 #include "nls/frb.nls"
180 LANG_BEGIN (LANG_FRENCH
, SUBLANG_FRENCH_CANADIAN
) /*0x0C0C*/
181 #include "nls/frc.nls"
183 LANG_BEGIN (LANG_FRENCH
, SUBLANG_FRENCH_SWISS
) /*0x100C*/
184 #include "nls/frs.nls"
186 LANG_BEGIN (LANG_FRENCH
, SUBLANG_FRENCH_LUXEMBOURG
) /*0x140C*/
187 #include "nls/frl.nls"
190 LANG_BEGIN (LANG_HUNGARIAN
, SUBLANG_DEFAULT
) /*0x040e*/
191 #include "nls/hun.nls"
194 LANG_BEGIN (LANG_ITALIAN
, SUBLANG_ITALIAN
) /*0x0410*/
195 #include "nls/ita.nls"
197 LANG_BEGIN (LANG_ITALIAN
, SUBLANG_ITALIAN_SWISS
) /*0x0810*/
198 #include "nls/its.nls"
201 LANG_BEGIN (LANG_KOREAN
, SUBLANG_KOREAN
) /*0x0412*/
202 #include "nls/kor.nls"
205 LANG_BEGIN (LANG_DUTCH
, SUBLANG_DUTCH
) /*0x0413*/
206 #include "nls/nld.nls"
208 LANG_BEGIN (LANG_DUTCH
, SUBLANG_DUTCH_BELGIAN
) /*0x0813*/
209 #include "nls/nlb.nls"
211 LANG_BEGIN (LANG_DUTCH
, SUBLANG_DUTCH_SURINAM
) /*0x0C13*/
212 #include "nls/nls.nls"
215 LANG_BEGIN (LANG_NORWEGIAN
, SUBLANG_NORWEGIAN_BOKMAL
) /*0x0414*/
216 #include "nls/nor.nls"
218 LANG_BEGIN (LANG_NORWEGIAN
, SUBLANG_NORWEGIAN_NYNORSK
) /*0x0814*/
219 #include "nls/non.nls"
222 LANG_BEGIN (LANG_POLISH
, SUBLANG_DEFAULT
) /*0x0415*/
223 #include "nls/plk.nls"
226 LANG_BEGIN (LANG_PORTUGUESE
,SUBLANG_PORTUGUESE_BRAZILIAN
) /*0x0416*/
227 #include "nls/ptb.nls"
229 LANG_BEGIN (LANG_PORTUGUESE
,SUBLANG_PORTUGUESE
) /*0x0816*/
230 #include "nls/ptg.nls"
233 LANG_BEGIN (LANG_RUSSIAN
, SUBLANG_DEFAULT
) /*0x419*/
234 #include "nls/rus.nls"
237 LANG_BEGIN (LANG_SLOVAK
, SUBLANG_DEFAULT
) /*0x041b*/
238 #include "nls/sky.nls"
241 LANG_BEGIN (LANG_SWEDISH
, SUBLANG_SWEDISH
) /*0x041d*/
242 #include "nls/sve.nls"
244 LANG_BEGIN (LANG_SWEDISH
, SUBLANG_SWEDISH_FINLAND
) /*0x081d*/
245 #include "nls/svf.nls"
248 LANG_BEGIN (LANG_THAI
, SUBLANG_DEFAULT
) /*0x41e*/
249 #include "nls/tha.nls"
252 LANG_BEGIN (LANG_ESPERANTO
, SUBLANG_DEFAULT
) /*0x048f*/
253 #include "nls/esperanto.nls"
256 LANG_BEGIN (LANG_WALON
, SUBLANG_DEFAULT
) /*0x0490*/
257 #include "nls/wal.nls"
262 /* Locale name to id map. used by EnumSystemLocales, GetLocaleInfoA
263 * MUST contain all #defines from winnls.h
264 * last entry has NULL name, 0 id.
266 #define LOCALE_ENTRY(x) {#x,LOCALE_##x}
267 static struct tagLOCALE_NAME2ID
{
270 } locale_name2id
[]= {
271 LOCALE_ENTRY(ILANGUAGE
),
272 LOCALE_ENTRY(SLANGUAGE
),
273 LOCALE_ENTRY(SENGLANGUAGE
),
274 LOCALE_ENTRY(SABBREVLANGNAME
),
275 LOCALE_ENTRY(SNATIVELANGNAME
),
276 LOCALE_ENTRY(ICOUNTRY
),
277 LOCALE_ENTRY(SCOUNTRY
),
278 LOCALE_ENTRY(SENGCOUNTRY
),
279 LOCALE_ENTRY(SABBREVCTRYNAME
),
280 LOCALE_ENTRY(SNATIVECTRYNAME
),
281 LOCALE_ENTRY(IDEFAULTLANGUAGE
),
282 LOCALE_ENTRY(IDEFAULTCOUNTRY
),
283 LOCALE_ENTRY(IDEFAULTCODEPAGE
),
284 LOCALE_ENTRY(IDEFAULTANSICODEPAGE
),
285 LOCALE_ENTRY(IDEFAULTMACCODEPAGE
),
287 LOCALE_ENTRY(IMEASURE
),
288 LOCALE_ENTRY(SDECIMAL
),
289 LOCALE_ENTRY(STHOUSAND
),
290 LOCALE_ENTRY(SGROUPING
),
291 LOCALE_ENTRY(IDIGITS
),
292 LOCALE_ENTRY(ILZERO
),
293 LOCALE_ENTRY(INEGNUMBER
),
294 LOCALE_ENTRY(SNATIVEDIGITS
),
295 LOCALE_ENTRY(SCURRENCY
),
296 LOCALE_ENTRY(SINTLSYMBOL
),
297 LOCALE_ENTRY(SMONDECIMALSEP
),
298 LOCALE_ENTRY(SMONTHOUSANDSEP
),
299 LOCALE_ENTRY(SMONGROUPING
),
300 LOCALE_ENTRY(ICURRDIGITS
),
301 LOCALE_ENTRY(IINTLCURRDIGITS
),
302 LOCALE_ENTRY(ICURRENCY
),
303 LOCALE_ENTRY(INEGCURR
),
306 LOCALE_ENTRY(SSHORTDATE
),
307 LOCALE_ENTRY(SLONGDATE
),
308 LOCALE_ENTRY(STIMEFORMAT
),
310 LOCALE_ENTRY(ILDATE
),
312 LOCALE_ENTRY(ITIMEMARKPOSN
),
313 LOCALE_ENTRY(ICENTURY
),
314 LOCALE_ENTRY(ITLZERO
),
315 LOCALE_ENTRY(IDAYLZERO
),
316 LOCALE_ENTRY(IMONLZERO
),
319 LOCALE_ENTRY(ICALENDARTYPE
),
320 LOCALE_ENTRY(IOPTIONALCALENDAR
),
321 LOCALE_ENTRY(IFIRSTDAYOFWEEK
),
322 LOCALE_ENTRY(IFIRSTWEEKOFYEAR
),
323 LOCALE_ENTRY(SDAYNAME1
),
324 LOCALE_ENTRY(SDAYNAME2
),
325 LOCALE_ENTRY(SDAYNAME3
),
326 LOCALE_ENTRY(SDAYNAME4
),
327 LOCALE_ENTRY(SDAYNAME5
),
328 LOCALE_ENTRY(SDAYNAME6
),
329 LOCALE_ENTRY(SDAYNAME7
),
330 LOCALE_ENTRY(SABBREVDAYNAME1
),
331 LOCALE_ENTRY(SABBREVDAYNAME2
),
332 LOCALE_ENTRY(SABBREVDAYNAME3
),
333 LOCALE_ENTRY(SABBREVDAYNAME4
),
334 LOCALE_ENTRY(SABBREVDAYNAME5
),
335 LOCALE_ENTRY(SABBREVDAYNAME6
),
336 LOCALE_ENTRY(SABBREVDAYNAME7
),
337 LOCALE_ENTRY(SMONTHNAME1
),
338 LOCALE_ENTRY(SMONTHNAME2
),
339 LOCALE_ENTRY(SMONTHNAME3
),
340 LOCALE_ENTRY(SMONTHNAME4
),
341 LOCALE_ENTRY(SMONTHNAME5
),
342 LOCALE_ENTRY(SMONTHNAME6
),
343 LOCALE_ENTRY(SMONTHNAME7
),
344 LOCALE_ENTRY(SMONTHNAME8
),
345 LOCALE_ENTRY(SMONTHNAME9
),
346 LOCALE_ENTRY(SMONTHNAME10
),
347 LOCALE_ENTRY(SMONTHNAME11
),
348 LOCALE_ENTRY(SMONTHNAME12
),
349 LOCALE_ENTRY(SMONTHNAME13
),
350 LOCALE_ENTRY(SABBREVMONTHNAME1
),
351 LOCALE_ENTRY(SABBREVMONTHNAME2
),
352 LOCALE_ENTRY(SABBREVMONTHNAME3
),
353 LOCALE_ENTRY(SABBREVMONTHNAME4
),
354 LOCALE_ENTRY(SABBREVMONTHNAME5
),
355 LOCALE_ENTRY(SABBREVMONTHNAME6
),
356 LOCALE_ENTRY(SABBREVMONTHNAME7
),
357 LOCALE_ENTRY(SABBREVMONTHNAME8
),
358 LOCALE_ENTRY(SABBREVMONTHNAME9
),
359 LOCALE_ENTRY(SABBREVMONTHNAME10
),
360 LOCALE_ENTRY(SABBREVMONTHNAME11
),
361 LOCALE_ENTRY(SABBREVMONTHNAME12
),
362 LOCALE_ENTRY(SABBREVMONTHNAME13
),
363 LOCALE_ENTRY(SPOSITIVESIGN
),
364 LOCALE_ENTRY(SNEGATIVESIGN
),
365 LOCALE_ENTRY(IPOSSIGNPOSN
),
366 LOCALE_ENTRY(INEGSIGNPOSN
),
367 LOCALE_ENTRY(IPOSSYMPRECEDES
),
368 LOCALE_ENTRY(IPOSSEPBYSPACE
),
369 LOCALE_ENTRY(INEGSYMPRECEDES
),
370 LOCALE_ENTRY(INEGSEPBYSPACE
),
371 LOCALE_ENTRY(FONTSIGNATURE
),
372 LOCALE_ENTRY(SISO639LANGNAME
),
373 LOCALE_ENTRY(SISO3166CTRYNAME
),
377 const struct map_lcid2str
{
379 const char *langname
;
381 {0x0401,"Arabic (Saudi Arabia)"},
382 {0x0801,"Arabic (Iraq)"},
383 {0x0c01,"Arabic (Egypt)"},
384 {0x1001,"Arabic (Libya)"},
385 {0x1401,"Arabic (Algeria)"},
386 {0x1801,"Arabic (Morocco)"},
387 {0x1c01,"Arabic (Tunisia)"},
388 {0x2001,"Arabic (Oman)"},
389 {0x2401,"Arabic (Yemen)"},
390 {0x2801,"Arabic (Syria)"},
391 {0x2c01,"Arabic (Jordan)"},
392 {0x3001,"Arabic (Lebanon)"},
393 {0x3401,"Arabic (Kuwait)"},
394 {0x3801,"Arabic (United Arab Emirates)"},
395 {0x3c01,"Arabic (Bahrain)"},
396 {0x4001,"Arabic (Qatar)"},
397 {0x0402,"Bulgarian"},
399 {0x0404,"Chinese (Taiwan)"},
400 {0x0804,"Chinese (People's Republic of China)"},
401 {0x0c04,"Chinese (Hong Kong)"},
402 {0x1004,"Chinese (Singapore)"},
403 {0x1404,"Chinese (Macau)"},
406 {0x0407,"German (Germany)"},
407 {0x0807,"German (Switzerland)"},
408 {0x0c07,"German (Austria)"},
409 {0x1007,"German (Luxembourg)"},
410 {0x1407,"German (Liechtenstein)"},
412 {0x0409,"English (United States)"},
413 {0x0809,"English (United Kingdom)"},
414 {0x0c09,"English (Australia)"},
415 {0x1009,"English (Canada)"},
416 {0x1409,"English (New Zealand)"},
417 {0x1809,"English (Ireland)"},
418 {0x1c09,"English (South Africa)"},
419 {0x2009,"English (Jamaica)"},
420 {0x2409,"English (Caribbean)"},
421 {0x2809,"English (Belize)"},
422 {0x2c09,"English (Trinidad)"},
423 {0x3009,"English (Zimbabwe)"},
424 {0x3409,"English (Philippines)"},
425 {0x040a,"Spanish (Spain, traditional sorting)"},
426 {0x080a,"Spanish (Mexico)"},
427 {0x0c0a,"Spanish (Spain, international sorting)"},
428 {0x100a,"Spanish (Guatemala)"},
429 {0x140a,"Spanish (Costa Rica)"},
430 {0x180a,"Spanish (Panama)"},
431 {0x1c0a,"Spanish (Dominican Republic)"},
432 {0x200a,"Spanish (Venezuela)"},
433 {0x240a,"Spanish (Colombia)"},
434 {0x280a,"Spanish (Peru)"},
435 {0x2c0a,"Spanish (Argentina)"},
436 {0x300a,"Spanish (Ecuador)"},
437 {0x340a,"Spanish (Chile)"},
438 {0x380a,"Spanish (Uruguay)"},
439 {0x3c0a,"Spanish (Paraguay)"},
440 {0x400a,"Spanish (Bolivia)"},
441 {0x440a,"Spanish (El Salvador)"},
442 {0x480a,"Spanish (Honduras)"},
443 {0x4c0a,"Spanish (Nicaragua)"},
444 {0x500a,"Spanish (Puerto Rico)"},
446 {0x040c,"French (France)"},
447 {0x080c,"French (Belgium)"},
448 {0x0c0c,"French (Canada)"},
449 {0x100c,"French (Switzerland)"},
450 {0x140c,"French (Luxembourg)"},
451 {0x180c,"French (Monaco)"},
453 {0x040e,"Hungarian"},
454 {0x040f,"Icelandic"},
455 {0x0410,"Italian (Italy)"},
456 {0x0810,"Italian (Switzerland)"},
458 {0x0412,"Korean (Wansung)"},
459 {0x0812,"Korean (Johab)"},
460 {0x0413,"Dutch (Netherlands)"},
461 {0x0813,"Dutch (Belgium)"},
462 {0x0414,"Norwegian (Bokmal)"},
463 {0x0814,"Norwegian (Nynorsk)"},
465 {0x0416,"Portuguese (Brazil)"},
466 {0x0816,"Portuguese (Portugal)"},
467 {0x0417,"Rhaeto Romanic"},
469 {0x0818,"Moldavian"},
470 {0x0419,"Russian (Russia)"},
471 {0x0819,"Russian (Moldavia)"},
473 {0x081a,"Serbian (latin)"},
474 {0x0c1a,"Serbian (cyrillic)"},
477 {0x041d,"Swedish (Sweden)"},
478 {0x081d,"Swedish (Finland)"},
482 {0x0421,"Indonesian"},
483 {0x0422,"Ukrainian"},
484 {0x0423,"Belarusian"},
488 {0x0427,"Lithuanian (modern)"},
489 {0x0827,"Lithuanian (classic)"},
492 {0x042a,"Vietnamese"},
494 {0x042c,"Azeri (latin)"},
495 {0x082c,"Azeri (cyrillic)"},
498 {0x042f,"Macedonian"},
505 {0x0436,"Afrikaans"},
511 {0x043c,"Irish gaelic"},
512 {0x083c,"Scottish gaelic"},
513 {0x043e,"Malay (Malaysia)"},
514 {0x083e,"Malay (Brunei Darussalam)"},
517 {0x0443,"Uzbek (latin)"},
518 {0x0843,"Uzbek (cyrillic)"},
527 {0x044c,"Malayalam"},
532 {0x048f,"Esperanto"}, /* Non official */
533 {0x0490,"Walon"}, /* Non official */
537 {0x0402,"Bulgarisch"},
538 {0x0403,"Katalanisch"},
539 {0x0404,"Traditionales Chinesisch"},
540 {0x0405,"Tschecisch"},
543 {0x0408,"Griechisch"},
544 {0x0409,"Amerikanisches Englisch"},
545 {0x040A,"Kastilisches Spanisch"},
547 {0x040C,"Franzvsisch"},
548 {0x040D,"Hebrdisch"},
549 {0x040E,"Ungarisch"},
550 {0x040F,"Isldndisch"},
551 {0x0410,"Italienisch"},
552 {0x0411,"Japanisch"},
553 {0x0412,"Koreanisch"},
554 {0x0413,"Niederldndisch"},
555 {0x0414,"Norwegisch-Bokmal"},
557 {0x0416,"Brasilianisches Portugiesisch"},
558 {0x0417,"Rdtoromanisch"},
559 {0x0418,"Rumdnisch"},
561 {0x041A,"Kroatoserbisch (lateinisch)"},
562 {0x041B,"Slowenisch"},
563 {0x041C,"Albanisch"},
564 {0x041D,"Schwedisch"},
569 {0x0804,"Vereinfachtes Chinesisch"},
570 {0x0807,"Schweizerdeutsch"},
571 {0x0809,"Britisches Englisch"},
572 {0x080A,"Mexikanisches Spanisch"},
573 {0x080C,"Belgisches Franzvsisch"},
574 {0x0810,"Schweizerisches Italienisch"},
575 {0x0813,"Belgisches Niederldndisch"},
576 {0x0814,"Norgwegisch-Nynorsk"},
577 {0x0816,"Portugiesisch"},
578 {0x081A,"Serbokratisch (kyrillisch)"},
579 {0x0C1C,"Kanadisches Franzvsisch"},
580 {0x100C,"Schweizerisches Franzvsisch"},
581 {0x0000,"Unbekannt"},
584 /***********************************************************************
585 * GetUserDefaultLCID (OLE2NLS.1)
587 LCID WINAPI
GetUserDefaultLCID()
589 return MAKELCID( GetUserDefaultLangID() , SORT_DEFAULT
);
592 /***********************************************************************
593 * GetSystemDefaultLCID (OLE2NLS.2)
595 LCID WINAPI
GetSystemDefaultLCID()
597 return GetUserDefaultLCID();
600 /***********************************************************************
601 * GetUserDefaultLangID (OLE2NLS.3)
603 LANGID WINAPI
GetUserDefaultLangID()
605 /* caching result, if defined from environment, which should (?) not change during a WINE session */
606 static LANGID userLCID
= 0;
607 if (Options
.language
) {
608 return Languages
[Options
.language
].langid
;
613 char *lang
,*country
,*charset
,*dialect
,*next
;
616 buf
=getenv("LANGUAGE");
617 if (!buf
) buf
=getenv("LANG");
618 if (!buf
) buf
=getenv("LC_ALL");
619 if (!buf
) buf
=getenv("LC_MESSAGES");
620 if (!buf
) buf
=getenv("LC_CTYPE");
621 if (!buf
) return userLCID
= MAKELANGID( LANG_ENGLISH
, SUBLANG_DEFAULT
);
623 if (!strcmp(buf
,"POSIX") || !strcmp(buf
,"C")) {
624 return MAKELANGID( LANG_ENGLISH
, SUBLANG_DEFAULT
);
630 next
=strchr(lang
,':'); if (next
) *next
++='\0';
631 dialect
=strchr(lang
,'@'); if (dialect
) *dialect
++='\0';
632 charset
=strchr(lang
,'.'); if (charset
) *charset
++='\0';
633 country
=strchr(lang
,'_'); if (country
) *country
++='\0';
635 ret
=MAIN_GetLanguageID(lang
, country
, charset
, dialect
);
639 } while (lang
&& !ret
);
641 /* FIXME : are strings returned by getenv() to be free()'ed ? */
642 userLCID
= (LANGID
)ret
;
647 /***********************************************************************
648 * GetSystemDefaultLangID (OLE2NLS.4)
650 LANGID WINAPI
GetSystemDefaultLangID()
652 return GetUserDefaultLangID();
655 /******************************************************************************
656 * GetLocaleInfo16 [OLE2NLS.5]
657 * Is the last parameter really WORD for Win16?
659 INT16 WINAPI
GetLocaleInfo16(LCID lcid
,LCTYPE LCType
,LPSTR buf
,INT16 len
)
661 return GetLocaleInfoA(lcid
,LCType
,buf
,len
);
663 /******************************************************************************
664 * ConvertDefaultLocale32 [KERNEL32.147]
666 LCID WINAPI
ConvertDefaultLocale32 (LCID lcid
)
668 { case LOCALE_SYSTEM_DEFAULT
:
669 return GetSystemDefaultLCID();
670 case LOCALE_USER_DEFAULT
:
671 return GetUserDefaultLCID();
673 return MAKELCID (LANG_NEUTRAL
, SUBLANG_NEUTRAL
);
675 return MAKELANGID( PRIMARYLANGID(lcid
), SUBLANG_NEUTRAL
);
677 /******************************************************************************
678 * GetLocaleInfo32A [KERNEL32.342]
681 * LANG_NEUTRAL is equal to LOCALE_SYSTEM_DEFAULT
683 * MS online documentation states that the string returned is NULL terminated
684 * except for LOCALE_FONTSIGNATURE which "will return a non-NULL
685 * terminated string".
687 INT WINAPI
GetLocaleInfoA(LCID lcid
,LCTYPE LCType
,LPSTR buf
,INT len
)
693 TRACE("(lcid=0x%lx,lctype=0x%lx,%p,%x)\n",lcid
,LCType
,buf
,len
);
695 if (len
&& (! buf
) ) {
696 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
700 if (lcid
==0 || lcid
== LANG_SYSTEM_DEFAULT
|| (LCType
& LOCALE_NOUSEROVERRIDE
) ) /* 0x00, 0x400 */
702 lcid
= GetSystemDefaultLCID();
704 else if (lcid
== LANG_USER_DEFAULT
) /*0x800*/
706 lcid
= GetUserDefaultLCID();
708 LCType
&= ~(LOCALE_NOUSEROVERRIDE
|LOCALE_USE_CP_ACP
);
710 /* As an option, we could obtain the value from win.ini.
711 This would not match the Wine compile-time option.
712 Also, not all identifiers are available from win.ini */
714 /* If we are through all of this, retLen should not be zero anymore.
715 If it is, the value is not supported */
717 while (locale_name2id
[i
].name
!=NULL
) {
718 if (LCType
== locale_name2id
[i
].id
) {
719 retString
= locale_name2id
[i
].name
;
725 FIXME("Unkown LC type %lX\n",LCType
);
730 for (i
=0;(i
<3 && !found
);i
++) {
733 for (j
=0;j
<sizeof(langlocales
)/sizeof(langlocales
[0]);j
++) {
734 if (langlocales
[j
].lang
== lang
) {
737 for (k
=0;k
<sizeof(langlocales
[j
].locvars
)/sizeof(langlocales
[j
].locvars
[0]) && (langlocales
[j
].locvars
[k
].type
);k
++) {
738 if (langlocales
[j
].locvars
[k
].type
== LCType
) {
740 retString
= langlocales
[j
].locvars
[k
].val
;
748 /* language not found, try without a sublanguage*/
749 if (i
==1) lang
=MAKELANGID( PRIMARYLANGID(lang
), SUBLANG_DEFAULT
);
750 /* mask the LC Value */
751 if (i
==2) LCType
&= 0xfff;
755 ERR("'%s' not supported for your language (%04X).\n",
756 retString
,(WORD
)lcid
);
757 SetLastError(ERROR_INVALID_PARAMETER
);
760 /* a FONTSIGNATURE is not a string, just 6 DWORDs */
761 if (LCType
== LOCALE_FONTSIGNATURE
) {
763 memcpy(buf
, retString
, (len
<=sizeof(FONTSIGNATURE
))?len
:sizeof(FONTSIGNATURE
));
764 return sizeof(FONTSIGNATURE
);
766 /* if len=0 return only the length, don't touch the buffer*/
767 if (len
) lstrcpynA(buf
,retString
,len
);
768 return strlen(retString
)+1;
771 /******************************************************************************
772 * GetLocaleInfo32W [KERNEL32.343]
775 * MS documentation states that len "specifies the size, in bytes (ANSI version)
776 * or characters (Unicode version), of" wbuf. Thus the number returned is
777 * the same between GetLocaleInfo32W and GetLocaleInfo32A.
779 INT WINAPI
GetLocaleInfoW(LCID lcid
,LCTYPE LCType
,LPWSTR wbuf
,INT len
)
783 if (len
&& (! wbuf
) )
784 { SetLastError(ERROR_INSUFFICIENT_BUFFER
);
788 abuf
= (LPSTR
)HeapAlloc(GetProcessHeap(),0,len
);
789 wlen
= GetLocaleInfoA(lcid
, LCType
, abuf
, len
);
791 if (wlen
&& len
) /* if len=0 return only the length*/
792 lstrcpynAtoW(wbuf
,abuf
,len
);
794 HeapFree(GetProcessHeap(),0,abuf
);
798 /******************************************************************************
799 * SetLocaleInfoA [KERNEL32.656]
801 BOOL16 WINAPI
SetLocaleInfoA(DWORD lcid
, DWORD lctype
, LPCSTR data
)
803 FIXME("(%ld,%ld,%s): stub\n",lcid
,lctype
,data
);
807 /******************************************************************************
808 * IsValidLocale [KERNEL32.489]
810 BOOL WINAPI
IsValidLocale(LCID lcid
,DWORD flags
)
812 /* we support ANY language. Well, at least say that...*/
816 /******************************************************************************
817 * EnumSystemLocales32W [KERNEL32.209]
819 BOOL WINAPI
EnumSystemLocalesW( LOCALE_ENUMPROCW lpfnLocaleEnum
,
827 TRACE_(win32
)("(%p,%08lx)\n",lpfnLocaleEnum
,flags
);
828 /* see if we can reuse the Win95 registry entries.... */
829 if (ERROR_SUCCESS
==RegOpenKeyA(HKEY_LOCAL_MACHINE
,"System\\CurrentControlSet\\control\\Nls\\Locale\\",&xhkey
)) {
832 if (ERROR_SUCCESS
!=RegEnumKeyW(xhkey
,i
,buffer
,sizeof(buffer
)))
834 if (!lpfnLocaleEnum(buffer
))
843 while (languages
[i
].langid
!=0)
848 sprintf(xbuffer
,"%08lx",(DWORD
)languages
[i
].langid
);
850 cp
= HEAP_strdupAtoW( GetProcessHeap(), 0, xbuffer
);
851 ret
= lpfnLocaleEnum(cp
);
852 HeapFree( GetProcessHeap(), 0, cp
);
859 /******************************************************************************
860 * EnumSystemLocales32A [KERNEL32.208]
862 BOOL WINAPI
EnumSystemLocalesA(LOCALE_ENUMPROCA lpfnLocaleEnum
,
869 TRACE_(win32
)("(%p,%08lx)\n",
873 if ( ERROR_SUCCESS
==RegOpenKeyA(HKEY_LOCAL_MACHINE
,
874 "System\\CurrentControlSet\\Control\\Nls\\Locale\\",
878 DWORD size
=sizeof(buffer
);
879 if (ERROR_SUCCESS
!=RegEnumValueA(xhkey
,i
,buffer
,&size
,NULL
,
882 if (size
&& !lpfnLocaleEnum(buffer
))
890 while (languages
[i
].langid
!=0) {
891 sprintf(buffer
,"%08lx",(DWORD
)languages
[i
].langid
);
892 if (!lpfnLocaleEnum(buffer
))
899 static const unsigned char CT_CType2_LUT
[] = {
900 C2_NOTAPPLICABLE
, /* - 0 */
901 C2_NOTAPPLICABLE
, /* - 1 */
902 C2_NOTAPPLICABLE
, /* - 2 */
903 C2_NOTAPPLICABLE
, /* - 3 */
904 C2_NOTAPPLICABLE
, /* - 4 */
905 C2_NOTAPPLICABLE
, /* - 5 */
906 C2_NOTAPPLICABLE
, /* - 6 */
907 C2_NOTAPPLICABLE
, /* - 7 */
908 C2_NOTAPPLICABLE
, /* - 8 */
909 C2_SEGMENTSEPARATOR
, /* - 9 */
910 C2_NOTAPPLICABLE
, /* - 10 */
911 C2_NOTAPPLICABLE
, /* - 11 */
912 C2_NOTAPPLICABLE
, /* - 12 */
913 C2_NOTAPPLICABLE
, /* - 13 */
914 C2_NOTAPPLICABLE
, /* - 14 */
915 C2_NOTAPPLICABLE
, /* - 15 */
916 C2_NOTAPPLICABLE
, /* - 16 */
917 C2_NOTAPPLICABLE
, /* - 17 */
918 C2_NOTAPPLICABLE
, /* - 18 */
919 C2_NOTAPPLICABLE
, /* - 19 */
920 C2_NOTAPPLICABLE
, /* - 20 */
921 C2_NOTAPPLICABLE
, /* - 21 */
922 C2_NOTAPPLICABLE
, /* - 22 */
923 C2_NOTAPPLICABLE
, /* - 23 */
924 C2_NOTAPPLICABLE
, /* - 24 */
925 C2_NOTAPPLICABLE
, /* - 25 */
926 C2_NOTAPPLICABLE
, /* - 26 */
927 C2_NOTAPPLICABLE
, /* - 27 */
928 C2_NOTAPPLICABLE
, /* - 28 */
929 C2_NOTAPPLICABLE
, /* - 29 */
930 C2_NOTAPPLICABLE
, /* - 30 */
931 C2_NOTAPPLICABLE
, /* - 31 */
932 C2_WHITESPACE
, /* - 32 */
933 C2_OTHERNEUTRAL
, /* ! - 33 */
934 C2_OTHERNEUTRAL
, /* " - 34 */ /* " */
935 C2_EUROPETERMINATOR
, /* # - 35 */
936 C2_EUROPETERMINATOR
, /* $ - 36 */
937 C2_EUROPETERMINATOR
, /* % - 37 */
938 C2_LEFTTORIGHT
, /* & - 38 */
939 C2_OTHERNEUTRAL
, /* ' - 39 */
940 C2_OTHERNEUTRAL
, /* ( - 40 */
941 C2_OTHERNEUTRAL
, /* ) - 41 */
942 C2_OTHERNEUTRAL
, /* * - 42 */
943 C2_EUROPETERMINATOR
, /* + - 43 */
944 C2_COMMONSEPARATOR
, /* , - 44 */
945 C2_EUROPETERMINATOR
, /* - - 45 */
946 C2_EUROPESEPARATOR
, /* . - 46 */
947 C2_EUROPESEPARATOR
, /* / - 47 */
948 C2_EUROPENUMBER
, /* 0 - 48 */
949 C2_EUROPENUMBER
, /* 1 - 49 */
950 C2_EUROPENUMBER
, /* 2 - 50 */
951 C2_EUROPENUMBER
, /* 3 - 51 */
952 C2_EUROPENUMBER
, /* 4 - 52 */
953 C2_EUROPENUMBER
, /* 5 - 53 */
954 C2_EUROPENUMBER
, /* 6 - 54 */
955 C2_EUROPENUMBER
, /* 7 - 55 */
956 C2_EUROPENUMBER
, /* 8 - 56 */
957 C2_EUROPENUMBER
, /* 9 - 57 */
958 C2_COMMONSEPARATOR
, /* : - 58 */
959 C2_OTHERNEUTRAL
, /* ; - 59 */
960 C2_OTHERNEUTRAL
, /* < - 60 */
961 C2_OTHERNEUTRAL
, /* = - 61 */
962 C2_OTHERNEUTRAL
, /* > - 62 */
963 C2_OTHERNEUTRAL
, /* ? - 63 */
964 C2_LEFTTORIGHT
, /* @ - 64 */
965 C2_LEFTTORIGHT
, /* A - 65 */
966 C2_LEFTTORIGHT
, /* B - 66 */
967 C2_LEFTTORIGHT
, /* C - 67 */
968 C2_LEFTTORIGHT
, /* D - 68 */
969 C2_LEFTTORIGHT
, /* E - 69 */
970 C2_LEFTTORIGHT
, /* F - 70 */
971 C2_LEFTTORIGHT
, /* G - 71 */
972 C2_LEFTTORIGHT
, /* H - 72 */
973 C2_LEFTTORIGHT
, /* I - 73 */
974 C2_LEFTTORIGHT
, /* J - 74 */
975 C2_LEFTTORIGHT
, /* K - 75 */
976 C2_LEFTTORIGHT
, /* L - 76 */
977 C2_LEFTTORIGHT
, /* M - 77 */
978 C2_LEFTTORIGHT
, /* N - 78 */
979 C2_LEFTTORIGHT
, /* O - 79 */
980 C2_LEFTTORIGHT
, /* P - 80 */
981 C2_LEFTTORIGHT
, /* Q - 81 */
982 C2_LEFTTORIGHT
, /* R - 82 */
983 C2_LEFTTORIGHT
, /* S - 83 */
984 C2_LEFTTORIGHT
, /* T - 84 */
985 C2_LEFTTORIGHT
, /* U - 85 */
986 C2_LEFTTORIGHT
, /* V - 86 */
987 C2_LEFTTORIGHT
, /* W - 87 */
988 C2_LEFTTORIGHT
, /* X - 88 */
989 C2_LEFTTORIGHT
, /* Y - 89 */
990 C2_LEFTTORIGHT
, /* Z - 90 */
991 C2_OTHERNEUTRAL
, /* [ - 91 */
992 C2_OTHERNEUTRAL
, /* \ - 92 */
993 C2_OTHERNEUTRAL
, /* ] - 93 */
994 C2_OTHERNEUTRAL
, /* ^ - 94 */
995 C2_OTHERNEUTRAL
, /* _ - 95 */
996 C2_OTHERNEUTRAL
, /* ` - 96 */
997 C2_LEFTTORIGHT
, /* a - 97 */
998 C2_LEFTTORIGHT
, /* b - 98 */
999 C2_LEFTTORIGHT
, /* c - 99 */
1000 C2_LEFTTORIGHT
, /* d - 100 */
1001 C2_LEFTTORIGHT
, /* e - 101 */
1002 C2_LEFTTORIGHT
, /* f - 102 */
1003 C2_LEFTTORIGHT
, /* g - 103 */
1004 C2_LEFTTORIGHT
, /* h - 104 */
1005 C2_LEFTTORIGHT
, /* i - 105 */
1006 C2_LEFTTORIGHT
, /* j - 106 */
1007 C2_LEFTTORIGHT
, /* k - 107 */
1008 C2_LEFTTORIGHT
, /* l - 108 */
1009 C2_LEFTTORIGHT
, /* m - 109 */
1010 C2_LEFTTORIGHT
, /* n - 110 */
1011 C2_LEFTTORIGHT
, /* o - 111 */
1012 C2_LEFTTORIGHT
, /* p - 112 */
1013 C2_LEFTTORIGHT
, /* q - 113 */
1014 C2_LEFTTORIGHT
, /* r - 114 */
1015 C2_LEFTTORIGHT
, /* s - 115 */
1016 C2_LEFTTORIGHT
, /* t - 116 */
1017 C2_LEFTTORIGHT
, /* u - 117 */
1018 C2_LEFTTORIGHT
, /* v - 118 */
1019 C2_LEFTTORIGHT
, /* w - 119 */
1020 C2_LEFTTORIGHT
, /* x - 120 */
1021 C2_LEFTTORIGHT
, /* y - 121 */
1022 C2_LEFTTORIGHT
, /* z - 122 */
1023 C2_OTHERNEUTRAL
, /* { - 123 */
1024 C2_OTHERNEUTRAL
, /* | - 124 */
1025 C2_OTHERNEUTRAL
, /* } - 125 */
1026 C2_OTHERNEUTRAL
, /* ~ - 126 */
1027 C2_NOTAPPLICABLE
, /* \x7f - 127 */
1028 C2_NOTAPPLICABLE
, /* € - 128 */
1029 C2_NOTAPPLICABLE
, /* � - 129 */
1030 C2_OTHERNEUTRAL
, /* ‚ - 130 */
1031 C2_LEFTTORIGHT
, /* ƒ - 131 */
1032 C2_OTHERNEUTRAL
, /* „ - 132 */
1033 C2_OTHERNEUTRAL
, /* … - 133 */
1034 C2_OTHERNEUTRAL
, /* † - 134 */
1035 C2_OTHERNEUTRAL
, /* ‡ - 135 */
1036 C2_LEFTTORIGHT
, /* ˆ - 136 */
1037 C2_EUROPETERMINATOR
, /* ‰ - 137 */
1038 C2_LEFTTORIGHT
, /* Š - 138 */
1039 C2_OTHERNEUTRAL
, /* ‹ - 139 */
1040 C2_LEFTTORIGHT
, /* Œ - 140 */
1041 C2_NOTAPPLICABLE
, /* � - 141 */
1042 C2_NOTAPPLICABLE
, /* Ž - 142 */
1043 C2_NOTAPPLICABLE
, /* � - 143 */
1044 C2_NOTAPPLICABLE
, /* � - 144 */
1045 C2_OTHERNEUTRAL
, /* ‘ - 145 */
1046 C2_OTHERNEUTRAL
, /* ’ - 146 */
1047 C2_OTHERNEUTRAL
, /* “ - 147 */
1048 C2_OTHERNEUTRAL
, /* ” - 148 */
1049 C2_OTHERNEUTRAL
, /* • - 149 */
1050 C2_OTHERNEUTRAL
, /* – - 150 */
1051 C2_OTHERNEUTRAL
, /* — - 151 */
1052 C2_LEFTTORIGHT
, /* ˜ - 152 */
1053 C2_OTHERNEUTRAL
, /* ™ - 153 */
1054 C2_LEFTTORIGHT
, /* š - 154 */
1055 C2_OTHERNEUTRAL
, /* › - 155 */
1056 C2_LEFTTORIGHT
, /* œ - 156 */
1057 C2_NOTAPPLICABLE
, /* � - 157 */
1058 C2_NOTAPPLICABLE
, /* ž - 158 */
1059 C2_LEFTTORIGHT
, /* Ÿ - 159 */
1060 C2_WHITESPACE
, /* - 160 */
1061 C2_OTHERNEUTRAL
, /* ¡ - 161 */
1062 C2_EUROPETERMINATOR
, /* ¢ - 162 */
1063 C2_EUROPETERMINATOR
, /* £ - 163 */
1064 C2_EUROPETERMINATOR
, /* ¤ - 164 */
1065 C2_EUROPETERMINATOR
, /* ¥ - 165 */
1066 C2_OTHERNEUTRAL
, /* ¦ - 166 */
1067 C2_OTHERNEUTRAL
, /* § - 167 */
1068 C2_OTHERNEUTRAL
, /* ¨ - 168 */
1069 C2_OTHERNEUTRAL
, /* © - 169 */
1070 C2_OTHERNEUTRAL
, /* ª - 170 */
1071 C2_OTHERNEUTRAL
, /* « - 171 */
1072 C2_OTHERNEUTRAL
, /* ¬ - 172 */
1073 C2_OTHERNEUTRAL
, /* - 173 */
1074 C2_OTHERNEUTRAL
, /* ® - 174 */
1075 C2_OTHERNEUTRAL
, /* ¯ - 175 */
1076 C2_EUROPETERMINATOR
, /* ° - 176 */
1077 C2_EUROPETERMINATOR
, /* ± - 177 */
1078 C2_EUROPENUMBER
, /* ² - 178 */
1079 C2_EUROPENUMBER
, /* ³ - 179 */
1080 C2_OTHERNEUTRAL
, /* ´ - 180 */
1081 C2_OTHERNEUTRAL
, /* µ - 181 */
1082 C2_OTHERNEUTRAL
, /* ¶ - 182 */
1083 C2_OTHERNEUTRAL
, /* · - 183 */
1084 C2_OTHERNEUTRAL
, /* ¸ - 184 */
1085 C2_EUROPENUMBER
, /* ¹ - 185 */
1086 C2_OTHERNEUTRAL
, /* º - 186 */
1087 C2_OTHERNEUTRAL
, /* » - 187 */
1088 C2_OTHERNEUTRAL
, /* ¼ - 188 */
1089 C2_OTHERNEUTRAL
, /* ½ - 189 */
1090 C2_OTHERNEUTRAL
, /* ¾ - 190 */
1091 C2_OTHERNEUTRAL
, /* ¿ - 191 */
1092 C2_LEFTTORIGHT
, /* À - 192 */
1093 C2_LEFTTORIGHT
, /* Á - 193 */
1094 C2_LEFTTORIGHT
, /* Â - 194 */
1095 C2_LEFTTORIGHT
, /* Ã - 195 */
1096 C2_LEFTTORIGHT
, /* Ä - 196 */
1097 C2_LEFTTORIGHT
, /* Å - 197 */
1098 C2_LEFTTORIGHT
, /* Æ - 198 */
1099 C2_LEFTTORIGHT
, /* Ç - 199 */
1100 C2_LEFTTORIGHT
, /* È - 200 */
1101 C2_LEFTTORIGHT
, /* É - 201 */
1102 C2_LEFTTORIGHT
, /* Ê - 202 */
1103 C2_LEFTTORIGHT
, /* Ë - 203 */
1104 C2_LEFTTORIGHT
, /* Ì - 204 */
1105 C2_LEFTTORIGHT
, /* Í - 205 */
1106 C2_LEFTTORIGHT
, /* Î - 206 */
1107 C2_LEFTTORIGHT
, /* Ï - 207 */
1108 C2_LEFTTORIGHT
, /* Ð - 208 */
1109 C2_LEFTTORIGHT
, /* Ñ - 209 */
1110 C2_LEFTTORIGHT
, /* Ò - 210 */
1111 C2_LEFTTORIGHT
, /* Ó - 211 */
1112 C2_LEFTTORIGHT
, /* Ô - 212 */
1113 C2_LEFTTORIGHT
, /* Õ - 213 */
1114 C2_LEFTTORIGHT
, /* Ö - 214 */
1115 C2_OTHERNEUTRAL
, /* × - 215 */
1116 C2_LEFTTORIGHT
, /* Ø - 216 */
1117 C2_LEFTTORIGHT
, /* Ù - 217 */
1118 C2_LEFTTORIGHT
, /* Ú - 218 */
1119 C2_LEFTTORIGHT
, /* Û - 219 */
1120 C2_LEFTTORIGHT
, /* Ü - 220 */
1121 C2_LEFTTORIGHT
, /* Ý - 221 */
1122 C2_LEFTTORIGHT
, /* Þ - 222 */
1123 C2_LEFTTORIGHT
, /* ß - 223 */
1124 C2_LEFTTORIGHT
, /* à - 224 */
1125 C2_LEFTTORIGHT
, /* á - 225 */
1126 C2_LEFTTORIGHT
, /* â - 226 */
1127 C2_LEFTTORIGHT
, /* ã - 227 */
1128 C2_LEFTTORIGHT
, /* ä - 228 */
1129 C2_LEFTTORIGHT
, /* å - 229 */
1130 C2_LEFTTORIGHT
, /* æ - 230 */
1131 C2_LEFTTORIGHT
, /* ç - 231 */
1132 C2_LEFTTORIGHT
, /* è - 232 */
1133 C2_LEFTTORIGHT
, /* é - 233 */
1134 C2_LEFTTORIGHT
, /* ê - 234 */
1135 C2_LEFTTORIGHT
, /* ë - 235 */
1136 C2_LEFTTORIGHT
, /* ì - 236 */
1137 C2_LEFTTORIGHT
, /* í - 237 */
1138 C2_LEFTTORIGHT
, /* î - 238 */
1139 C2_LEFTTORIGHT
, /* ï - 239 */
1140 C2_LEFTTORIGHT
, /* ð - 240 */
1141 C2_LEFTTORIGHT
, /* ñ - 241 */
1142 C2_LEFTTORIGHT
, /* ò - 242 */
1143 C2_LEFTTORIGHT
, /* ó - 243 */
1144 C2_LEFTTORIGHT
, /* ô - 244 */
1145 C2_LEFTTORIGHT
, /* õ - 245 */
1146 C2_LEFTTORIGHT
, /* ö - 246 */
1147 C2_OTHERNEUTRAL
, /* ÷ - 247 */
1148 C2_LEFTTORIGHT
, /* ø - 248 */
1149 C2_LEFTTORIGHT
, /* ù - 249 */
1150 C2_LEFTTORIGHT
, /* ú - 250 */
1151 C2_LEFTTORIGHT
, /* û - 251 */
1152 C2_LEFTTORIGHT
, /* ü - 252 */
1153 C2_LEFTTORIGHT
, /* ý - 253 */
1154 C2_LEFTTORIGHT
, /* þ - 254 */
1155 C2_LEFTTORIGHT
/* ÿ - 255 */
1158 const WORD OLE2NLS_CT_CType3_LUT
[] = {
1192 0x0048, /* ! - 33 */
1193 0x0448, /* " - 34 */ /* " */
1194 0x0048, /* # - 35 */
1195 0x0448, /* $ - 36 */
1196 0x0048, /* % - 37 */
1197 0x0048, /* & - 38 */
1198 0x0440, /* ' - 39 */
1199 0x0048, /* ( - 40 */
1200 0x0048, /* ) - 41 */
1201 0x0048, /* * - 42 */
1202 0x0048, /* + - 43 */
1203 0x0048, /* , - 44 */
1204 0x0440, /* - - 45 */
1205 0x0048, /* . - 46 */
1206 0x0448, /* / - 47 */
1207 0x0040, /* 0 - 48 */
1208 0x0040, /* 1 - 49 */
1209 0x0040, /* 2 - 50 */
1210 0x0040, /* 3 - 51 */
1211 0x0040, /* 4 - 52 */
1212 0x0040, /* 5 - 53 */
1213 0x0040, /* 6 - 54 */
1214 0x0040, /* 7 - 55 */
1215 0x0040, /* 8 - 56 */
1216 0x0040, /* 9 - 57 */
1217 0x0048, /* : - 58 */
1218 0x0048, /* ; - 59 */
1219 0x0048, /* < - 60 */
1220 0x0448, /* = - 61 */
1221 0x0048, /* > - 62 */
1222 0x0048, /* ? - 63 */
1223 0x0448, /* @ - 64 */
1224 0x8040, /* A - 65 */
1225 0x8040, /* B - 66 */
1226 0x8040, /* C - 67 */
1227 0x8040, /* D - 68 */
1228 0x8040, /* E - 69 */
1229 0x8040, /* F - 70 */
1230 0x8040, /* G - 71 */
1231 0x8040, /* H - 72 */
1232 0x8040, /* I - 73 */
1233 0x8040, /* J - 74 */
1234 0x8040, /* K - 75 */
1235 0x8040, /* L - 76 */
1236 0x8040, /* M - 77 */
1237 0x8040, /* N - 78 */
1238 0x8040, /* O - 79 */
1239 0x8040, /* P - 80 */
1240 0x8040, /* Q - 81 */
1241 0x8040, /* R - 82 */
1242 0x8040, /* S - 83 */
1243 0x8040, /* T - 84 */
1244 0x8040, /* U - 85 */
1245 0x8040, /* V - 86 */
1246 0x8040, /* W - 87 */
1247 0x8040, /* X - 88 */
1248 0x8040, /* Y - 89 */
1249 0x8040, /* Z - 90 */
1250 0x0048, /* [ - 91 */
1251 0x0448, /* \ - 92 */
1252 0x0048, /* ] - 93 */
1253 0x0448, /* ^ - 94 */
1254 0x0448, /* _ - 95 */
1255 0x0448, /* ` - 96 */
1256 0x8040, /* a - 97 */
1257 0x8040, /* b - 98 */
1258 0x8040, /* c - 99 */
1259 0x8040, /* d - 100 */
1260 0x8040, /* e - 101 */
1261 0x8040, /* f - 102 */
1262 0x8040, /* g - 103 */
1263 0x8040, /* h - 104 */
1264 0x8040, /* i - 105 */
1265 0x8040, /* j - 106 */
1266 0x8040, /* k - 107 */
1267 0x8040, /* l - 108 */
1268 0x8040, /* m - 109 */
1269 0x8040, /* n - 110 */
1270 0x8040, /* o - 111 */
1271 0x8040, /* p - 112 */
1272 0x8040, /* q - 113 */
1273 0x8040, /* r - 114 */
1274 0x8040, /* s - 115 */
1275 0x8040, /* t - 116 */
1276 0x8040, /* u - 117 */
1277 0x8040, /* v - 118 */
1278 0x8040, /* w - 119 */
1279 0x8040, /* x - 120 */
1280 0x8040, /* y - 121 */
1281 0x8040, /* z - 122 */
1282 0x0048, /* { - 123 */
1283 0x0048, /* | - 124 */
1284 0x0048, /* } - 125 */
1285 0x0448, /* ~ - 126 */
1286 0x0000, /* \x7f - 127 */
1287 0x0000, /* € - 128 */
1288 0x0000, /* � - 129 */
1289 0x0008, /* ‚ - 130 */
1290 0x8000, /* ƒ - 131 */
1291 0x0008, /* „ - 132 */
1292 0x0008, /* … - 133 */
1293 0x0008, /* † - 134 */
1294 0x0008, /* ‡ - 135 */
1295 0x0001, /* ˆ - 136 */
1296 0x0008, /* ‰ - 137 */
1297 0x8003, /* Š - 138 */
1298 0x0008, /* ‹ - 139 */
1299 0x8000, /* Œ - 140 */
1300 0x0000, /* � - 141 */
1301 0x0000, /* Ž - 142 */
1302 0x0000, /* � - 143 */
1303 0x0000, /* � - 144 */
1304 0x0088, /* ‘ - 145 */
1305 0x0088, /* ’ - 146 */
1306 0x0088, /* “ - 147 */
1307 0x0088, /* ” - 148 */
1308 0x0008, /* • - 149 */
1309 0x0400, /* – - 150 */
1310 0x0400, /* — - 151 */
1311 0x0408, /* ˜ - 152 */
1312 0x0000, /* ™ - 153 */
1313 0x8003, /* š - 154 */
1314 0x0008, /* › - 155 */
1315 0x8000, /* œ - 156 */
1316 0x0000, /* � - 157 */
1317 0x0000, /* ž - 158 */
1318 0x8003, /* Ÿ - 159 */
1320 0x0008, /* ¡ - 161 */
1321 0x0048, /* ¢ - 162 */
1322 0x0048, /* £ - 163 */
1323 0x0008, /* ¤ - 164 */
1324 0x0048, /* ¥ - 165 */
1325 0x0048, /* ¦ - 166 */
1326 0x0008, /* § - 167 */
1327 0x0408, /* ¨ - 168 */
1328 0x0008, /* © - 169 */
1329 0x0400, /* ª - 170 */
1330 0x0008, /* « - 171 */
1331 0x0048, /* ¬ - 172 */
1332 0x0408, /* - 173 */
1333 0x0008, /* ® - 174 */
1334 0x0448, /* ¯ - 175 */
1335 0x0008, /* ° - 176 */
1336 0x0008, /* ± - 177 */
1337 0x0000, /* ² - 178 */
1338 0x0000, /* ³ - 179 */
1339 0x0408, /* ´ - 180 */
1340 0x0008, /* µ - 181 */
1341 0x0008, /* ¶ - 182 */
1342 0x0008, /* · - 183 */
1343 0x0408, /* ¸ - 184 */
1344 0x0000, /* ¹ - 185 */
1345 0x0400, /* º - 186 */
1346 0x0008, /* » - 187 */
1347 0x0000, /* ¼ - 188 */
1348 0x0000, /* ½ - 189 */
1349 0x0000, /* ¾ - 190 */
1350 0x0008, /* ¿ - 191 */
1351 0x8003, /* À - 192 */
1352 0x8003, /* Á - 193 */
1353 0x8003, /* Â - 194 */
1354 0x8003, /* Ã - 195 */
1355 0x8003, /* Ä - 196 */
1356 0x8003, /* Å - 197 */
1357 0x8000, /* Æ - 198 */
1358 0x8003, /* Ç - 199 */
1359 0x8003, /* È - 200 */
1360 0x8003, /* É - 201 */
1361 0x8003, /* Ê - 202 */
1362 0x8003, /* Ë - 203 */
1363 0x8003, /* Ì - 204 */
1364 0x8003, /* Í - 205 */
1365 0x8003, /* Î - 206 */
1366 0x8003, /* Ï - 207 */
1367 0x8000, /* Ð - 208 */
1368 0x8003, /* Ñ - 209 */
1369 0x8003, /* Ò - 210 */
1370 0x8003, /* Ó - 211 */
1371 0x8003, /* Ô - 212 */
1372 0x8003, /* Õ - 213 */
1373 0x8003, /* Ö - 214 */
1374 0x0008, /* × - 215 */
1375 0x8003, /* Ø - 216 */
1376 0x8003, /* Ù - 217 */
1377 0x8003, /* Ú - 218 */
1378 0x8003, /* Û - 219 */
1379 0x8003, /* Ü - 220 */
1380 0x8003, /* Ý - 221 */
1381 0x8000, /* Þ - 222 */
1382 0x8000, /* ß - 223 */
1383 0x8003, /* à - 224 */
1384 0x8003, /* á - 225 */
1385 0x8003, /* â - 226 */
1386 0x8003, /* ã - 227 */
1387 0x8003, /* ä - 228 */
1388 0x8003, /* å - 229 */
1389 0x8000, /* æ - 230 */
1390 0x8003, /* ç - 231 */
1391 0x8003, /* è - 232 */
1392 0x8003, /* é - 233 */
1393 0x8003, /* ê - 234 */
1394 0x8003, /* ë - 235 */
1395 0x8003, /* ì - 236 */
1396 0x8003, /* í - 237 */
1397 0x8003, /* î - 238 */
1398 0x8003, /* ï - 239 */
1399 0x8000, /* ð - 240 */
1400 0x8003, /* ñ - 241 */
1401 0x8003, /* ò - 242 */
1402 0x8003, /* ó - 243 */
1403 0x8003, /* ô - 244 */
1404 0x8003, /* õ - 245 */
1405 0x8003, /* ö - 246 */
1406 0x0008, /* ÷ - 247 */
1407 0x8003, /* ø - 248 */
1408 0x8003, /* ù - 249 */
1409 0x8003, /* ú - 250 */
1410 0x8003, /* û - 251 */
1411 0x8003, /* ü - 252 */
1412 0x8003, /* ý - 253 */
1413 0x8000, /* þ - 254 */
1414 0x8003 /* ÿ - 255 */
1417 /******************************************************************************
1418 * GetStringType16 [OLE2NLS.7]
1420 BOOL16 WINAPI
GetStringType16(LCID locale
,DWORD dwInfoType
,LPCSTR src
,
1421 INT16 cchSrc
,LPWORD chartype
)
1423 return GetStringTypeExA(locale
,dwInfoType
,src
,cchSrc
,chartype
);
1425 /******************************************************************************
1426 * GetStringType32A [KERNEL32.396]
1428 BOOL WINAPI
GetStringTypeA(LCID locale
,DWORD dwInfoType
,LPCSTR src
,
1429 INT cchSrc
,LPWORD chartype
)
1431 return GetStringTypeExA(locale
,dwInfoType
,src
,cchSrc
,chartype
);
1434 /******************************************************************************
1435 * GetStringTypeEx32A [KERNEL32.397]
1437 * FIXME: Ignores the locale.
1439 BOOL WINAPI
GetStringTypeExA(LCID locale
,DWORD dwInfoType
,LPCSTR src
,
1440 INT cchSrc
,LPWORD chartype
)
1444 if ((src
==NULL
) || (chartype
==NULL
) || (src
==(LPSTR
)chartype
))
1446 SetLastError(ERROR_INVALID_PARAMETER
);
1451 cchSrc
=lstrlenA(src
)+1;
1453 switch (dwInfoType
) {
1455 for (i
=0;i
<cchSrc
;i
++)
1458 if (isdigit(src
[i
])) chartype
[i
]|=C1_DIGIT
;
1459 if (isalpha(src
[i
])) chartype
[i
]|=C1_ALPHA
;
1460 if (islower(src
[i
])) chartype
[i
]|=C1_LOWER
;
1461 if (isupper(src
[i
])) chartype
[i
]|=C1_UPPER
;
1462 if (isspace(src
[i
])) chartype
[i
]|=C1_SPACE
;
1463 if (ispunct(src
[i
])) chartype
[i
]|=C1_PUNCT
;
1464 if (iscntrl(src
[i
])) chartype
[i
]|=C1_CNTRL
;
1465 /* FIXME: isblank() is a GNU extension */
1466 /* if (isblank(src[i])) chartype[i]|=C1_BLANK; */
1467 if ((src
[i
] == ' ') || (src
[i
] == '\t')) chartype
[i
]|=C1_BLANK
;
1473 for (i
=0;i
<cchSrc
;i
++)
1475 chartype
[i
]=(WORD
)CT_CType2_LUT
[i
];
1480 for (i
=0;i
<cchSrc
;i
++)
1482 chartype
[i
]=OLE2NLS_CT_CType3_LUT
[i
];
1487 ERR("Unknown dwInfoType:%ld\n",dwInfoType
);
1492 /******************************************************************************
1493 * GetStringType32W [KERNEL32.399]
1496 * Yes, this is missing LCID locale. MS fault.
1498 BOOL WINAPI
GetStringTypeW(DWORD dwInfoType
,LPCWSTR src
,INT cchSrc
,
1501 return GetStringTypeExW(0/*defaultlocale*/,dwInfoType
,src
,cchSrc
,chartype
);
1504 /******************************************************************************
1505 * GetStringTypeEx32W [KERNEL32.398]
1507 * FIXME: unicode chars are assumed chars
1509 BOOL WINAPI
GetStringTypeExW(LCID locale
,DWORD dwInfoType
,LPCWSTR src
,
1510 INT cchSrc
,LPWORD chartype
)
1516 cchSrc
=lstrlenW(src
)+1;
1518 switch (dwInfoType
) {
1520 FIXME("CT_CTYPE2 not supported.\n");
1523 FIXME("CT_CTYPE3 not supported.\n");
1527 for (i
=0;i
<cchSrc
;i
++) {
1529 if (isdigit(src
[i
])) chartype
[i
]|=C1_DIGIT
;
1530 if (isalpha(src
[i
])) chartype
[i
]|=C1_ALPHA
;
1531 if (islower(src
[i
])) chartype
[i
]|=C1_LOWER
;
1532 if (isupper(src
[i
])) chartype
[i
]|=C1_UPPER
;
1533 if (isspace(src
[i
])) chartype
[i
]|=C1_SPACE
;
1534 if (ispunct(src
[i
])) chartype
[i
]|=C1_PUNCT
;
1535 if (iscntrl(src
[i
])) chartype
[i
]|=C1_CNTRL
;
1536 /* FIXME: isblank() is a GNU extension */
1537 /* if (isblank(src[i])) chartype[i]|=C1_BLANK; */
1538 if ((src
[i
] == ' ') || (src
[i
] == '\t')) chartype
[i
]|=C1_BLANK
;
1544 /*****************************************************************
1545 * WINE_GetLanguageName [internal]
1547 static LPCSTR
WINE_GetLanguageName( UINT langid
)
1550 for ( i
= 0; languages
[i
].langid
!= 0; i
++ )
1551 if ( langid
== languages
[i
].langid
)
1554 return languages
[i
].langname
;
1557 /***********************************************************************
1558 * VerLanguageNameA [KERNEL32.709][VERSION.9]
1560 DWORD WINAPI
VerLanguageNameA( UINT wLang
, LPSTR szLang
, UINT nSize
)
1567 * First, check \System\CurrentControlSet\control\Nls\Locale\<langid>
1568 * from the registry.
1572 "\\System\\CurrentControlSet\\control\\Nls\\Locale\\%08x",
1575 result
= RegQueryValueA( HKEY_LOCAL_MACHINE
, buffer
, szLang
, (LPDWORD
)&nSize
);
1576 if ( result
== ERROR_SUCCESS
|| result
== ERROR_MORE_DATA
)
1580 * If that fails, use the internal table
1583 name
= WINE_GetLanguageName( wLang
);
1584 lstrcpynA( szLang
, name
, nSize
);
1585 return lstrlenA( name
);
1588 /***********************************************************************
1589 * VerLanguageNameW [KERNEL32.710][VERSION.10]
1591 DWORD WINAPI
VerLanguageNameW( UINT wLang
, LPWSTR szLang
, UINT nSize
)
1599 * First, check \System\CurrentControlSet\control\Nls\Locale\<langid>
1600 * from the registry.
1604 "\\System\\CurrentControlSet\\control\\Nls\\Locale\\%08x",
1607 keyname
= HEAP_strdupAtoW( GetProcessHeap(), 0, buffer
);
1608 result
= RegQueryValueW( HKEY_LOCAL_MACHINE
, keyname
, szLang
, (LPDWORD
)&nSize
);
1609 HeapFree( GetProcessHeap(), 0, keyname
);
1611 if ( result
== ERROR_SUCCESS
|| result
== ERROR_MORE_DATA
)
1615 * If that fails, use the internal table
1618 name
= WINE_GetLanguageName( wLang
);
1619 lstrcpynAtoW( szLang
, name
, nSize
);
1620 return lstrlenA( name
);
1624 static const unsigned char LCM_Unicode_LUT
[] = {
1657 7 , 28, /* ! - 33 */
1658 7 , 29, /* " - 34 */ /* " */
1659 7 , 31, /* # - 35 */
1660 7 , 33, /* $ - 36 */
1661 7 , 35, /* % - 37 */
1662 7 , 37, /* & - 38 */
1663 6 , 128, /* ' - 39 */
1664 7 , 39, /* ( - 40 */
1665 7 , 42, /* ) - 41 */
1666 7 , 45, /* * - 42 */
1668 7 , 47, /* , - 44 */
1669 6 , 130, /* - - 45 */
1670 7 , 51, /* . - 46 */
1671 7 , 53, /* / - 47 */
1672 12 , 3, /* 0 - 48 */
1673 12 , 33, /* 1 - 49 */
1674 12 , 51, /* 2 - 50 */
1675 12 , 70, /* 3 - 51 */
1676 12 , 88, /* 4 - 52 */
1677 12 , 106, /* 5 - 53 */
1678 12 , 125, /* 6 - 54 */
1679 12 , 144, /* 7 - 55 */
1680 12 , 162, /* 8 - 56 */
1681 12 , 180, /* 9 - 57 */
1682 7 , 55, /* : - 58 */
1683 7 , 58, /* ; - 59 */
1684 8 , 14, /* < - 60 */
1685 8 , 18, /* = - 61 */
1686 8 , 20, /* > - 62 */
1687 7 , 60, /* ? - 63 */
1688 7 , 62, /* @ - 64 */
1689 14 , 2, /* A - 65 */
1690 14 , 9, /* B - 66 */
1691 14 , 10, /* C - 67 */
1692 14 , 26, /* D - 68 */
1693 14 , 33, /* E - 69 */
1694 14 , 35, /* F - 70 */
1695 14 , 37, /* G - 71 */
1696 14 , 44, /* H - 72 */
1697 14 , 50, /* I - 73 */
1698 14 , 53, /* J - 74 */
1699 14 , 54, /* K - 75 */
1700 14 , 72, /* L - 76 */
1701 14 , 81, /* M - 77 */
1702 14 , 112, /* N - 78 */
1703 14 , 124, /* O - 79 */
1704 14 , 126, /* P - 80 */
1705 14 , 137, /* Q - 81 */
1706 14 , 138, /* R - 82 */
1707 14 , 145, /* S - 83 */
1708 14 , 153, /* T - 84 */
1709 14 , 159, /* U - 85 */
1710 14 , 162, /* V - 86 */
1711 14 , 164, /* W - 87 */
1712 14 , 166, /* X - 88 */
1713 14 , 167, /* Y - 89 */
1714 14 , 169, /* Z - 90 */
1715 7 , 63, /* [ - 91 */
1716 7 , 65, /* \ - 92 */
1717 7 , 66, /* ] - 93 */
1718 7 , 67, /* ^ - 94 */
1719 7 , 68, /* _ - 95 */
1720 7 , 72, /* ` - 96 */
1721 14 , 2, /* a - 97 */
1722 14 , 9, /* b - 98 */
1723 14 , 10, /* c - 99 */
1724 14 , 26, /* d - 100 */
1725 14 , 33, /* e - 101 */
1726 14 , 35, /* f - 102 */
1727 14 , 37, /* g - 103 */
1728 14 , 44, /* h - 104 */
1729 14 , 50, /* i - 105 */
1730 14 , 53, /* j - 106 */
1731 14 , 54, /* k - 107 */
1732 14 , 72, /* l - 108 */
1733 14 , 81, /* m - 109 */
1734 14 , 112, /* n - 110 */
1735 14 , 124, /* o - 111 */
1736 14 , 126, /* p - 112 */
1737 14 , 137, /* q - 113 */
1738 14 , 138, /* r - 114 */
1739 14 , 145, /* s - 115 */
1740 14 , 153, /* t - 116 */
1741 14 , 159, /* u - 117 */
1742 14 , 162, /* v - 118 */
1743 14 , 164, /* w - 119 */
1744 14 , 166, /* x - 120 */
1745 14 , 167, /* y - 121 */
1746 14 , 169, /* z - 122 */
1747 7 , 74, /* { - 123 */
1748 7 , 76, /* | - 124 */
1749 7 , 78, /* } - 125 */
1750 7 , 80, /* ~ - 126 */
1751 6 , 29, /* \x7f - 127 */
1752 6 , 30, /* € - 128 */
1753 6 , 31, /* � - 129 */
1754 7 , 123, /* ‚ - 130 */
1755 14 , 35, /* ƒ - 131 */
1756 7 , 127, /* „ - 132 */
1757 10 , 21, /* … - 133 */
1758 10 , 15, /* † - 134 */
1759 10 , 16, /* ‡ - 135 */
1760 7 , 67, /* ˆ - 136 */
1761 10 , 22, /* ‰ - 137 */
1762 14 , 145, /* Š - 138 */
1763 7 , 136, /* ‹ - 139 */
1764 14 + 16 , 124, /* Œ - 140 */
1765 6 , 43, /* � - 141 */
1766 6 , 44, /* Ž - 142 */
1767 6 , 45, /* � - 143 */
1768 6 , 46, /* � - 144 */
1769 7 , 121, /* ‘ - 145 */
1770 7 , 122, /* ’ - 146 */
1771 7 , 125, /* “ - 147 */
1772 7 , 126, /* ” - 148 */
1773 10 , 17, /* • - 149 */
1774 6 , 137, /* – - 150 */
1775 6 , 139, /* — - 151 */
1776 7 , 93, /* ˜ - 152 */
1777 14 , 156, /* ™ - 153 */
1778 14 , 145, /* š - 154 */
1779 7 , 137, /* › - 155 */
1780 14 + 16 , 124, /* œ - 156 */
1781 6 , 59, /* � - 157 */
1782 6 , 60, /* ž - 158 */
1783 14 , 167, /* Ÿ - 159 */
1785 7 , 81, /* ¡ - 161 */
1786 10 , 2, /* ¢ - 162 */
1787 10 , 3, /* £ - 163 */
1788 10 , 4, /* ¤ - 164 */
1789 10 , 5, /* ¥ - 165 */
1790 7 , 82, /* ¦ - 166 */
1791 10 , 6, /* § - 167 */
1792 7 , 83, /* ¨ - 168 */
1793 10 , 7, /* © - 169 */
1794 14 , 2, /* ª - 170 */
1795 8 , 24, /* « - 171 */
1796 10 , 8, /* ¬ - 172 */
1797 6 , 131, /* - 173 */
1798 10 , 9, /* ® - 174 */
1799 7 , 84, /* ¯ - 175 */
1800 10 , 10, /* ° - 176 */
1801 8 , 23, /* ± - 177 */
1802 12 , 51, /* ² - 178 */
1803 12 , 70, /* ³ - 179 */
1804 7 , 85, /* ´ - 180 */
1805 10 , 11, /* µ - 181 */
1806 10 , 12, /* ¶ - 182 */
1807 10 , 13, /* · - 183 */
1808 7 , 86, /* ¸ - 184 */
1809 12 , 33, /* ¹ - 185 */
1810 14 , 124, /* º - 186 */
1811 8 , 26, /* » - 187 */
1812 12 , 21, /* ¼ - 188 */
1813 12 , 25, /* ½ - 189 */
1814 12 , 29, /* ¾ - 190 */
1815 7 , 87, /* ¿ - 191 */
1816 14 , 2, /* À - 192 */
1817 14 , 2, /* Á - 193 */
1818 14 , 2, /* Â - 194 */
1819 14 , 2, /* Ã - 195 */
1820 14 , 2, /* Ä - 196 */
1821 14 , 2, /* Å - 197 */
1822 14 + 16 , 2, /* Æ - 198 */
1823 14 , 10, /* Ç - 199 */
1824 14 , 33, /* È - 200 */
1825 14 , 33, /* É - 201 */
1826 14 , 33, /* Ê - 202 */
1827 14 , 33, /* Ë - 203 */
1828 14 , 50, /* Ì - 204 */
1829 14 , 50, /* Í - 205 */
1830 14 , 50, /* Î - 206 */
1831 14 , 50, /* Ï - 207 */
1832 14 , 26, /* Ð - 208 */
1833 14 , 112, /* Ñ - 209 */
1834 14 , 124, /* Ò - 210 */
1835 14 , 124, /* Ó - 211 */
1836 14 , 124, /* Ô - 212 */
1837 14 , 124, /* Õ - 213 */
1838 14 , 124, /* Ö - 214 */
1839 8 , 28, /* × - 215 */
1840 14 , 124, /* Ø - 216 */
1841 14 , 159, /* Ù - 217 */
1842 14 , 159, /* Ú - 218 */
1843 14 , 159, /* Û - 219 */
1844 14 , 159, /* Ü - 220 */
1845 14 , 167, /* Ý - 221 */
1846 14 + 32 , 153, /* Þ - 222 */
1847 14 + 48 , 145, /* ß - 223 */
1848 14 , 2, /* à - 224 */
1849 14 , 2, /* á - 225 */
1850 14 , 2, /* â - 226 */
1851 14 , 2, /* ã - 227 */
1852 14 , 2, /* ä - 228 */
1853 14 , 2, /* å - 229 */
1854 14 + 16 , 2, /* æ - 230 */
1855 14 , 10, /* ç - 231 */
1856 14 , 33, /* è - 232 */
1857 14 , 33, /* é - 233 */
1858 14 , 33, /* ê - 234 */
1859 14 , 33, /* ë - 235 */
1860 14 , 50, /* ì - 236 */
1861 14 , 50, /* í - 237 */
1862 14 , 50, /* î - 238 */
1863 14 , 50, /* ï - 239 */
1864 14 , 26, /* ð - 240 */
1865 14 , 112, /* ñ - 241 */
1866 14 , 124, /* ò - 242 */
1867 14 , 124, /* ó - 243 */
1868 14 , 124, /* ô - 244 */
1869 14 , 124, /* õ - 245 */
1870 14 , 124, /* ö - 246 */
1871 8 , 29, /* ÷ - 247 */
1872 14 , 124, /* ø - 248 */
1873 14 , 159, /* ù - 249 */
1874 14 , 159, /* ú - 250 */
1875 14 , 159, /* û - 251 */
1876 14 , 159, /* ü - 252 */
1877 14 , 167, /* ý - 253 */
1878 14 + 32 , 153, /* þ - 254 */
1879 14 , 167 /* ÿ - 255 */ };
1881 static const unsigned char LCM_Unicode_LUT_2
[] = { 33, 44, 145 };
1883 #define LCM_Diacritic_Start 131
1885 static const unsigned char LCM_Diacritic_LUT
[] = {
2013 /******************************************************************************
2014 * OLE2NLS_isPunctuation [INTERNAL]
2016 static int OLE2NLS_isPunctuation(unsigned char c
)
2018 /* "punctuation character" in this context is a character which is
2019 considered "less important" during word sort comparison.
2020 See LCMapString implementation for the precise definition
2021 of "less important". */
2023 return (LCM_Unicode_LUT
[-2+2*c
]==6);
2026 /******************************************************************************
2027 * OLE2NLS_isNonSpacing [INTERNAL]
2029 static int OLE2NLS_isNonSpacing(unsigned char c
)
2031 /* This function is used by LCMapString32A. Characters
2032 for which it returns true are ignored when mapping a
2033 string with NORM_IGNORENONSPACE */
2034 return ((c
==136) || (c
==170) || (c
==186));
2037 /******************************************************************************
2038 * OLE2NLS_isSymbol [INTERNAL]
2040 static int OLE2NLS_isSymbol(unsigned char c
)
2042 /* This function is used by LCMapString32A. Characters
2043 for which it returns true are ignored when mapping a
2044 string with NORM_IGNORESYMBOLS */
2045 return ( (c
!=0) && !IsCharAlphaNumericA(c
) );
2048 /******************************************************************************
2049 * identity [Internal]
2051 static int identity(int c
)
2056 /*************************************************************************
2057 * LCMapString32A [KERNEL32.492]
2059 * Convert a string, or generate a sort key from it.
2061 * If (mapflags & LCMAP_SORTKEY), the function will generate
2062 * a sort key for the source string. Else, it will convert it
2063 * accordingly to the flags LCMAP_UPPERCASE, LCMAP_LOWERCASE,...
2067 * Success : length of the result string.
2070 * If called with scrlen = -1, the function will compute the length
2071 * of the 0-terminated string strsrc by itself.
2073 * If called with dstlen = 0, returns the buffer length that
2074 * would be required.
2076 * NORM_IGNOREWIDTH means to compare ASCII and wide characters
2077 * as if they are equal.
2078 * In the only code page implemented so far, there may not be
2079 * wide characters in strings passed to LCMapString32A,
2080 * so there is nothing to be done for this flag.
2082 INT WINAPI
LCMapStringA(
2083 LCID lcid
/* locale identifier created with MAKELCID;
2084 LOCALE_SYSTEM_DEFAULT and LOCALE_USER_DEFAULT are
2085 predefined values. */,
2086 DWORD mapflags
/* flags */,
2087 LPCSTR srcstr
/* source buffer */,
2088 INT srclen
/* source length */,
2089 LPSTR dststr
/* destination buffer */,
2090 INT dstlen
/* destination buffer length */)
2094 TRACE_(string
)("(0x%04lx,0x%08lx,%s,%d,%p,%d)\n",
2095 lcid
,mapflags
,srcstr
,srclen
,dststr
,dstlen
);
2097 if ( ((dstlen
!=0) && (dststr
==NULL
)) || (srcstr
==NULL
) )
2099 ERR("(src=%s,dest=%s): Invalid NULL string\n", srcstr
, dststr
);
2100 SetLastError(ERROR_INVALID_PARAMETER
);
2104 srclen
= lstrlenA(srcstr
) + 1 ; /* (include final '\0') */
2106 #define LCMAPSTRINGA_SUPPORTED_FLAGS (LCMAP_UPPERCASE | \
2110 NORM_IGNORENONSPACE | \
2112 NORM_IGNOREWIDTH | \
2113 NORM_IGNOREKANATYPE)
2114 /* FIXME: as long as we don't support Kanakana nor Hirigana
2115 * characters, we can support NORM_IGNOREKANATYPE
2117 if (mapflags
& ~LCMAPSTRINGA_SUPPORTED_FLAGS
)
2119 FIXME_(string
)("(0x%04lx,0x%08lx,%p,%d,%p,%d): "
2120 "unimplemented flags: 0x%08lx\n",
2127 mapflags
& ~LCMAPSTRINGA_SUPPORTED_FLAGS
2131 if ( !(mapflags
& LCMAP_SORTKEY
) )
2134 int (*f
)(int) = identity
;
2135 int flag_ignorenonspace
= mapflags
& NORM_IGNORENONSPACE
;
2136 int flag_ignoresymbols
= mapflags
& NORM_IGNORESYMBOLS
;
2138 if (flag_ignorenonspace
|| flag_ignoresymbols
)
2140 /* For some values of mapflags, the length of the resulting
2141 string is not known at this point. Windows does map the string
2142 and does not SetLastError ERROR_INSUFFICIENT_BUFFER in
2146 /* Compute required length */
2147 for (i
=j
=0; i
< srclen
; i
++)
2149 if ( !(flag_ignorenonspace
&& OLE2NLS_isNonSpacing(srcstr
[i
]))
2150 && !(flag_ignoresymbols
&& OLE2NLS_isSymbol(srcstr
[i
])) )
2162 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2166 if (mapflags
& LCMAP_UPPERCASE
)
2168 else if (mapflags
& LCMAP_LOWERCASE
)
2170 /* FIXME: NORM_IGNORENONSPACE requires another conversion */
2171 for (i
=j
=0; (i
<srclen
) && (j
<dstlen
) ; i
++)
2173 if ( !(flag_ignorenonspace
&& OLE2NLS_isNonSpacing(srcstr
[i
]))
2174 && !(flag_ignoresymbols
&& OLE2NLS_isSymbol(srcstr
[i
])) )
2176 dststr
[j
] = (CHAR
) f(srcstr
[i
]);
2183 /* else ... (mapflags & LCMAP_SORTKEY) */
2187 int diacritic_len
=0;
2188 int delayed_punctuation_len
=0;
2189 char *case_component
;
2190 char *diacritic_component
;
2191 char *delayed_punctuation_component
;
2193 int flag_stringsort
= mapflags
& SORT_STRINGSORT
;
2195 /* compute how much room we will need */
2196 for (i
=0;i
<srclen
;i
++)
2199 unsigned char source_char
= srcstr
[i
];
2200 if (source_char
!='\0')
2202 if (flag_stringsort
|| !OLE2NLS_isPunctuation(source_char
))
2205 if ( LCM_Unicode_LUT
[-2+2*source_char
] & ~15 )
2206 unicode_len
++; /* double letter */
2210 delayed_punctuation_len
++;
2214 if (isupper(source_char
))
2215 case_len
=unicode_len
;
2217 ofs
= source_char
- LCM_Diacritic_Start
;
2218 if ((ofs
>=0) && (LCM_Diacritic_LUT
[ofs
]!=2))
2219 diacritic_len
=unicode_len
;
2222 if (mapflags
& NORM_IGNORECASE
)
2224 if (mapflags
& NORM_IGNORENONSPACE
)
2227 room
= 2 * unicode_len
/* "unicode" component */
2228 + diacritic_len
/* "diacritic" component */
2229 + case_len
/* "case" component */
2230 + 4 * delayed_punctuation_len
/* punctuation in word sort mode */
2231 + 4 /* four '\1' separators */
2232 + 1 ; /* terminal '\0' */
2235 else if (dstlen
<room
)
2237 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2241 /*FIXME the Pointercheck should not be nessesary */
2242 if (IsBadWritePtr (dststr
,room
))
2243 { ERR_(string
)("bad destination buffer (dststr) : %p,%d\n",dststr
,dstlen
);
2244 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2248 /* locate each component, write separators */
2249 diacritic_component
= dststr
+ 2*unicode_len
;
2250 *diacritic_component
++ = '\1';
2251 case_component
= diacritic_component
+ diacritic_len
;
2252 *case_component
++ = '\1';
2253 delayed_punctuation_component
= case_component
+ case_len
;
2254 *delayed_punctuation_component
++ = '\1';
2255 *delayed_punctuation_component
++ = '\1';
2257 /* read source string char by char, write
2258 corresponding weight in each component. */
2259 for (i
=0,count
=0;i
<srclen
;i
++)
2261 unsigned char source_char
=srcstr
[i
];
2262 if (source_char
!='\0')
2265 type
= LCM_Unicode_LUT
[-2+2*source_char
];
2266 longcode
= type
>> 4;
2268 if (!flag_stringsort
&& OLE2NLS_isPunctuation(source_char
))
2270 UINT16 encrypted_location
= (1<<15) + 7 + 4*count
;
2271 *delayed_punctuation_component
++ = (unsigned char) (encrypted_location
>>8);
2272 *delayed_punctuation_component
++ = (unsigned char) (encrypted_location
&255);
2273 /* big-endian is used here because it lets string comparison be
2274 compatible with numerical comparison */
2276 *delayed_punctuation_component
++ = type
;
2277 *delayed_punctuation_component
++ = LCM_Unicode_LUT
[-1+2*source_char
];
2278 /* assumption : a punctuation character is never a
2279 double or accented letter */
2283 dststr
[2*count
] = type
;
2284 dststr
[2*count
+1] = LCM_Unicode_LUT
[-1+2*source_char
];
2288 case_component
[count
] = ( isupper(source_char
) ? 18 : 2 ) ;
2289 if (count
<diacritic_len
)
2290 diacritic_component
[count
] = 2; /* assumption: a double letter
2291 is never accented */
2294 dststr
[2*count
] = type
;
2295 dststr
[2*count
+1] = *(LCM_Unicode_LUT_2
- 1 + longcode
);
2296 /* 16 in the first column of LCM_Unicode_LUT --> longcode = 1
2297 32 in the first column of LCM_Unicode_LUT --> longcode = 2
2298 48 in the first column of LCM_Unicode_LUT --> longcode = 3 */
2302 case_component
[count
] = ( isupper(source_char
) ? 18 : 2 ) ;
2303 if (count
<diacritic_len
)
2305 int ofs
= source_char
- LCM_Diacritic_Start
;
2306 diacritic_component
[count
] = (ofs
>=0 ? LCM_Diacritic_LUT
[ofs
] : 2);
2312 dststr
[room
-1] = '\0';
2317 /*************************************************************************
2318 * LCMapString32W [KERNEL32.493]
2320 * Convert a string, or generate a sort key from it.
2324 * See LCMapString32A for documentation
2326 INT WINAPI
LCMapStringW(
2327 LCID lcid
,DWORD mapflags
,LPCWSTR srcstr
,INT srclen
,LPWSTR dststr
,
2332 TRACE_(string
)("(0x%04lx,0x%08lx,%p,%d,%p,%d)\n",
2333 lcid
,mapflags
,srcstr
,srclen
,dststr
,dstlen
);
2335 if ( ((dstlen
!=0) && (dststr
==NULL
)) || (srcstr
==NULL
) )
2337 ERR("(src=%p,dst=%p): Invalid NULL string\n", srcstr
, dststr
);
2338 SetLastError(ERROR_INVALID_PARAMETER
);
2342 srclen
= lstrlenW(srcstr
)+1;
2343 if (mapflags
& LCMAP_SORTKEY
)
2345 FIXME_(string
)("(0x%04lx,0x%08lx,%p,%d,%p,%d): "
2346 "unimplemented flags: 0x%08lx\n",
2347 lcid
,mapflags
,srcstr
,srclen
,dststr
,dstlen
,mapflags
);
2352 int (*f
)(int)=identity
;
2356 if (dstlen
<srclen
) {
2357 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2360 if (mapflags
& LCMAP_UPPERCASE
)
2362 else if (mapflags
& LCMAP_LOWERCASE
)
2364 for (i
=0; i
< srclen
; i
++)
2365 dststr
[i
] = (WCHAR
) f(srcstr
[i
]);
2370 /***********************************************************************
2371 * CompareString16 (OLE2NLS.8)
2373 UINT16 WINAPI
CompareString16(DWORD lcid
,DWORD fdwStyle
,
2374 LPCSTR s1
,DWORD l1
,LPCSTR s2
,DWORD l2
)
2376 return (UINT16
)CompareStringA(lcid
,fdwStyle
,s1
,l1
,s2
,l2
);
2379 /******************************************************************************
2380 * CompareString32A [KERNEL32.143]
2381 * Compares two strings using locale
2385 * success: CSTR_LESS_THAN, CSTR_EQUAL, CSTR_GREATER_THAN
2390 * Defaults to a word sort, but uses a string sort if
2391 * SORT_STRINGSORT is set.
2392 * Calls SetLastError for ERROR_INVALID_FLAGS, ERROR_INVALID_PARAMETER.
2396 * This implementation ignores the locale
2400 * Quite inefficient.
2402 UINT WINAPI
CompareStringA(
2403 DWORD lcid
, /* locale ID */
2404 DWORD fdwStyle
, /* comparison-style options */
2405 LPCSTR s1
, /* first string */
2406 DWORD l1
, /* length of first string */
2407 LPCSTR s2
, /* second string */
2408 DWORD l2
) /* length of second string */
2410 int mapstring_flags
;
2414 TRACE("%s and %s\n",
2415 debugstr_a (s1
), debugstr_a (s2
));
2417 if ( (s1
==NULL
) || (s2
==NULL
) )
2419 ERR("(s1=%s,s2=%s): Invalid NULL string\n", s1
, s2
);
2420 SetLastError(ERROR_INVALID_PARAMETER
);
2424 if(fdwStyle
& NORM_IGNORESYMBOLS
)
2425 FIXME("IGNORESYMBOLS not supported\n");
2427 mapstring_flags
= LCMAP_SORTKEY
| fdwStyle
;
2428 len1
= LCMapStringA(lcid
,mapstring_flags
,s1
,l1
,NULL
,0);
2429 len2
= LCMapStringA(lcid
,mapstring_flags
,s2
,l2
,NULL
,0);
2431 if ((len1
==0)||(len2
==0))
2432 return 0; /* something wrong happened */
2434 sk1
= (LPSTR
)HeapAlloc(GetProcessHeap(),0,len1
);
2435 sk2
= (LPSTR
)HeapAlloc(GetProcessHeap(),0,len2
);
2436 if ( (!LCMapStringA(lcid
,mapstring_flags
,s1
,l1
,sk1
,len1
))
2437 || (!LCMapStringA(lcid
,mapstring_flags
,s2
,l2
,sk2
,len2
)) )
2439 ERR("Bug in LCmapString32A.\n");
2444 /* strcmp doesn't necessarily return -1, 0, or 1 */
2445 result
= strcmp(sk1
,sk2
);
2447 HeapFree(GetProcessHeap(),0,sk1
);
2448 HeapFree(GetProcessHeap(),0,sk2
);
2455 /* must be greater, if we reach this point */
2459 /******************************************************************************
2460 * CompareString32W [KERNEL32.144]
2461 * This implementation ignores the locale
2462 * FIXME : Does only string sort. Should
2463 * be reimplemented the same way as CompareString32A.
2465 UINT WINAPI
CompareStringW(DWORD lcid
, DWORD fdwStyle
,
2466 LPCWSTR s1
, DWORD l1
, LPCWSTR s2
,DWORD l2
)
2469 if(fdwStyle
& NORM_IGNORENONSPACE
)
2470 FIXME("IGNORENONSPACE not supprted\n");
2471 if(fdwStyle
& NORM_IGNORESYMBOLS
)
2472 FIXME("IGNORESYMBOLS not supported\n");
2474 /* Is strcmp defaulting to string sort or to word sort?? */
2475 /* FIXME: Handle NORM_STRINGSORT */
2476 l1
= (l1
==-1)?lstrlenW(s1
):l1
;
2477 l2
= (l2
==-1)?lstrlenW(s2
):l2
;
2478 len
= l1
<l2
? l1
:l2
;
2479 ret
= (fdwStyle
& NORM_IGNORECASE
) ?
2480 CRTDLL__wcsnicmp(s1
,s2
,len
) : CRTDLL_wcsncmp(s1
,s2
,len
);
2481 /* not equal, return 1 or 3 */
2482 if(ret
!=0) return ret
+2;
2483 /* same len, return 2 */
2484 if(l1
==l2
) return 2;
2485 /* the longer one is lexically greater */
2486 return (l1
<l2
)? 1 : 3;
2489 /******************************************************************************
2490 * RegisterNLSInfoChanged [OLE2NLS.10]
2492 BOOL16 WINAPI
RegisterNLSInfoChanged16(LPVOID
/*FIXME*/ lpNewNLSInfo
)
2494 FIXME("Fully implemented, but doesn't effect anything.\n");
2505 lpNLSInfo
= lpNewNLSInfo
;
2510 return FALSE
; /* ptr not set */
2513 /******************************************************************************
2514 * OLE_GetFormatA [Internal]
2517 * If datelen == 0, it should return the reguired string length.
2519 This function implements stuff for GetDateFormat() and
2522 d single-digit (no leading zero) day (of month)
2523 dd two-digit day (of month)
2524 ddd short day-of-week name
2525 dddd long day-of-week name
2526 M single-digit month
2528 MMM short month name
2529 MMMM full month name
2530 y two-digit year, no leading 0
2532 yyyy four-digit year
2534 h hours with no leading zero (12-hour)
2535 hh hours with full two digits
2536 H hours with no leading zero (24-hour)
2537 HH hours with full two digits
2538 m minutes with no leading zero
2539 mm minutes with full two digits
2540 s seconds with no leading zero
2541 ss seconds with full two digits
2542 t time marker (A or P)
2543 tt time marker (AM, PM)
2544 '' used to quote literal characters
2545 '' (within a quoted string) indicates a literal '
2547 These functions REQUIRE valid locale, date, and format.
2549 static INT
OLE_GetFormatA(LCID locale
,
2553 LPCSTR _format
, /*in*/
2558 int count
, type
, inquote
, Overflow
;
2564 const char * _dgfmt
[] = { "%d", "%02d" };
2565 const char ** dgfmt
= _dgfmt
- 1;
2567 /* report, for debugging */
2568 TRACE("(0x%lx,0x%lx, 0x%lx, time(d=%d,h=%d,m=%d,s=%d), fmt=%p \'%s\' , %p, len=%d)\n",
2569 locale
, flags
, tflags
,
2570 xtime
->wDay
, xtime
->wHour
, xtime
->wMinute
, xtime
->wSecond
,
2571 _format
, _format
, date
, datelen
);
2574 FIXME("datelen = 0, returning 255\n");
2578 /* initalize state variables and output buffer */
2580 count
= 0; inquote
= 0; Overflow
= 0;
2582 date
[0] = buf
[0] = '\0';
2584 strcpy(format
,_format
);
2586 /* alter the formatstring, while it works for all languages now in wine
2587 its possible that it fails when the time looks like ss:mm:hh as example*/
2588 if (tflags
& (TIME_NOMINUTESORSECONDS
))
2589 { if ((pos
= strstr ( format
, ":mm")))
2590 { memcpy ( pos
, pos
+3, strlen(format
)-(pos
-format
)-2 );
2593 if (tflags
& (TIME_NOSECONDS
))
2594 { if ((pos
= strstr ( format
, ":ss")))
2595 { memcpy ( pos
, pos
+3, strlen(format
)-(pos
-format
)-2 );
2599 for (inpos
= 0;; inpos
++) {
2600 /* 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]); */
2602 if (format
[inpos
] == '\'') {
2603 if (format
[inpos
+1] == '\'') {
2605 date
[outpos
++] = '\'';
2608 continue; /* we did nothing to the output */
2610 } else if (format
[inpos
] == '\0') {
2611 date
[outpos
++] = '\0';
2612 if (outpos
> datelen
) Overflow
= 1;
2615 date
[outpos
++] = format
[inpos
];
2616 if (outpos
> datelen
) {
2618 date
[outpos
-1] = '\0'; /* this is the last place where
2619 it's safe to write */
2623 } else if ( (count
&& (format
[inpos
] != type
))
2625 || (count
== 2 && strchr("ghHmst", type
)) )
2629 GetLocaleInfoA(locale
,
2631 + xtime
->wDayOfWeek
- 1,
2633 } else if (count
== 3) {
2634 GetLocaleInfoA(locale
,
2635 LOCALE_SABBREVDAYNAME1
2636 + xtime
->wDayOfWeek
- 1,
2639 sprintf(buf
, dgfmt
[count
], xtime
->wDay
);
2641 } else if (type
== 'M') {
2643 GetLocaleInfoA(locale
,
2644 LOCALE_SABBREVMONTHNAME1
2645 + xtime
->wMonth
- 1,
2647 } else if (count
== 4) {
2648 GetLocaleInfoA(locale
,
2650 + xtime
->wMonth
- 1,
2653 sprintf(buf
, dgfmt
[count
], xtime
->wMonth
);
2655 } else if (type
== 'y') {
2657 sprintf(buf
, "%d", xtime
->wYear
);
2658 } else if (count
== 3) {
2660 WARN("unknown format, c=%c, n=%d\n", type
, count
);
2662 sprintf(buf
, dgfmt
[count
], xtime
->wYear
% 100);
2664 } else if (type
== 'g') {
2666 FIXME("LOCALE_ICALENDARTYPE unimp.\n");
2670 WARN("unknown format, c=%c, n=%d\n", type
, count
);
2672 } else if (type
== 'h') {
2673 /* gives us hours 1:00 -- 12:00 */
2674 sprintf(buf
, dgfmt
[count
], (xtime
->wHour
-1)%12 +1);
2675 } else if (type
== 'H') {
2677 sprintf(buf
, dgfmt
[count
], xtime
->wHour
);
2678 } else if ( type
== 'm') {
2679 sprintf(buf
, dgfmt
[count
], xtime
->wMinute
);
2680 } else if ( type
== 's') {
2681 sprintf(buf
, dgfmt
[count
], xtime
->wSecond
);
2682 } else if (type
== 't') {
2684 sprintf(buf
, "%c", (xtime
->wHour
< 12) ? 'A' : 'P');
2685 } else if (count
== 2) {
2686 /* sprintf(buf, "%s", (xtime->wHour < 12) ? "AM" : "PM"); */
2687 GetLocaleInfoA(locale
,
2689 ? LOCALE_S1159
: LOCALE_S2359
,
2694 /* we need to check the next char in the format string
2695 again, no matter what happened */
2698 /* add the contents of buf to the output */
2699 buflen
= strlen(buf
);
2700 if (outpos
+ buflen
< datelen
) {
2701 date
[outpos
] = '\0'; /* for strcat to hook onto */
2705 date
[outpos
] = '\0';
2706 strncat(date
, buf
, datelen
- outpos
);
2707 date
[datelen
- 1] = '\0';
2708 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2709 WARN("insufficient buffer\n");
2713 /* reset the variables we used to keep track of this item */
2716 } else if (format
[inpos
] == '\0') {
2717 /* we can't check for this at the loop-head, because
2718 that breaks the printing of the last format-item */
2719 date
[outpos
] = '\0';
2722 /* continuing a code for an item */
2725 } else if (strchr("hHmstyMdg", format
[inpos
])) {
2726 type
= format
[inpos
];
2729 } else if (format
[inpos
] == '\'') {
2733 date
[outpos
++] = format
[inpos
];
2735 /* now deal with a possible buffer overflow */
2736 if (outpos
>= datelen
) {
2737 date
[datelen
- 1] = '\0';
2738 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2744 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2747 /* finish it off with a string terminator */
2750 if (outpos
> datelen
-1) outpos
= datelen
-1;
2751 date
[outpos
] = '\0';
2753 TRACE("OLE_GetFormatA returns string '%s', len %d\n",
2758 /******************************************************************************
2759 * OLE_GetFormatW [INTERNAL]
2761 static INT
OLE_GetFormatW(LCID locale
, DWORD flags
, DWORD tflags
,
2764 LPWSTR output
, INT outlen
)
2767 int count
, type
=0, inquote
;
2768 int Overflow
; /* loop check */
2771 WCHAR arg0
[] = {0}, arg1
[] = {'%','d',0};
2772 WCHAR arg2
[] = {'%','0','2','d',0};
2774 int datevars
=0, timevars
=0;
2780 /* make a debug report */
2781 TRACE("args: 0x%lx, 0x%lx, 0x%lx, time(d=%d,h=%d,m=%d,s=%d), fmt:%s (at %p), "
2782 "%p with max len %d\n",
2783 locale
, flags
, tflags
,
2784 xtime
->wDay
, xtime
->wHour
, xtime
->wMinute
, xtime
->wSecond
,
2785 debugstr_w(format
), format
, output
, outlen
);
2788 FIXME("outlen = 0, returning 255\n");
2792 /* initialize state variables */
2795 inquote
= Overflow
= 0;
2796 /* this is really just a sanity check */
2797 output
[0] = buf
[0] = 0;
2799 /* this loop is the core of the function */
2800 for (inpos
= 0; /* we have several break points */ ; inpos
++) {
2802 if (format
[inpos
] == (WCHAR
) '\'') {
2803 if (format
[inpos
+1] == '\'') {
2805 output
[outpos
++] = '\'';
2810 } else if (format
[inpos
] == 0) {
2811 output
[outpos
++] = 0;
2812 if (outpos
> outlen
) Overflow
= 1;
2813 break; /* normal exit (within a quote) */
2815 output
[outpos
++] = format
[inpos
]; /* copy input */
2816 if (outpos
> outlen
) {
2818 output
[outpos
-1] = 0;
2822 } else if ( (count
&& (format
[inpos
] != type
))
2823 || ( (count
==4 && type
=='y') ||
2824 (count
==4 && type
=='M') ||
2825 (count
==4 && type
=='d') ||
2826 (count
==2 && type
=='g') ||
2827 (count
==2 && type
=='h') ||
2828 (count
==2 && type
=='H') ||
2829 (count
==2 && type
=='m') ||
2830 (count
==2 && type
=='s') ||
2831 (count
==2 && type
=='t') ) ) {
2834 GetLocaleInfoW(locale
,
2835 LOCALE_SDAYNAME1
+ xtime
->wDayOfWeek
-1,
2836 buf
, sizeof(buf
)/sizeof(WCHAR
) );
2837 } else if (count
== 3) {
2838 GetLocaleInfoW(locale
,
2839 LOCALE_SABBREVDAYNAME1
+
2840 xtime
->wDayOfWeek
-1,
2841 buf
, sizeof(buf
)/sizeof(WCHAR
) );
2843 wsnprintfW(buf
, 5, argarr
[count
], xtime
->wDay
);
2845 } else if (type
== 'M') {
2847 GetLocaleInfoW(locale
, LOCALE_SMONTHNAME1
+
2848 xtime
->wMonth
-1, buf
,
2849 sizeof(buf
)/sizeof(WCHAR
) );
2850 } else if (count
== 3) {
2851 GetLocaleInfoW(locale
, LOCALE_SABBREVMONTHNAME1
+
2852 xtime
->wMonth
-1, buf
,
2853 sizeof(buf
)/sizeof(WCHAR
) );
2855 wsnprintfW(buf
, 5, argarr
[count
], xtime
->wMonth
);
2857 } else if (type
== 'y') {
2859 wsnprintfW(buf
, 6, argarr
[1] /* "%d" */,
2861 } else if (count
== 3) {
2862 lstrcpynAtoW(buf
, "yyy", 5);
2864 wsnprintfW(buf
, 6, argarr
[count
],
2865 xtime
->wYear
% 100);
2867 } else if (type
== 'g') {
2869 FIXME("LOCALE_ICALENDARTYPE unimplemented\n");
2870 lstrcpynAtoW(buf
, "AD", 5);
2872 /* Win API sez we copy it verbatim */
2873 lstrcpynAtoW(buf
, "g", 5);
2875 } else if (type
== 'h') {
2876 /* hours 1:00-12:00 --- is this right? */
2877 wsnprintfW(buf
, 5, argarr
[count
],
2878 (xtime
->wHour
-1)%12 +1);
2879 } else if (type
== 'H') {
2880 wsnprintfW(buf
, 5, argarr
[count
],
2882 } else if (type
== 'm' ) {
2883 wsnprintfW(buf
, 5, argarr
[count
],
2885 } else if (type
== 's' ) {
2886 wsnprintfW(buf
, 5, argarr
[count
],
2888 } else if (type
== 't') {
2889 GetLocaleInfoW(locale
, (xtime
->wHour
< 12) ?
2890 LOCALE_S1159
: LOCALE_S2359
,
2897 /* no matter what happened, we need to check this next
2898 character the next time we loop through */
2901 /* cat buf onto the output */
2902 outlen
= lstrlenW(buf
);
2903 if (outpos
+ buflen
< outlen
) {
2904 lstrcpyW( output
+ outpos
, buf
);
2907 lstrcpynW( output
+ outpos
, buf
, outlen
- outpos
);
2909 break; /* Abnormal exit */
2912 /* reset the variables we used this time */
2915 } else if (format
[inpos
] == 0) {
2916 /* we can't check for this at the beginning, because that
2917 would keep us from printing a format spec that ended the
2920 break; /* NORMAL EXIT */
2922 /* how we keep track of the middle of a format spec */
2925 } else if ( (datevars
&& (format
[inpos
]=='d' ||
2926 format
[inpos
]=='M' ||
2927 format
[inpos
]=='y' ||
2928 format
[inpos
]=='g') ) ||
2929 (timevars
&& (format
[inpos
]=='H' ||
2930 format
[inpos
]=='h' ||
2931 format
[inpos
]=='m' ||
2932 format
[inpos
]=='s' ||
2933 format
[inpos
]=='t') ) ) {
2934 type
= format
[inpos
];
2937 } else if (format
[inpos
] == '\'') {
2941 /* unquoted literals */
2942 output
[outpos
++] = format
[inpos
];
2947 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2948 WARN(" buffer overflow\n");
2951 /* final string terminator and sanity check */
2953 if (outpos
> outlen
-1) outpos
= outlen
-1;
2954 output
[outpos
] = '0';
2956 TRACE(" returning %s\n", debugstr_w(output
));
2958 return (!Overflow
) ? outlen
: 0;
2963 /******************************************************************************
2964 * GetDateFormat32A [KERNEL32.310]
2965 * Makes an ASCII string of the date
2967 * This function uses format to format the date, or, if format
2968 * is NULL, uses the default for the locale. format is a string
2969 * of literal fields and characters as follows:
2971 * - d single-digit (no leading zero) day (of month)
2972 * - dd two-digit day (of month)
2973 * - ddd short day-of-week name
2974 * - dddd long day-of-week name
2975 * - M single-digit month
2976 * - MM two-digit month
2977 * - MMM short month name
2978 * - MMMM full month name
2979 * - y two-digit year, no leading 0
2980 * - yy two-digit year
2981 * - yyyy four-digit year
2985 INT WINAPI
GetDateFormatA(LCID locale
,DWORD flags
,
2987 LPCSTR format
, LPSTR date
,INT datelen
)
2990 char format_buf
[40];
2993 LPSYSTEMTIME thistime
;
2997 TRACE("(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",
2998 locale
,flags
,xtime
,format
,date
,datelen
);
3001 locale
= LOCALE_SYSTEM_DEFAULT
;
3004 if (locale
== LOCALE_SYSTEM_DEFAULT
) {
3005 thislocale
= GetSystemDefaultLCID();
3006 } else if (locale
== LOCALE_USER_DEFAULT
) {
3007 thislocale
= GetUserDefaultLCID();
3009 thislocale
= locale
;
3012 if (xtime
== NULL
) {
3019 if (format
== NULL
) {
3020 GetLocaleInfoA(thislocale
, ((flags
&DATE_LONGDATE
)
3022 : LOCALE_SSHORTDATE
),
3023 format_buf
, sizeof(format_buf
));
3024 thisformat
= format_buf
;
3026 thisformat
= format
;
3030 ret
= OLE_GetFormatA(thislocale
, flags
, 0, thistime
, thisformat
,
3035 "GetDateFormat32A() returning %d, with data=%s\n",
3040 /******************************************************************************
3041 * GetDateFormat32W [KERNEL32.311]
3042 * Makes a Unicode string of the date
3044 * Acts the same as GetDateFormat32A(), except that it's Unicode.
3045 * Accepts & returns sizes as counts of Unicode characters.
3048 INT WINAPI
GetDateFormatW(LCID locale
,DWORD flags
,
3051 LPWSTR date
, INT datelen
)
3053 unsigned short datearr
[] = {'1','9','9','4','-','1','-','1',0};
3055 FIXME("STUB (should call OLE_GetFormatW)\n");
3056 lstrcpynW(date
, datearr
, datelen
);
3057 return ( datelen
< 9) ? datelen
: 9;
3062 /**************************************************************************
3063 * EnumDateFormats32A (KERNEL32.198)
3065 BOOL WINAPI
EnumDateFormatsA(
3066 DATEFMT_ENUMPROCA lpDateFmtEnumProc
, LCID Locale
, DWORD dwFlags
)
3068 FIXME("Only US English supported\n");
3070 if(!lpDateFmtEnumProc
)
3072 SetLastError(ERROR_INVALID_PARAMETER
);
3078 case DATE_SHORTDATE
:
3079 if(!(*lpDateFmtEnumProc
)("M/d/yy")) return TRUE
;
3080 if(!(*lpDateFmtEnumProc
)("M/d/yyyy")) return TRUE
;
3081 if(!(*lpDateFmtEnumProc
)("MM/dd/yy")) return TRUE
;
3082 if(!(*lpDateFmtEnumProc
)("MM/dd/yyyy")) return TRUE
;
3083 if(!(*lpDateFmtEnumProc
)("yy/MM/dd")) return TRUE
;
3084 if(!(*lpDateFmtEnumProc
)("dd-MMM-yy")) return TRUE
;
3087 if(!(*lpDateFmtEnumProc
)("dddd, MMMM dd, yyyy")) return TRUE
;
3088 if(!(*lpDateFmtEnumProc
)("MMMM dd, yyyy")) return TRUE
;
3089 if(!(*lpDateFmtEnumProc
)("dddd, dd MMMM, yyyy")) return TRUE
;
3090 if(!(*lpDateFmtEnumProc
)("dd MMMM, yyyy")) return TRUE
;
3093 FIXME("Unknown date format (%ld)\n", dwFlags
);
3094 SetLastError(ERROR_INVALID_PARAMETER
);
3099 /**************************************************************************
3100 * EnumDateFormats32W (KERNEL32.199)
3102 BOOL WINAPI
EnumDateFormatsW(
3103 DATEFMT_ENUMPROCW lpDateFmtEnumProc
, LCID Locale
, DWORD dwFlags
)
3105 FIXME("(%p, %ld, %ld): stub\n", lpDateFmtEnumProc
, Locale
, dwFlags
);
3106 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
3110 /**************************************************************************
3111 * EnumTimeFormats32A (KERNEL32.210)
3113 BOOL WINAPI
EnumTimeFormatsA(
3114 TIMEFMT_ENUMPROCA lpTimeFmtEnumProc
, LCID Locale
, DWORD dwFlags
)
3116 FIXME("Only US English supported\n");
3118 if(!lpTimeFmtEnumProc
)
3120 SetLastError(ERROR_INVALID_PARAMETER
);
3126 FIXME("Unknown time format (%ld)\n", dwFlags
);
3129 if(!(*lpTimeFmtEnumProc
)("h:mm:ss tt")) return TRUE
;
3130 if(!(*lpTimeFmtEnumProc
)("hh:mm:ss tt")) return TRUE
;
3131 if(!(*lpTimeFmtEnumProc
)("H:mm:ss")) return TRUE
;
3132 if(!(*lpTimeFmtEnumProc
)("HH:mm:ss")) return TRUE
;
3137 /**************************************************************************
3138 * EnumTimeFormats32W (KERNEL32.211)
3140 BOOL WINAPI
EnumTimeFormatsW(
3141 TIMEFMT_ENUMPROCW lpTimeFmtEnumProc
, LCID Locale
, DWORD dwFlags
)
3143 FIXME("(%p,%ld,%ld): stub\n", lpTimeFmtEnumProc
, Locale
, dwFlags
);
3144 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
3148 /**************************************************************************
3149 * GetNumberFormat32A (KERNEL32.355)
3151 INT WINAPI
GetNumberFormatA(LCID locale
, DWORD dwflags
,
3152 LPCSTR lpvalue
, const NUMBERFMTA
* lpFormat
,
3153 LPSTR lpNumberStr
, int cchNumber
)
3155 FIXME_(file
)("%s: stub, no reformating done\n",lpvalue
);
3157 lstrcpynA( lpNumberStr
, lpvalue
, cchNumber
);
3158 return cchNumber
? lstrlenA( lpNumberStr
) : 0;
3160 /**************************************************************************
3161 * GetNumberFormat32W (KERNEL32.xxx)
3163 INT WINAPI
GetNumberFormatW(LCID locale
, DWORD dwflags
,
3164 LPCWSTR lpvalue
, const NUMBERFMTW
* lpFormat
,
3165 LPWSTR lpNumberStr
, int cchNumber
)
3167 FIXME_(file
)("%s: stub, no reformating done\n",debugstr_w(lpvalue
));
3169 lstrcpynW( lpNumberStr
, lpvalue
, cchNumber
);
3170 return cchNumber
? lstrlenW( lpNumberStr
) : 0;
3172 /******************************************************************************
3173 * OLE2NLS_CheckLocale [intern]
3175 static LCID
OLE2NLS_CheckLocale (LCID locale
)
3178 { locale
= LOCALE_SYSTEM_DEFAULT
;
3181 if (locale
== LOCALE_SYSTEM_DEFAULT
)
3182 { return GetSystemDefaultLCID();
3184 else if (locale
== LOCALE_USER_DEFAULT
)
3185 { return GetUserDefaultLCID();
3191 /******************************************************************************
3192 * GetTimeFormat32A [KERNEL32.422]
3193 * Makes an ASCII string of the time
3195 * Formats date according to format, or locale default if format is
3196 * NULL. The format consists of literal characters and fields as follows:
3198 * h hours with no leading zero (12-hour)
3199 * hh hours with full two digits
3200 * H hours with no leading zero (24-hour)
3201 * HH hours with full two digits
3202 * m minutes with no leading zero
3203 * mm minutes with full two digits
3204 * s seconds with no leading zero
3205 * ss seconds with full two digits
3206 * t time marker (A or P)
3207 * tt time marker (AM, PM)
3211 GetTimeFormatA(LCID locale
, /* in */
3212 DWORD flags
, /* in */
3213 LPSYSTEMTIME xtime
, /* in */
3214 LPCSTR format
, /* in */
3215 LPSTR timestr
, /* out */
3216 INT timelen
/* in */)
3217 { char format_buf
[40];
3220 LPSYSTEMTIME thistime
;
3222 DWORD thisflags
=LOCALE_STIMEFORMAT
; /* standart timeformat */
3225 TRACE("GetTimeFormat(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",locale
,flags
,xtime
,format
,timestr
,timelen
);
3227 thislocale
= OLE2NLS_CheckLocale ( locale
);
3229 if ( flags
& (TIME_NOTIMEMARKER
| TIME_FORCE24HOURFORMAT
))
3230 { FIXME("TIME_NOTIMEMARKER or TIME_FORCE24HOURFORMAT not implemented\n");
3233 flags
&= (TIME_NOSECONDS
| TIME_NOMINUTESORSECONDS
); /* mask for OLE_GetFormatA*/
3236 { if (flags
& LOCALE_NOUSEROVERRIDE
) /*use system default*/
3237 { thislocale
= GetSystemDefaultLCID();
3239 GetLocaleInfoA(thislocale
, thisflags
, format_buf
, sizeof(format_buf
));
3240 thisformat
= format_buf
;
3243 { thisformat
= format
;
3246 if (xtime
== NULL
) /* NULL means use the current local time*/
3253 ret
= OLE_GetFormatA(thislocale
, thisflags
, flags
, thistime
, thisformat
,
3259 /******************************************************************************
3260 * GetTimeFormat32W [KERNEL32.423]
3261 * Makes a Unicode string of the time
3264 GetTimeFormatW(LCID locale
, /* in */
3265 DWORD flags
, /* in */
3266 LPSYSTEMTIME xtime
, /* in */
3267 LPCWSTR format
, /* in */
3268 LPWSTR timestr
, /* out */
3269 INT timelen
/* in */)
3270 { WCHAR format_buf
[40];
3273 LPSYSTEMTIME thistime
;
3275 DWORD thisflags
=LOCALE_STIMEFORMAT
; /* standart timeformat */
3278 TRACE("GetTimeFormat(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",locale
,flags
,
3279 xtime
,debugstr_w(format
),timestr
,timelen
);
3281 thislocale
= OLE2NLS_CheckLocale ( locale
);
3283 if ( flags
& (TIME_NOTIMEMARKER
| TIME_FORCE24HOURFORMAT
))
3284 { FIXME("TIME_NOTIMEMARKER or TIME_FORCE24HOURFORMAT not implemented\n");
3287 flags
&= (TIME_NOSECONDS
| TIME_NOMINUTESORSECONDS
); /* mask for OLE_GetFormatA*/
3290 { if (flags
& LOCALE_NOUSEROVERRIDE
) /*use system default*/
3291 { thislocale
= GetSystemDefaultLCID();
3293 GetLocaleInfoW(thislocale
, thisflags
, format_buf
, 40);
3294 thisformat
= format_buf
;
3297 { thisformat
= format
;
3300 if (xtime
== NULL
) /* NULL means use the current local time*/
3301 { GetSystemTime(&t
);
3308 ret
= OLE_GetFormatW(thislocale
, thisflags
, flags
, thistime
, thisformat
,
3313 /******************************************************************************
3314 * EnumCalendarInfoA [KERNEL32.196]
3316 BOOL WINAPI
EnumCalendarInfoA(
3317 CALINFO_ENUMPROCA calinfoproc
,LCID locale
,CALID calendar
,CALTYPE caltype
3319 FIXME("(%p,0x%04lx,0x%08lx,0x%08lx),stub!\n",calinfoproc
,locale
,calendar
,caltype
);