4 * Copyright 1995 Martin von Loewis
5 * Copyright 1998 David Lee Lambert
20 /* Locale name to id map. used by EnumSystemLocales, GetLocalInfoA
21 * MUST contain all #defines from winnls.h
22 * last entry has NULL name, 0 id.
24 #define LOCALE_ENTRY(x) {#x,LOCALE_##x}
25 static struct tagLOCALE_NAME2ID
{
29 LOCALE_ENTRY(ILANGUAGE
),
30 LOCALE_ENTRY(SLANGUAGE
),
31 LOCALE_ENTRY(SENGLANGUAGE
),
32 LOCALE_ENTRY(SABBREVLANGNAME
),
33 LOCALE_ENTRY(SNATIVELANGNAME
),
34 LOCALE_ENTRY(ICOUNTRY
),
35 LOCALE_ENTRY(SCOUNTRY
),
36 LOCALE_ENTRY(SENGCOUNTRY
),
37 LOCALE_ENTRY(SABBREVCTRYNAME
),
38 LOCALE_ENTRY(SNATIVECTRYNAME
),
39 LOCALE_ENTRY(IDEFAULTLANGUAGE
),
40 LOCALE_ENTRY(IDEFAULTCOUNTRY
),
41 LOCALE_ENTRY(IDEFAULTCODEPAGE
),
42 LOCALE_ENTRY(IDEFAULTANSICODEPAGE
),
44 LOCALE_ENTRY(IMEASURE
),
45 LOCALE_ENTRY(SDECIMAL
),
46 LOCALE_ENTRY(STHOUSAND
),
47 LOCALE_ENTRY(SGROUPING
),
48 LOCALE_ENTRY(IDIGITS
),
50 LOCALE_ENTRY(INEGNUMBER
),
51 LOCALE_ENTRY(SNATIVEDIGITS
),
52 LOCALE_ENTRY(SCURRENCY
),
53 LOCALE_ENTRY(SINTLSYMBOL
),
54 LOCALE_ENTRY(SMONDECIMALSEP
),
55 LOCALE_ENTRY(SMONTHOUSANDSEP
),
56 LOCALE_ENTRY(SMONGROUPING
),
57 LOCALE_ENTRY(ICURRDIGITS
),
58 LOCALE_ENTRY(IINTLCURRDIGITS
),
59 LOCALE_ENTRY(ICURRENCY
),
60 LOCALE_ENTRY(INEGCURR
),
63 LOCALE_ENTRY(SSHORTDATE
),
64 LOCALE_ENTRY(SLONGDATE
),
65 LOCALE_ENTRY(STIMEFORMAT
),
69 LOCALE_ENTRY(ITIMEMARKPOSN
),
70 LOCALE_ENTRY(ICENTURY
),
71 LOCALE_ENTRY(ITLZERO
),
72 LOCALE_ENTRY(IDAYLZERO
),
73 LOCALE_ENTRY(IMONLZERO
),
76 LOCALE_ENTRY(ICALENDARTYPE
),
77 LOCALE_ENTRY(IOPTIONALCALENDAR
),
78 LOCALE_ENTRY(IFIRSTDAYOFWEEK
),
79 LOCALE_ENTRY(IFIRSTWEEKOFYEAR
),
80 LOCALE_ENTRY(SDAYNAME1
),
81 LOCALE_ENTRY(SDAYNAME2
),
82 LOCALE_ENTRY(SDAYNAME3
),
83 LOCALE_ENTRY(SDAYNAME4
),
84 LOCALE_ENTRY(SDAYNAME5
),
85 LOCALE_ENTRY(SDAYNAME6
),
86 LOCALE_ENTRY(SDAYNAME7
),
87 LOCALE_ENTRY(SABBREVDAYNAME1
),
88 LOCALE_ENTRY(SABBREVDAYNAME2
),
89 LOCALE_ENTRY(SABBREVDAYNAME3
),
90 LOCALE_ENTRY(SABBREVDAYNAME4
),
91 LOCALE_ENTRY(SABBREVDAYNAME5
),
92 LOCALE_ENTRY(SABBREVDAYNAME6
),
93 LOCALE_ENTRY(SABBREVDAYNAME7
),
94 LOCALE_ENTRY(SMONTHNAME1
),
95 LOCALE_ENTRY(SMONTHNAME2
),
96 LOCALE_ENTRY(SMONTHNAME3
),
97 LOCALE_ENTRY(SMONTHNAME4
),
98 LOCALE_ENTRY(SMONTHNAME5
),
99 LOCALE_ENTRY(SMONTHNAME6
),
100 LOCALE_ENTRY(SMONTHNAME7
),
101 LOCALE_ENTRY(SMONTHNAME8
),
102 LOCALE_ENTRY(SMONTHNAME9
),
103 LOCALE_ENTRY(SMONTHNAME10
),
104 LOCALE_ENTRY(SMONTHNAME11
),
105 LOCALE_ENTRY(SMONTHNAME12
),
106 LOCALE_ENTRY(SMONTHNAME13
),
107 LOCALE_ENTRY(SABBREVMONTHNAME1
),
108 LOCALE_ENTRY(SABBREVMONTHNAME2
),
109 LOCALE_ENTRY(SABBREVMONTHNAME3
),
110 LOCALE_ENTRY(SABBREVMONTHNAME4
),
111 LOCALE_ENTRY(SABBREVMONTHNAME5
),
112 LOCALE_ENTRY(SABBREVMONTHNAME6
),
113 LOCALE_ENTRY(SABBREVMONTHNAME7
),
114 LOCALE_ENTRY(SABBREVMONTHNAME8
),
115 LOCALE_ENTRY(SABBREVMONTHNAME9
),
116 LOCALE_ENTRY(SABBREVMONTHNAME10
),
117 LOCALE_ENTRY(SABBREVMONTHNAME11
),
118 LOCALE_ENTRY(SABBREVMONTHNAME12
),
119 LOCALE_ENTRY(SABBREVMONTHNAME13
),
120 LOCALE_ENTRY(SPOSITIVESIGN
),
121 LOCALE_ENTRY(SNEGATIVESIGN
),
122 LOCALE_ENTRY(IPOSSIGNPOSN
),
123 LOCALE_ENTRY(INEGSIGNPOSN
),
124 LOCALE_ENTRY(IPOSSYMPRECEDES
),
125 LOCALE_ENTRY(IPOSSEPBYSPACE
),
126 LOCALE_ENTRY(INEGSYMPRECEDES
),
127 LOCALE_ENTRY(INEGSEPBYSPACE
),
128 /* LOCALE_ENTRY(FONTSIGNATURE),*/
132 const struct map_lcid2str
{
134 const char *langname
;
137 {0x0402,"Bulgarisch"},
138 {0x0403,"Katalanisch"},
139 {0x0404,"Traditionales Chinesisch"},
140 {0x0405,"Tschecisch"},
143 {0x0408,"Griechisch"},
144 {0x0409,"Amerikanisches Englisch"},
145 {0x040A,"Kastilisches Spanisch"},
147 {0x040C,"Franzvsisch"},
148 {0x040D,"Hebrdisch"},
149 {0x040E,"Ungarisch"},
150 {0x040F,"Isldndisch"},
151 {0x0410,"Italienisch"},
152 {0x0411,"Japanisch"},
153 {0x0412,"Koreanisch"},
154 {0x0413,"Niederldndisch"},
155 {0x0414,"Norwegisch-Bokmal"},
157 {0x0416,"Brasilianisches Portugiesisch"},
158 {0x0417,"Rdtoromanisch"},
159 {0x0418,"Rumdnisch"},
161 {0x041A,"Kroatoserbisch (lateinisch)"},
162 {0x041B,"Slowenisch"},
163 {0x041C,"Albanisch"},
164 {0x041D,"Schwedisch"},
169 {0x0804,"Vereinfachtes Chinesisch"},
170 {0x0807,"Schweizerdeutsch"},
171 {0x0809,"Britisches Englisch"},
172 {0x080A,"Mexikanisches Spanisch"},
173 {0x080C,"Belgisches Franzvsisch"},
174 {0x0810,"Schweizerisches Italienisch"},
175 {0x0813,"Belgisches Niederldndisch"},
176 {0x0814,"Norgwegisch-Nynorsk"},
177 {0x0816,"Portugiesisch"},
178 {0x081A,"Serbokratisch (kyrillisch)"},
179 {0x0C1C,"Kanadisches Franzvsisch"},
180 {0x100C,"Schweizerisches Franzvsisch"},
181 {0x0000,"Unbekannt"},
184 /***********************************************************************
185 * GetUserDefaultLCID (OLE2NLS.1)
187 LCID WINAPI
GetUserDefaultLCID()
189 /* Default sorting, neutral sublanguage */
190 switch(Options
.language
)
192 /* case LANG_Bu: return 0x02; */ /* Bulgarian */
193 /* case LANG_Ch: return 0x04; */ /* Chinese */
194 case LANG_Cz
: return 0x05; /* Czech */
195 case LANG_Da
: return 0x06; /* Danish */
196 case LANG_De
: return 0x07; /* German */
197 /* case LANG_Gr: return 0x08; */ /* Greek */
198 case LANG_En
: return 0x09; /* English */
199 case LANG_Es
: return 0x0a; /* Spanish */
200 case LANG_Fi
: return 0x0b; /* Finnish */
201 case LANG_Fr
: return 0x0c; /* French */
202 case LANG_Hu
: return 0x0e; /* Hungarian */
203 /* case LANG_Ic: return 0x0f; */ /* Icelandic */
204 case LANG_It
: return 0x10; /* Italian */
205 /* case LANG_Jp: return 0x11; */ /* Japanese */
206 case LANG_Ko
: return 0x12; /* Korean */
207 /* case LANG_Du: return 0x13; */ /* Dutch */
208 case LANG_No
: return 0x14; /* Norwegian */
209 case LANG_Pl
: return 0x15; /* Polish */
210 case LANG_Po
: return 0x16; /* Portuguese */
211 /* case LANG_Ro: return 0x18; */ /* Romanian */
212 /* case LANG_Ru: return 0x19; */ /* Russian */
213 /* case LANG_Cr: return 0x1a; */ /* Croatian */
214 /* case LANG_Sl: return 0x1b; */ /* Slovak */
215 case LANG_Sw
: return 0x1d; /* Swedish */
216 /* case LANG_Tu: return 0x1f; */ /* Turkish */
217 /* case LANG_Sv: return 0x24; */ /* Slovenian */
218 case LANG_Eo
: return 0x25; /* Esperanto (not official) */
219 case LANG_Ca
: return 0x26; /* Catalan */
222 return 0x00; /* Neutral language */
226 /***********************************************************************
227 * GetSystemDefaultLCID (OLE2NLS.2)
229 LCID WINAPI
GetSystemDefaultLCID()
231 return GetUserDefaultLCID();
234 /***********************************************************************
235 * GetUserDefaultLangID (OLE2NLS.3)
237 LANGID WINAPI
GetUserDefaultLangID()
239 return 0x400|(WORD
)GetUserDefaultLCID();
242 /***********************************************************************
243 * GetSystemDefaultLangID (OLE2NLS.4)
245 LANGID WINAPI
GetSystemDefaultLangID()
247 return 0x400|GetUserDefaultLangID();
250 /***********************************************************************
251 * GetLocaleInfoA (OLE2NLS.5)
252 * Is the last parameter really WORD for Win16?
254 INT16 WINAPI
GetLocaleInfo16(LCID lcid
,LCTYPE LCType
,LPSTR buf
,INT16 len
)
256 return GetLocaleInfo32A(lcid
,LCType
,buf
,len
);
259 INT32 WINAPI
GetLocaleInfo32A(LCID lcid
,LCTYPE LCType
,LPSTR buf
,INT32 len
)
264 TRACE(ole
,"(0x%lx,0x%lx,%p,%x)\n",
265 lcid
,LCType
,buf
,len
);
267 LCType
&= ~(LOCALE_NOUSEROVERRIDE
|LOCALE_USE_CP_ACP
);
269 /* As an option, we could obtain the value from win.ini.
270 This would not match the Wine compile-time option.
271 Also, not all identifiers are available from win.ini */
273 /* If we are through all of this, retLen should not be zero anymore.
274 If it is, the value is not supported */
276 while (locale_name2id
[i
].name
!=NULL
) {
277 if (LCType
== locale_name2id
[i
].id
) {
278 retString
= locale_name2id
[i
].name
;
284 WARN(ole
,"Unkown LC type %lX\n",LCType
);
288 #define LOCVAL(type,value) case type:retString=value;break;
290 /* Now, the language specific definitions. They don't have to be
293 switch(Options
.language
)
297 #include "nls/deu.nls"
298 default: found
=0;break;
300 break; /* LANG(De) */
304 #include "nls/dnk.nls"
305 default: found
=0;break;
307 break; /* LANG(Da) */
311 #include "nls/enu.nls"
312 default: found
=0;break;
314 break; /* LANG(En) */
318 #include "nls/esperanto.nls"
319 default: found
=0;break;
321 break; /* LANG(Eo) */
325 #include "nls/fin.nls"
326 default: found
=0;break;
328 break; /* LANG(Fi) */
332 #include "nls/ita.nls"
333 default: found
=0;break;
335 break; /* LANG(It) */
339 #include "nls/eng.nls"
340 default: found
=0;break;
342 break; /* LANG(0x0809) (U.K. English) */
344 case LANG_Ko
: /* string using codepage 949 */
346 #include "nls/kor.nls"
347 default: found
=0;break;
349 break; /* LANG(Ko) */
353 #include "nls/hun.nls"
354 default: found
=0;break;
356 break; /* LANG(En) */
360 #include "nls/plk.nls"
361 default: found
=0;break;
363 break; /* LANG(Pl) */
367 #include "nls/ptb.nls"
368 default: found
=0;break;
370 break; /* LANG(Po) */
374 #include "nls/sve.nls"
375 default: found
=0;break;
377 break; /* LANG(Sw) */
379 /*Insert other languages here*/
387 ERR(ole
,"'%s' not supported for your language.\n",
389 retString
= "<WINE-NLS-unknown>";
393 lstrcpyn32A(buf
,retString
,len
);
394 return strlen(retString
)+1;
397 /***********************************************************************
398 * GetLocaleInfo32W (KERNEL32.230)
399 * Is the last parameter really WORD for Win16?
401 INT32 WINAPI
GetLocaleInfo32W(LCID lcid
,LCTYPE LCType
,LPWSTR wbuf
,INT32 len
)
403 LPSTR abuf
= (LPSTR
)HeapAlloc(GetProcessHeap(),0,len
);
405 INT32 n
= GetLocaleInfo32A(lcid
, LCType
, abuf
, len
);
407 lstrcpynAtoW(wbuf
,abuf
,len
);
408 HeapFree(GetProcessHeap(),0,abuf
);
412 /***********************************************************************
413 * SetLocaleInfoA [KERNEL32.499]
415 BOOL16 WINAPI
SetLocaleInfoA(DWORD lcid
, DWORD lctype
, LPCSTR data
)
417 FIXME(ole
,"(%ld,%ld,%s): stub\n",lcid
,lctype
,data
);
421 /***********************************************************************
422 * IsValidLocale [KERNEL32.361]
424 BOOL32 WINAPI
IsValidLocale(LCID lcid
,DWORD flags
)
426 /* we support ANY language. Well, at least say that...*/
430 /***********************************************************************
431 * EnumSystemLocales32W [KERNEL32.93]
433 BOOL32 WINAPI
EnumSystemLocales32W( LOCALE_ENUMPROC32W lpfnLocaleEnum
,
441 TRACE(win32
,"(%p,%08lx)\n",lpfnLocaleEnum
,flags
);
442 /* see if we can reuse the Win95 registry entries.... */
443 if (ERROR_SUCCESS
==RegOpenKey32A(HKEY_LOCAL_MACHINE
,"\\System\\CurrentControlSet\\control\\Nls\\Locale\\",&xhkey
)) {
446 if (ERROR_SUCCESS
!=RegEnumKey32W(xhkey
,i
,buffer
,sizeof(buffer
)))
448 if (!lpfnLocaleEnum(buffer
))
457 while (languages
[i
].langname
!=NULL
)
462 sprintf(xbuffer
,"%08lx",(DWORD
)languages
[i
].langid
);
464 cp
= HEAP_strdupAtoW( GetProcessHeap(), 0, xbuffer
);
465 ret
= lpfnLocaleEnum(cp
);
466 HeapFree( GetProcessHeap(), 0, cp
);
473 /***********************************************************************
474 * EnumSystemLocales32A [KERNEL32.92]
476 BOOL32 WINAPI
EnumSystemLocales32A(LOCALE_ENUMPROC32A lpfnLocaleEnum
,
483 TRACE(win32
,"(%p,%08lx)\n",
486 if (ERROR_SUCCESS
==RegOpenKey32A(HKEY_LOCAL_MACHINE
,"\\System\\CurrentControlSet\\control\\Nls\\Locale\\",&xhkey
)) {
489 if (ERROR_SUCCESS
!=RegEnumKey32A(xhkey
,i
,buffer
,sizeof(buffer
)))
491 if (!lpfnLocaleEnum(buffer
))
499 while (languages
[i
].langname
!=NULL
) {
500 sprintf(buffer
,"%08lx",(DWORD
)languages
[i
].langid
);
501 if (!lpfnLocaleEnum(buffer
))
508 static const unsigned char CT_CType2_LUT
[] = {
509 C2_NOTAPPLICABLE
, /* - 0 */
510 C2_NOTAPPLICABLE
, /* - 1 */
511 C2_NOTAPPLICABLE
, /* - 2 */
512 C2_NOTAPPLICABLE
, /* - 3 */
513 C2_NOTAPPLICABLE
, /* - 4 */
514 C2_NOTAPPLICABLE
, /* - 5 */
515 C2_NOTAPPLICABLE
, /* - 6 */
516 C2_NOTAPPLICABLE
, /* - 7 */
517 C2_NOTAPPLICABLE
, /* - 8 */
518 C2_SEGMENTSEPARATOR
, /* - 9 */
519 C2_NOTAPPLICABLE
, /* - 10 */
520 C2_NOTAPPLICABLE
, /* - 11 */
521 C2_NOTAPPLICABLE
, /* - 12 */
522 C2_NOTAPPLICABLE
, /* - 13 */
523 C2_NOTAPPLICABLE
, /* - 14 */
524 C2_NOTAPPLICABLE
, /* - 15 */
525 C2_NOTAPPLICABLE
, /* - 16 */
526 C2_NOTAPPLICABLE
, /* - 17 */
527 C2_NOTAPPLICABLE
, /* - 18 */
528 C2_NOTAPPLICABLE
, /* - 19 */
529 C2_NOTAPPLICABLE
, /* - 20 */
530 C2_NOTAPPLICABLE
, /* - 21 */
531 C2_NOTAPPLICABLE
, /* - 22 */
532 C2_NOTAPPLICABLE
, /* - 23 */
533 C2_NOTAPPLICABLE
, /* - 24 */
534 C2_NOTAPPLICABLE
, /* - 25 */
535 C2_NOTAPPLICABLE
, /* - 26 */
536 C2_NOTAPPLICABLE
, /* - 27 */
537 C2_NOTAPPLICABLE
, /* - 28 */
538 C2_NOTAPPLICABLE
, /* - 29 */
539 C2_NOTAPPLICABLE
, /* - 30 */
540 C2_NOTAPPLICABLE
, /* - 31 */
541 C2_WHITESPACE
, /* - 32 */
542 C2_OTHERNEUTRAL
, /* ! - 33 */
543 C2_OTHERNEUTRAL
, /* " - 34 */ /* " */
544 C2_EUROPETERMINATOR
, /* # - 35 */
545 C2_EUROPETERMINATOR
, /* $ - 36 */
546 C2_EUROPETERMINATOR
, /* % - 37 */
547 C2_LEFTTORIGHT
, /* & - 38 */
548 C2_OTHERNEUTRAL
, /* ' - 39 */
549 C2_OTHERNEUTRAL
, /* ( - 40 */
550 C2_OTHERNEUTRAL
, /* ) - 41 */
551 C2_OTHERNEUTRAL
, /* * - 42 */
552 C2_EUROPETERMINATOR
, /* + - 43 */
553 C2_COMMONSEPARATOR
, /* , - 44 */
554 C2_EUROPETERMINATOR
, /* - - 45 */
555 C2_EUROPESEPARATOR
, /* . - 46 */
556 C2_EUROPESEPARATOR
, /* / - 47 */
557 C2_EUROPENUMBER
, /* 0 - 48 */
558 C2_EUROPENUMBER
, /* 1 - 49 */
559 C2_EUROPENUMBER
, /* 2 - 50 */
560 C2_EUROPENUMBER
, /* 3 - 51 */
561 C2_EUROPENUMBER
, /* 4 - 52 */
562 C2_EUROPENUMBER
, /* 5 - 53 */
563 C2_EUROPENUMBER
, /* 6 - 54 */
564 C2_EUROPENUMBER
, /* 7 - 55 */
565 C2_EUROPENUMBER
, /* 8 - 56 */
566 C2_EUROPENUMBER
, /* 9 - 57 */
567 C2_COMMONSEPARATOR
, /* : - 58 */
568 C2_OTHERNEUTRAL
, /* ; - 59 */
569 C2_OTHERNEUTRAL
, /* < - 60 */
570 C2_OTHERNEUTRAL
, /* = - 61 */
571 C2_OTHERNEUTRAL
, /* > - 62 */
572 C2_OTHERNEUTRAL
, /* ? - 63 */
573 C2_LEFTTORIGHT
, /* @ - 64 */
574 C2_LEFTTORIGHT
, /* A - 65 */
575 C2_LEFTTORIGHT
, /* B - 66 */
576 C2_LEFTTORIGHT
, /* C - 67 */
577 C2_LEFTTORIGHT
, /* D - 68 */
578 C2_LEFTTORIGHT
, /* E - 69 */
579 C2_LEFTTORIGHT
, /* F - 70 */
580 C2_LEFTTORIGHT
, /* G - 71 */
581 C2_LEFTTORIGHT
, /* H - 72 */
582 C2_LEFTTORIGHT
, /* I - 73 */
583 C2_LEFTTORIGHT
, /* J - 74 */
584 C2_LEFTTORIGHT
, /* K - 75 */
585 C2_LEFTTORIGHT
, /* L - 76 */
586 C2_LEFTTORIGHT
, /* M - 77 */
587 C2_LEFTTORIGHT
, /* N - 78 */
588 C2_LEFTTORIGHT
, /* O - 79 */
589 C2_LEFTTORIGHT
, /* P - 80 */
590 C2_LEFTTORIGHT
, /* Q - 81 */
591 C2_LEFTTORIGHT
, /* R - 82 */
592 C2_LEFTTORIGHT
, /* S - 83 */
593 C2_LEFTTORIGHT
, /* T - 84 */
594 C2_LEFTTORIGHT
, /* U - 85 */
595 C2_LEFTTORIGHT
, /* V - 86 */
596 C2_LEFTTORIGHT
, /* W - 87 */
597 C2_LEFTTORIGHT
, /* X - 88 */
598 C2_LEFTTORIGHT
, /* Y - 89 */
599 C2_LEFTTORIGHT
, /* Z - 90 */
600 C2_OTHERNEUTRAL
, /* [ - 91 */
601 C2_OTHERNEUTRAL
, /* \ - 92 */
602 C2_OTHERNEUTRAL
, /* ] - 93 */
603 C2_OTHERNEUTRAL
, /* ^ - 94 */
604 C2_OTHERNEUTRAL
, /* _ - 95 */
605 C2_OTHERNEUTRAL
, /* ` - 96 */
606 C2_LEFTTORIGHT
, /* a - 97 */
607 C2_LEFTTORIGHT
, /* b - 98 */
608 C2_LEFTTORIGHT
, /* c - 99 */
609 C2_LEFTTORIGHT
, /* d - 100 */
610 C2_LEFTTORIGHT
, /* e - 101 */
611 C2_LEFTTORIGHT
, /* f - 102 */
612 C2_LEFTTORIGHT
, /* g - 103 */
613 C2_LEFTTORIGHT
, /* h - 104 */
614 C2_LEFTTORIGHT
, /* i - 105 */
615 C2_LEFTTORIGHT
, /* j - 106 */
616 C2_LEFTTORIGHT
, /* k - 107 */
617 C2_LEFTTORIGHT
, /* l - 108 */
618 C2_LEFTTORIGHT
, /* m - 109 */
619 C2_LEFTTORIGHT
, /* n - 110 */
620 C2_LEFTTORIGHT
, /* o - 111 */
621 C2_LEFTTORIGHT
, /* p - 112 */
622 C2_LEFTTORIGHT
, /* q - 113 */
623 C2_LEFTTORIGHT
, /* r - 114 */
624 C2_LEFTTORIGHT
, /* s - 115 */
625 C2_LEFTTORIGHT
, /* t - 116 */
626 C2_LEFTTORIGHT
, /* u - 117 */
627 C2_LEFTTORIGHT
, /* v - 118 */
628 C2_LEFTTORIGHT
, /* w - 119 */
629 C2_LEFTTORIGHT
, /* x - 120 */
630 C2_LEFTTORIGHT
, /* y - 121 */
631 C2_LEFTTORIGHT
, /* z - 122 */
632 C2_OTHERNEUTRAL
, /* { - 123 */
633 C2_OTHERNEUTRAL
, /* | - 124 */
634 C2_OTHERNEUTRAL
, /* } - 125 */
635 C2_OTHERNEUTRAL
, /* ~ - 126 */
636 C2_NOTAPPLICABLE
, /* \x7f - 127 */
637 C2_NOTAPPLICABLE
, /* € - 128 */
638 C2_NOTAPPLICABLE
, /* � - 129 */
639 C2_OTHERNEUTRAL
, /* ‚ - 130 */
640 C2_LEFTTORIGHT
, /* ƒ - 131 */
641 C2_OTHERNEUTRAL
, /* „ - 132 */
642 C2_OTHERNEUTRAL
, /* … - 133 */
643 C2_OTHERNEUTRAL
, /* † - 134 */
644 C2_OTHERNEUTRAL
, /* ‡ - 135 */
645 C2_LEFTTORIGHT
, /* ˆ - 136 */
646 C2_EUROPETERMINATOR
, /* ‰ - 137 */
647 C2_LEFTTORIGHT
, /* Š - 138 */
648 C2_OTHERNEUTRAL
, /* ‹ - 139 */
649 C2_LEFTTORIGHT
, /* Œ - 140 */
650 C2_NOTAPPLICABLE
, /* � - 141 */
651 C2_NOTAPPLICABLE
, /* Ž - 142 */
652 C2_NOTAPPLICABLE
, /* � - 143 */
653 C2_NOTAPPLICABLE
, /* � - 144 */
654 C2_OTHERNEUTRAL
, /* ‘ - 145 */
655 C2_OTHERNEUTRAL
, /* ’ - 146 */
656 C2_OTHERNEUTRAL
, /* “ - 147 */
657 C2_OTHERNEUTRAL
, /* ” - 148 */
658 C2_OTHERNEUTRAL
, /* • - 149 */
659 C2_OTHERNEUTRAL
, /* – - 150 */
660 C2_OTHERNEUTRAL
, /* — - 151 */
661 C2_LEFTTORIGHT
, /* ˜ - 152 */
662 C2_OTHERNEUTRAL
, /* ™ - 153 */
663 C2_LEFTTORIGHT
, /* š - 154 */
664 C2_OTHERNEUTRAL
, /* › - 155 */
665 C2_LEFTTORIGHT
, /* œ - 156 */
666 C2_NOTAPPLICABLE
, /* � - 157 */
667 C2_NOTAPPLICABLE
, /* ž - 158 */
668 C2_LEFTTORIGHT
, /* Ÿ - 159 */
669 C2_WHITESPACE
, /* - 160 */
670 C2_OTHERNEUTRAL
, /* ¡ - 161 */
671 C2_EUROPETERMINATOR
, /* ¢ - 162 */
672 C2_EUROPETERMINATOR
, /* £ - 163 */
673 C2_EUROPETERMINATOR
, /* ¤ - 164 */
674 C2_EUROPETERMINATOR
, /* ¥ - 165 */
675 C2_OTHERNEUTRAL
, /* ¦ - 166 */
676 C2_OTHERNEUTRAL
, /* § - 167 */
677 C2_OTHERNEUTRAL
, /* ¨ - 168 */
678 C2_OTHERNEUTRAL
, /* © - 169 */
679 C2_OTHERNEUTRAL
, /* ª - 170 */
680 C2_OTHERNEUTRAL
, /* « - 171 */
681 C2_OTHERNEUTRAL
, /* ¬ - 172 */
682 C2_OTHERNEUTRAL
, /* - 173 */
683 C2_OTHERNEUTRAL
, /* ® - 174 */
684 C2_OTHERNEUTRAL
, /* ¯ - 175 */
685 C2_EUROPETERMINATOR
, /* ° - 176 */
686 C2_EUROPETERMINATOR
, /* ± - 177 */
687 C2_EUROPENUMBER
, /* ² - 178 */
688 C2_EUROPENUMBER
, /* ³ - 179 */
689 C2_OTHERNEUTRAL
, /* ´ - 180 */
690 C2_OTHERNEUTRAL
, /* µ - 181 */
691 C2_OTHERNEUTRAL
, /* ¶ - 182 */
692 C2_OTHERNEUTRAL
, /* · - 183 */
693 C2_OTHERNEUTRAL
, /* ¸ - 184 */
694 C2_EUROPENUMBER
, /* ¹ - 185 */
695 C2_OTHERNEUTRAL
, /* º - 186 */
696 C2_OTHERNEUTRAL
, /* » - 187 */
697 C2_OTHERNEUTRAL
, /* ¼ - 188 */
698 C2_OTHERNEUTRAL
, /* ½ - 189 */
699 C2_OTHERNEUTRAL
, /* ¾ - 190 */
700 C2_OTHERNEUTRAL
, /* ¿ - 191 */
701 C2_LEFTTORIGHT
, /* À - 192 */
702 C2_LEFTTORIGHT
, /* Á - 193 */
703 C2_LEFTTORIGHT
, /* Â - 194 */
704 C2_LEFTTORIGHT
, /* Ã - 195 */
705 C2_LEFTTORIGHT
, /* Ä - 196 */
706 C2_LEFTTORIGHT
, /* Å - 197 */
707 C2_LEFTTORIGHT
, /* Æ - 198 */
708 C2_LEFTTORIGHT
, /* Ç - 199 */
709 C2_LEFTTORIGHT
, /* È - 200 */
710 C2_LEFTTORIGHT
, /* É - 201 */
711 C2_LEFTTORIGHT
, /* Ê - 202 */
712 C2_LEFTTORIGHT
, /* Ë - 203 */
713 C2_LEFTTORIGHT
, /* Ì - 204 */
714 C2_LEFTTORIGHT
, /* Í - 205 */
715 C2_LEFTTORIGHT
, /* Î - 206 */
716 C2_LEFTTORIGHT
, /* Ï - 207 */
717 C2_LEFTTORIGHT
, /* Ð - 208 */
718 C2_LEFTTORIGHT
, /* Ñ - 209 */
719 C2_LEFTTORIGHT
, /* Ò - 210 */
720 C2_LEFTTORIGHT
, /* Ó - 211 */
721 C2_LEFTTORIGHT
, /* Ô - 212 */
722 C2_LEFTTORIGHT
, /* Õ - 213 */
723 C2_LEFTTORIGHT
, /* Ö - 214 */
724 C2_OTHERNEUTRAL
, /* × - 215 */
725 C2_LEFTTORIGHT
, /* Ø - 216 */
726 C2_LEFTTORIGHT
, /* Ù - 217 */
727 C2_LEFTTORIGHT
, /* Ú - 218 */
728 C2_LEFTTORIGHT
, /* Û - 219 */
729 C2_LEFTTORIGHT
, /* Ü - 220 */
730 C2_LEFTTORIGHT
, /* Ý - 221 */
731 C2_LEFTTORIGHT
, /* Þ - 222 */
732 C2_LEFTTORIGHT
, /* ß - 223 */
733 C2_LEFTTORIGHT
, /* à - 224 */
734 C2_LEFTTORIGHT
, /* á - 225 */
735 C2_LEFTTORIGHT
, /* â - 226 */
736 C2_LEFTTORIGHT
, /* ã - 227 */
737 C2_LEFTTORIGHT
, /* ä - 228 */
738 C2_LEFTTORIGHT
, /* å - 229 */
739 C2_LEFTTORIGHT
, /* æ - 230 */
740 C2_LEFTTORIGHT
, /* ç - 231 */
741 C2_LEFTTORIGHT
, /* è - 232 */
742 C2_LEFTTORIGHT
, /* é - 233 */
743 C2_LEFTTORIGHT
, /* ê - 234 */
744 C2_LEFTTORIGHT
, /* ë - 235 */
745 C2_LEFTTORIGHT
, /* ì - 236 */
746 C2_LEFTTORIGHT
, /* í - 237 */
747 C2_LEFTTORIGHT
, /* î - 238 */
748 C2_LEFTTORIGHT
, /* ï - 239 */
749 C2_LEFTTORIGHT
, /* ð - 240 */
750 C2_LEFTTORIGHT
, /* ñ - 241 */
751 C2_LEFTTORIGHT
, /* ò - 242 */
752 C2_LEFTTORIGHT
, /* ó - 243 */
753 C2_LEFTTORIGHT
, /* ô - 244 */
754 C2_LEFTTORIGHT
, /* õ - 245 */
755 C2_LEFTTORIGHT
, /* ö - 246 */
756 C2_OTHERNEUTRAL
, /* ÷ - 247 */
757 C2_LEFTTORIGHT
, /* ø - 248 */
758 C2_LEFTTORIGHT
, /* ù - 249 */
759 C2_LEFTTORIGHT
, /* ú - 250 */
760 C2_LEFTTORIGHT
, /* û - 251 */
761 C2_LEFTTORIGHT
, /* ü - 252 */
762 C2_LEFTTORIGHT
, /* ý - 253 */
763 C2_LEFTTORIGHT
, /* þ - 254 */
764 C2_LEFTTORIGHT
/* ÿ - 255 */
767 static const WORD CT_CType3_LUT
[] = {
802 0x0448, /* " - 34 */ /* " */
868 0x8040, /* d - 100 */
869 0x8040, /* e - 101 */
870 0x8040, /* f - 102 */
871 0x8040, /* g - 103 */
872 0x8040, /* h - 104 */
873 0x8040, /* i - 105 */
874 0x8040, /* j - 106 */
875 0x8040, /* k - 107 */
876 0x8040, /* l - 108 */
877 0x8040, /* m - 109 */
878 0x8040, /* n - 110 */
879 0x8040, /* o - 111 */
880 0x8040, /* p - 112 */
881 0x8040, /* q - 113 */
882 0x8040, /* r - 114 */
883 0x8040, /* s - 115 */
884 0x8040, /* t - 116 */
885 0x8040, /* u - 117 */
886 0x8040, /* v - 118 */
887 0x8040, /* w - 119 */
888 0x8040, /* x - 120 */
889 0x8040, /* y - 121 */
890 0x8040, /* z - 122 */
891 0x0048, /* { - 123 */
892 0x0048, /* | - 124 */
893 0x0048, /* } - 125 */
894 0x0448, /* ~ - 126 */
895 0x0000, /* \x7f - 127 */
896 0x0000, /* € - 128 */
897 0x0000, /* � - 129 */
898 0x0008, /* ‚ - 130 */
899 0x8000, /* ƒ - 131 */
900 0x0008, /* „ - 132 */
901 0x0008, /* … - 133 */
902 0x0008, /* † - 134 */
903 0x0008, /* ‡ - 135 */
904 0x0001, /* ˆ - 136 */
905 0x0008, /* ‰ - 137 */
906 0x8003, /* Š - 138 */
907 0x0008, /* ‹ - 139 */
908 0x8000, /* Œ - 140 */
909 0x0000, /* � - 141 */
910 0x0000, /* Ž - 142 */
911 0x0000, /* � - 143 */
912 0x0000, /* � - 144 */
913 0x0088, /* ‘ - 145 */
914 0x0088, /* ’ - 146 */
915 0x0088, /* “ - 147 */
916 0x0088, /* ” - 148 */
917 0x0008, /* • - 149 */
918 0x0400, /* – - 150 */
919 0x0400, /* — - 151 */
920 0x0408, /* ˜ - 152 */
921 0x0000, /* ™ - 153 */
922 0x8003, /* š - 154 */
923 0x0008, /* › - 155 */
924 0x8000, /* œ - 156 */
925 0x0000, /* � - 157 */
926 0x0000, /* ž - 158 */
927 0x8003, /* Ÿ - 159 */
929 0x0008, /* ¡ - 161 */
930 0x0048, /* ¢ - 162 */
931 0x0048, /* £ - 163 */
932 0x0008, /* ¤ - 164 */
933 0x0048, /* ¥ - 165 */
934 0x0048, /* ¦ - 166 */
935 0x0008, /* § - 167 */
936 0x0408, /* ¨ - 168 */
937 0x0008, /* © - 169 */
938 0x0400, /* ª - 170 */
939 0x0008, /* « - 171 */
940 0x0048, /* ¬ - 172 */
941 0x0408, /* - 173 */
942 0x0008, /* ® - 174 */
943 0x0448, /* ¯ - 175 */
944 0x0008, /* ° - 176 */
945 0x0008, /* ± - 177 */
946 0x0000, /* ² - 178 */
947 0x0000, /* ³ - 179 */
948 0x0408, /* ´ - 180 */
949 0x0008, /* µ - 181 */
950 0x0008, /* ¶ - 182 */
951 0x0008, /* · - 183 */
952 0x0408, /* ¸ - 184 */
953 0x0000, /* ¹ - 185 */
954 0x0400, /* º - 186 */
955 0x0008, /* » - 187 */
956 0x0000, /* ¼ - 188 */
957 0x0000, /* ½ - 189 */
958 0x0000, /* ¾ - 190 */
959 0x0008, /* ¿ - 191 */
960 0x8003, /* À - 192 */
961 0x8003, /* Á - 193 */
962 0x8003, /* Â - 194 */
963 0x8003, /* Ã - 195 */
964 0x8003, /* Ä - 196 */
965 0x8003, /* Å - 197 */
966 0x8000, /* Æ - 198 */
967 0x8003, /* Ç - 199 */
968 0x8003, /* È - 200 */
969 0x8003, /* É - 201 */
970 0x8003, /* Ê - 202 */
971 0x8003, /* Ë - 203 */
972 0x8003, /* Ì - 204 */
973 0x8003, /* Í - 205 */
974 0x8003, /* Î - 206 */
975 0x8003, /* Ï - 207 */
976 0x8000, /* Ð - 208 */
977 0x8003, /* Ñ - 209 */
978 0x8003, /* Ò - 210 */
979 0x8003, /* Ó - 211 */
980 0x8003, /* Ô - 212 */
981 0x8003, /* Õ - 213 */
982 0x8003, /* Ö - 214 */
983 0x0008, /* × - 215 */
984 0x8003, /* Ø - 216 */
985 0x8003, /* Ù - 217 */
986 0x8003, /* Ú - 218 */
987 0x8003, /* Û - 219 */
988 0x8003, /* Ü - 220 */
989 0x8003, /* Ý - 221 */
990 0x8000, /* Þ - 222 */
991 0x8000, /* ß - 223 */
992 0x8003, /* à - 224 */
993 0x8003, /* á - 225 */
994 0x8003, /* â - 226 */
995 0x8003, /* ã - 227 */
996 0x8003, /* ä - 228 */
997 0x8003, /* å - 229 */
998 0x8000, /* æ - 230 */
999 0x8003, /* ç - 231 */
1000 0x8003, /* è - 232 */
1001 0x8003, /* é - 233 */
1002 0x8003, /* ê - 234 */
1003 0x8003, /* ë - 235 */
1004 0x8003, /* ì - 236 */
1005 0x8003, /* í - 237 */
1006 0x8003, /* î - 238 */
1007 0x8003, /* ï - 239 */
1008 0x8000, /* ð - 240 */
1009 0x8003, /* ñ - 241 */
1010 0x8003, /* ò - 242 */
1011 0x8003, /* ó - 243 */
1012 0x8003, /* ô - 244 */
1013 0x8003, /* õ - 245 */
1014 0x8003, /* ö - 246 */
1015 0x0008, /* ÷ - 247 */
1016 0x8003, /* ø - 248 */
1017 0x8003, /* ù - 249 */
1018 0x8003, /* ú - 250 */
1019 0x8003, /* û - 251 */
1020 0x8003, /* ü - 252 */
1021 0x8003, /* ý - 253 */
1022 0x8000, /* þ - 254 */
1023 0x8003 /* ÿ - 255 */
1026 /***********************************************************************
1027 * GetStringTypeA [OLE2NLS.7]
1029 BOOL16 WINAPI
GetStringType16(LCID locale
,DWORD dwInfoType
,LPCSTR src
,
1030 INT16 cchSrc
,LPWORD chartype
)
1032 return GetStringTypeEx32A(locale
,dwInfoType
,src
,cchSrc
,chartype
);
1034 /***********************************************************************
1035 * GetStringTypeA [KERNEL32.277]
1037 BOOL32 WINAPI
GetStringType32A(LCID locale
,DWORD dwInfoType
,LPCSTR src
,
1038 INT32 cchSrc
,LPWORD chartype
)
1040 return GetStringTypeEx32A(locale
,dwInfoType
,src
,cchSrc
,chartype
);
1043 /***********************************************************************
1044 * GetStringTypeExA [KERNEL32.276]
1046 * FIXME: Ignores the locale.
1048 BOOL32 WINAPI
GetStringTypeEx32A(LCID locale
,DWORD dwInfoType
,LPCSTR src
,
1049 INT32 cchSrc
,LPWORD chartype
)
1053 if ((src
==NULL
) || (chartype
==NULL
) || (src
==(LPSTR
)chartype
))
1055 SetLastError(ERROR_INVALID_PARAMETER
);
1060 cchSrc
=lstrlen32A(src
)+1;
1062 switch (dwInfoType
) {
1064 for (i
=0;i
<cchSrc
;i
++)
1067 if (isdigit(src
[i
])) chartype
[i
]|=C1_DIGIT
;
1068 if (isalpha(src
[i
])) chartype
[i
]|=C1_ALPHA
;
1069 if (islower(src
[i
])) chartype
[i
]|=C1_LOWER
;
1070 if (isupper(src
[i
])) chartype
[i
]|=C1_UPPER
;
1071 if (isspace(src
[i
])) chartype
[i
]|=C1_SPACE
;
1072 if (ispunct(src
[i
])) chartype
[i
]|=C1_PUNCT
;
1073 if (iscntrl(src
[i
])) chartype
[i
]|=C1_CNTRL
;
1074 /* FIXME: isblank() is a GNU extension */
1075 /* if (isblank(src[i])) chartype[i]|=C1_BLANK; */
1076 if ((src
[i
] == ' ') || (src
[i
] == '\t')) chartype
[i
]|=C1_BLANK
;
1082 for (i
=0;i
<cchSrc
;i
++)
1084 chartype
[i
]=(WORD
)CT_CType2_LUT
[i
];
1089 for (i
=0;i
<cchSrc
;i
++)
1091 chartype
[i
]=CT_CType3_LUT
[i
];
1096 ERR(ole
,"Unknown dwInfoType:%ld\n",dwInfoType
);
1101 /*********************************************************************
1102 * GetStringTypeW [KERNEL32.279]
1105 * Yes, this is missing LCID locale. MS fault.
1107 BOOL32 WINAPI
GetStringType32W(DWORD dwInfoType
,LPCWSTR src
,INT32 cchSrc
,
1110 return GetStringTypeEx32W(0/*defaultlocale*/,dwInfoType
,src
,cchSrc
,chartype
);
1113 /*********************************************************************
1114 * GetStringTypeW [KERNEL32.278]
1115 * FIXME: unicode chars are assumed chars
1117 BOOL32 WINAPI
GetStringTypeEx32W(LCID locale
,DWORD dwInfoType
,LPCWSTR src
,
1118 INT32 cchSrc
,LPWORD chartype
)
1124 cchSrc
=lstrlen32W(src
)+1;
1126 switch (dwInfoType
) {
1128 FIXME(ole
,"CT_CTYPE2 not supported.\n");
1131 FIXME(ole
,"CT_CTYPE3 not supported.\n");
1135 for (i
=0;i
<cchSrc
;i
++) {
1137 if (isdigit(src
[i
])) chartype
[i
]|=C1_DIGIT
;
1138 if (isalpha(src
[i
])) chartype
[i
]|=C1_ALPHA
;
1139 if (islower(src
[i
])) chartype
[i
]|=C1_LOWER
;
1140 if (isupper(src
[i
])) chartype
[i
]|=C1_UPPER
;
1141 if (isspace(src
[i
])) chartype
[i
]|=C1_SPACE
;
1142 if (ispunct(src
[i
])) chartype
[i
]|=C1_PUNCT
;
1143 if (iscntrl(src
[i
])) chartype
[i
]|=C1_CNTRL
;
1144 /* FIXME: isblank() is a GNU extension */
1145 /* if (isblank(src[i])) chartype[i]|=C1_BLANK; */
1146 if ((src
[i
] == ' ') || (src
[i
] == '\t')) chartype
[i
]|=C1_BLANK
;
1152 /*****************************************************************
1153 * VerLanguageName16 [VER.10]
1155 DWORD WINAPI
VerLanguageName16(UINT16 langid
,LPSTR langname
,UINT16 langnamelen
)
1161 TRACE(ver
,"(%d,%p,%d)\n",langid
,langname
,langnamelen
);
1162 /* First, check \System\CurrentControlSet\control\Nls\Locale\<langid>
1163 * from the registry.
1166 "\\System\\CurrentControlSet\\control\\Nls\\Locale\\%08x",
1168 result
= RegQueryValue16(HKEY_LOCAL_MACHINE
, buffer
, langname
,
1169 (LPDWORD
)&langnamelen
);
1170 if (result
== ERROR_SUCCESS
) {
1171 langname
[langnamelen
-1]='\0';
1174 /* if that fails, use the internal table */
1175 for (i
=0;languages
[i
].langid
!=0;i
++)
1176 if (langid
==languages
[i
].langid
)
1178 strncpy(langname
,languages
[i
].langname
,langnamelen
);
1179 langname
[langnamelen
-1]='\0';
1180 return strlen(languages
[i
].langname
);
1183 /*****************************************************************
1184 * VerLanguageName32A [VERSION.9]
1186 DWORD WINAPI
VerLanguageName32A(UINT32 langid
,LPSTR langname
,
1189 return VerLanguageName16(langid
,langname
,langnamelen
);
1192 /*****************************************************************
1193 * VerLanguageName32W [VERSION.10]
1195 DWORD WINAPI
VerLanguageName32W(UINT32 langid
,LPWSTR langname
,
1203 /* First, check \System\CurrentControlSet\control\Nls\Locale\<langid>
1204 * from the registry.
1207 "\\System\\CurrentControlSet\\control\\Nls\\Locale\\%08x",
1209 keyname
= HEAP_strdupAtoW( GetProcessHeap(), 0, buffer
);
1210 result
= RegQueryValue32W(HKEY_LOCAL_MACHINE
, keyname
, langname
,
1211 (LPDWORD
)&langnamelen
);
1212 HeapFree( GetProcessHeap(), 0, keyname
);
1213 if (result
!= ERROR_SUCCESS
) {
1214 /* if that fails, use the internal table */
1215 for (i
=0;languages
[i
].langid
!=0;i
++)
1216 if (langid
==languages
[i
].langid
)
1218 lstrcpyAtoW( langname
, languages
[i
].langname
);
1219 langnamelen
= strlen(languages
[i
].langname
);
1220 /* same as strlenW(langname); */
1225 static const unsigned char LCM_Unicode_LUT
[] = {
1258 7 , 28, /* ! - 33 */
1259 7 , 29, /* " - 34 */ /* " */
1260 7 , 31, /* # - 35 */
1261 7 , 33, /* $ - 36 */
1262 7 , 35, /* % - 37 */
1263 7 , 37, /* & - 38 */
1264 6 , 128, /* ' - 39 */
1265 7 , 39, /* ( - 40 */
1266 7 , 42, /* ) - 41 */
1267 7 , 45, /* * - 42 */
1269 7 , 47, /* , - 44 */
1270 6 , 130, /* - - 45 */
1271 7 , 51, /* . - 46 */
1272 7 , 53, /* / - 47 */
1273 12 , 3, /* 0 - 48 */
1274 12 , 33, /* 1 - 49 */
1275 12 , 51, /* 2 - 50 */
1276 12 , 70, /* 3 - 51 */
1277 12 , 88, /* 4 - 52 */
1278 12 , 106, /* 5 - 53 */
1279 12 , 125, /* 6 - 54 */
1280 12 , 144, /* 7 - 55 */
1281 12 , 162, /* 8 - 56 */
1282 12 , 180, /* 9 - 57 */
1283 7 , 55, /* : - 58 */
1284 7 , 58, /* ; - 59 */
1285 8 , 14, /* < - 60 */
1286 8 , 18, /* = - 61 */
1287 8 , 20, /* > - 62 */
1288 7 , 60, /* ? - 63 */
1289 7 , 62, /* @ - 64 */
1290 14 , 2, /* A - 65 */
1291 14 , 9, /* B - 66 */
1292 14 , 10, /* C - 67 */
1293 14 , 26, /* D - 68 */
1294 14 , 33, /* E - 69 */
1295 14 , 35, /* F - 70 */
1296 14 , 37, /* G - 71 */
1297 14 , 44, /* H - 72 */
1298 14 , 50, /* I - 73 */
1299 14 , 53, /* J - 74 */
1300 14 , 54, /* K - 75 */
1301 14 , 72, /* L - 76 */
1302 14 , 81, /* M - 77 */
1303 14 , 112, /* N - 78 */
1304 14 , 124, /* O - 79 */
1305 14 , 126, /* P - 80 */
1306 14 , 137, /* Q - 81 */
1307 14 , 138, /* R - 82 */
1308 14 , 145, /* S - 83 */
1309 14 , 153, /* T - 84 */
1310 14 , 159, /* U - 85 */
1311 14 , 162, /* V - 86 */
1312 14 , 164, /* W - 87 */
1313 14 , 166, /* X - 88 */
1314 14 , 167, /* Y - 89 */
1315 14 , 169, /* Z - 90 */
1316 7 , 63, /* [ - 91 */
1317 7 , 65, /* \ - 92 */
1318 7 , 66, /* ] - 93 */
1319 7 , 67, /* ^ - 94 */
1320 7 , 68, /* _ - 95 */
1321 7 , 72, /* ` - 96 */
1322 14 , 2, /* a - 97 */
1323 14 , 9, /* b - 98 */
1324 14 , 10, /* c - 99 */
1325 14 , 26, /* d - 100 */
1326 14 , 33, /* e - 101 */
1327 14 , 35, /* f - 102 */
1328 14 , 37, /* g - 103 */
1329 14 , 44, /* h - 104 */
1330 14 , 50, /* i - 105 */
1331 14 , 53, /* j - 106 */
1332 14 , 54, /* k - 107 */
1333 14 , 72, /* l - 108 */
1334 14 , 81, /* m - 109 */
1335 14 , 112, /* n - 110 */
1336 14 , 124, /* o - 111 */
1337 14 , 126, /* p - 112 */
1338 14 , 137, /* q - 113 */
1339 14 , 138, /* r - 114 */
1340 14 , 145, /* s - 115 */
1341 14 , 153, /* t - 116 */
1342 14 , 159, /* u - 117 */
1343 14 , 162, /* v - 118 */
1344 14 , 164, /* w - 119 */
1345 14 , 166, /* x - 120 */
1346 14 , 167, /* y - 121 */
1347 14 , 169, /* z - 122 */
1348 7 , 74, /* { - 123 */
1349 7 , 76, /* | - 124 */
1350 7 , 78, /* } - 125 */
1351 7 , 80, /* ~ - 126 */
1352 6 , 29, /* \x7f - 127 */
1353 6 , 30, /* € - 128 */
1354 6 , 31, /* � - 129 */
1355 7 , 123, /* ‚ - 130 */
1356 14 , 35, /* ƒ - 131 */
1357 7 , 127, /* „ - 132 */
1358 10 , 21, /* … - 133 */
1359 10 , 15, /* † - 134 */
1360 10 , 16, /* ‡ - 135 */
1361 7 , 67, /* ˆ - 136 */
1362 10 , 22, /* ‰ - 137 */
1363 14 , 145, /* Š - 138 */
1364 7 , 136, /* ‹ - 139 */
1365 14 + 16 , 124, /* Œ - 140 */
1366 6 , 43, /* � - 141 */
1367 6 , 44, /* Ž - 142 */
1368 6 , 45, /* � - 143 */
1369 6 , 46, /* � - 144 */
1370 7 , 121, /* ‘ - 145 */
1371 7 , 122, /* ’ - 146 */
1372 7 , 125, /* “ - 147 */
1373 7 , 126, /* ” - 148 */
1374 10 , 17, /* • - 149 */
1375 6 , 137, /* – - 150 */
1376 6 , 139, /* — - 151 */
1377 7 , 93, /* ˜ - 152 */
1378 14 , 156, /* ™ - 153 */
1379 14 , 145, /* š - 154 */
1380 7 , 137, /* › - 155 */
1381 14 + 16 , 124, /* œ - 156 */
1382 6 , 59, /* � - 157 */
1383 6 , 60, /* ž - 158 */
1384 14 , 167, /* Ÿ - 159 */
1386 7 , 81, /* ¡ - 161 */
1387 10 , 2, /* ¢ - 162 */
1388 10 , 3, /* £ - 163 */
1389 10 , 4, /* ¤ - 164 */
1390 10 , 5, /* ¥ - 165 */
1391 7 , 82, /* ¦ - 166 */
1392 10 , 6, /* § - 167 */
1393 7 , 83, /* ¨ - 168 */
1394 10 , 7, /* © - 169 */
1395 14 , 2, /* ª - 170 */
1396 8 , 24, /* « - 171 */
1397 10 , 8, /* ¬ - 172 */
1398 6 , 131, /* - 173 */
1399 10 , 9, /* ® - 174 */
1400 7 , 84, /* ¯ - 175 */
1401 10 , 10, /* ° - 176 */
1402 8 , 23, /* ± - 177 */
1403 12 , 51, /* ² - 178 */
1404 12 , 70, /* ³ - 179 */
1405 7 , 85, /* ´ - 180 */
1406 10 , 11, /* µ - 181 */
1407 10 , 12, /* ¶ - 182 */
1408 10 , 13, /* · - 183 */
1409 7 , 86, /* ¸ - 184 */
1410 12 , 33, /* ¹ - 185 */
1411 14 , 124, /* º - 186 */
1412 8 , 26, /* » - 187 */
1413 12 , 21, /* ¼ - 188 */
1414 12 , 25, /* ½ - 189 */
1415 12 , 29, /* ¾ - 190 */
1416 7 , 87, /* ¿ - 191 */
1417 14 , 2, /* À - 192 */
1418 14 , 2, /* Á - 193 */
1419 14 , 2, /* Â - 194 */
1420 14 , 2, /* Ã - 195 */
1421 14 , 2, /* Ä - 196 */
1422 14 , 2, /* Å - 197 */
1423 14 + 16 , 2, /* Æ - 198 */
1424 14 , 10, /* Ç - 199 */
1425 14 , 33, /* È - 200 */
1426 14 , 33, /* É - 201 */
1427 14 , 33, /* Ê - 202 */
1428 14 , 33, /* Ë - 203 */
1429 14 , 50, /* Ì - 204 */
1430 14 , 50, /* Í - 205 */
1431 14 , 50, /* Î - 206 */
1432 14 , 50, /* Ï - 207 */
1433 14 , 26, /* Ð - 208 */
1434 14 , 112, /* Ñ - 209 */
1435 14 , 124, /* Ò - 210 */
1436 14 , 124, /* Ó - 211 */
1437 14 , 124, /* Ô - 212 */
1438 14 , 124, /* Õ - 213 */
1439 14 , 124, /* Ö - 214 */
1440 8 , 28, /* × - 215 */
1441 14 , 124, /* Ø - 216 */
1442 14 , 159, /* Ù - 217 */
1443 14 , 159, /* Ú - 218 */
1444 14 , 159, /* Û - 219 */
1445 14 , 159, /* Ü - 220 */
1446 14 , 167, /* Ý - 221 */
1447 14 + 32 , 153, /* Þ - 222 */
1448 14 + 48 , 145, /* ß - 223 */
1449 14 , 2, /* à - 224 */
1450 14 , 2, /* á - 225 */
1451 14 , 2, /* â - 226 */
1452 14 , 2, /* ã - 227 */
1453 14 , 2, /* ä - 228 */
1454 14 , 2, /* å - 229 */
1455 14 + 16 , 2, /* æ - 230 */
1456 14 , 10, /* ç - 231 */
1457 14 , 33, /* è - 232 */
1458 14 , 33, /* é - 233 */
1459 14 , 33, /* ê - 234 */
1460 14 , 33, /* ë - 235 */
1461 14 , 50, /* ì - 236 */
1462 14 , 50, /* í - 237 */
1463 14 , 50, /* î - 238 */
1464 14 , 50, /* ï - 239 */
1465 14 , 26, /* ð - 240 */
1466 14 , 112, /* ñ - 241 */
1467 14 , 124, /* ò - 242 */
1468 14 , 124, /* ó - 243 */
1469 14 , 124, /* ô - 244 */
1470 14 , 124, /* õ - 245 */
1471 14 , 124, /* ö - 246 */
1472 8 , 29, /* ÷ - 247 */
1473 14 , 124, /* ø - 248 */
1474 14 , 159, /* ù - 249 */
1475 14 , 159, /* ú - 250 */
1476 14 , 159, /* û - 251 */
1477 14 , 159, /* ü - 252 */
1478 14 , 167, /* ý - 253 */
1479 14 + 32 , 153, /* þ - 254 */
1480 14 , 167 /* ÿ - 255 */ };
1482 static const unsigned char LCM_Unicode_LUT_2
[] = { 33, 44, 145 };
1484 #define LCM_Diacritic_Start 131
1486 static const unsigned char LCM_Diacritic_LUT
[] = {
1614 static int OLE2NLS_isPunctuation(unsigned char c
)
1616 /* "punctuation character" in this context is a character which is
1617 considered "less important" during word sort comparison.
1618 See LCMapString implementation for the precise definition
1619 of "less important". */
1621 return (LCM_Unicode_LUT
[-2+2*c
]==6);
1624 static int identity(int c
)
1629 /*************************************************************************
1630 * LCMapString32A [KERNEL32.492]
1632 * Convert a string, or generate a sort key from it.
1634 * If (mapflags & LCMAP_SORTKEY), the function will generate
1635 * a sort key for the source string. Else, it will convert it
1636 * accordingly to the flags LCMAP_UPPERCASE, LCMAP_LOWERCASE,...
1640 * Success : length of the result string.
1643 * If called with scrlen = -1, the function will compute the length
1644 * of the 0-terminated string strsrc by itself.
1646 * If called with dstlen = 0, returns the buffer length that
1647 * would be required.
1649 * NORM_IGNOREWIDTH means to compare ASCII and Unicode characters
1650 * as if they are equal. Since Wine separates ASCII and Unicode into
1651 * separate functions, we shouldn't have to do anything for this flag.
1652 * I added it to the list of flags that don't need a fixme message
1653 * to make MS Word 95 not print several thousand fixme messages for
1656 INT32 WINAPI
LCMapString32A(
1657 LCID lcid
/* locale identifier created with MAKELCID;
1658 LOCALE_SYSTEM_DEFAULT and LOCALE_USER_DEFAULT are
1659 predefined values. */,
1660 DWORD mapflags
/* flags */,
1661 LPCSTR srcstr
/* source buffer */,
1662 INT32 srclen
/* source length */,
1663 LPSTR dststr
/* destination buffer */,
1664 INT32 dstlen
/* destination buffer length */)
1668 TRACE(string
,"(0x%04lx,0x%08lx,%s,%d,%p,%d)\n",
1669 lcid
,mapflags
,srcstr
,srclen
,dststr
,dstlen
);
1671 if ( ((dstlen
!=0) && (dststr
==NULL
)) || (srcstr
==NULL
) )
1673 ERR(ole
, "(src=%s,dest=%s): Invalid NULL string\n", srcstr
, dststr
);
1674 SetLastError(ERROR_INVALID_PARAMETER
);
1678 srclen
= lstrlen32A(srcstr
) + 1 ; /* (include final '\0') */
1680 if (mapflags
& ~ ( LCMAP_UPPERCASE
| LCMAP_LOWERCASE
| LCMAP_SORTKEY
|
1681 NORM_IGNORECASE
| NORM_IGNORENONSPACE
| SORT_STRINGSORT
|
1684 FIXME(string
,"(0x%04lx,0x%08lx,%p,%d,%p,%d): "
1685 "unimplemented flags: 0x%08lx\n",
1686 lcid
,mapflags
,srcstr
,srclen
,dststr
,dstlen
,mapflags
);
1689 if ( !(mapflags
& LCMAP_SORTKEY
) )
1691 int (*f
)(int)=identity
;
1694 return srclen
; /* dstlen=0 means "do nothing but return required length" */
1696 srclen
=dstlen
; /* No, this case is not an error under Windows 95.
1697 And no '\0' gets written. */
1698 if (mapflags
& LCMAP_UPPERCASE
)
1700 else if (mapflags
& LCMAP_LOWERCASE
)
1702 for (i
=0; i
< srclen
; i
++)
1703 dststr
[i
] = (CHAR
) f(srcstr
[i
]);
1707 /* else ... (mapflags & LCMAP_SORTKEY) */
1711 int diacritic_len
=0;
1712 int delayed_punctuation_len
=0;
1713 char *case_component
;
1714 char *diacritic_component
;
1715 char *delayed_punctuation_component
;
1717 int flag_stringsort
= mapflags
& SORT_STRINGSORT
;
1719 /* compute how much room we will need */
1720 for (i
=0;i
<srclen
;i
++)
1723 unsigned char source_char
= srcstr
[i
];
1724 if (source_char
!='\0')
1726 if (flag_stringsort
|| !OLE2NLS_isPunctuation(source_char
))
1729 if ( LCM_Unicode_LUT
[-2+2*source_char
] & ~15 )
1730 unicode_len
++; /* double letter */
1734 delayed_punctuation_len
++;
1738 if (isupper(source_char
))
1739 case_len
=unicode_len
;
1741 ofs
= source_char
- LCM_Diacritic_Start
;
1742 if ((ofs
>=0) && (LCM_Diacritic_LUT
[ofs
]!=2))
1743 diacritic_len
=unicode_len
;
1746 if (mapflags
& NORM_IGNORECASE
)
1748 if (mapflags
& NORM_IGNORENONSPACE
)
1751 room
= 2 * unicode_len
/* "unicode" component */
1752 + diacritic_len
/* "diacritic" component */
1753 + case_len
/* "case" component */
1754 + 4 * delayed_punctuation_len
/* punctuation in word sort mode */
1755 + 4 /* four '\1' separators */
1756 + 1 ; /* terminal '\0' */
1759 else if (dstlen
<room
)
1761 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1765 /*FIXME the Pointercheck should not be nessesary */
1766 if (IsBadWritePtr32 (dststr
,room
))
1767 { ERR (string
,"bad destination buffer (dststr) : %p,%d\n",dststr
,dstlen
);
1768 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1772 /* locate each component, write separators */
1773 diacritic_component
= dststr
+ 2*unicode_len
;
1774 *diacritic_component
++ = '\1';
1775 case_component
= diacritic_component
+ diacritic_len
;
1776 *case_component
++ = '\1';
1777 delayed_punctuation_component
= case_component
+ case_len
;
1778 *delayed_punctuation_component
++ = '\1';
1779 *delayed_punctuation_component
++ = '\1';
1781 /* read source string char by char, write
1782 corresponding weight in each component. */
1783 for (i
=0,count
=0;i
<srclen
;i
++)
1785 unsigned char source_char
=srcstr
[i
];
1786 if (source_char
!='\0')
1789 type
= LCM_Unicode_LUT
[-2+2*source_char
];
1790 longcode
= type
>> 4;
1792 if (!flag_stringsort
&& OLE2NLS_isPunctuation(source_char
))
1794 UINT16 encrypted_location
= (1<<15) + 7 + 4*count
;
1795 *delayed_punctuation_component
++ = (unsigned char) (encrypted_location
>>8);
1796 *delayed_punctuation_component
++ = (unsigned char) (encrypted_location
&255);
1797 /* big-endian is used here because it lets string comparison be
1798 compatible with numerical comparison */
1800 *delayed_punctuation_component
++ = type
;
1801 *delayed_punctuation_component
++ = LCM_Unicode_LUT
[-1+2*source_char
];
1802 /* assumption : a punctuation character is never a
1803 double or accented letter */
1807 dststr
[2*count
] = type
;
1808 dststr
[2*count
+1] = LCM_Unicode_LUT
[-1+2*source_char
];
1812 case_component
[count
] = ( isupper(source_char
) ? 18 : 2 ) ;
1813 if (count
<diacritic_len
)
1814 diacritic_component
[count
] = 2; /* assumption: a double letter
1815 is never accented */
1818 dststr
[2*count
] = type
;
1819 dststr
[2*count
+1] = *(LCM_Unicode_LUT_2
- 1 + longcode
);
1820 /* 16 in the first column of LCM_Unicode_LUT --> longcode = 1
1821 32 in the first column of LCM_Unicode_LUT --> longcode = 2
1822 48 in the first column of LCM_Unicode_LUT --> longcode = 3 */
1826 case_component
[count
] = ( isupper(source_char
) ? 18 : 2 ) ;
1827 if (count
<diacritic_len
)
1829 int ofs
= source_char
- LCM_Diacritic_Start
;
1830 diacritic_component
[count
] = (ofs
>=0 ? LCM_Diacritic_LUT
[ofs
] : 2);
1836 dststr
[room
-1] = '\0';
1841 /*************************************************************************
1842 * LCMapString32W [KERNEL32.493]
1844 * Convert a string, or generate a sort key from it.
1848 * See LCMapString32A for documentation
1850 INT32 WINAPI
LCMapString32W(
1851 LCID lcid
,DWORD mapflags
,LPCWSTR srcstr
,INT32 srclen
,LPWSTR dststr
,
1856 TRACE(string
,"(0x%04lx,0x%08lx,%p,%d,%p,%d)\n",
1857 lcid
,mapflags
,srcstr
,srclen
,dststr
,dstlen
);
1859 if ( ((dstlen
!=0) && (dststr
==NULL
)) || (srcstr
==NULL
) )
1861 ERR(ole
, "(src=%p,dst=%p): Invalid NULL string\n", srcstr
, dststr
);
1862 SetLastError(ERROR_INVALID_PARAMETER
);
1866 srclen
= lstrlen32W(srcstr
)+1;
1867 if (mapflags
& LCMAP_SORTKEY
)
1869 FIXME(string
,"(0x%04lx,0x%08lx,%p,%d,%p,%d): "
1870 "unimplemented flags: 0x%08lx\n",
1871 lcid
,mapflags
,srcstr
,srclen
,dststr
,dstlen
,mapflags
);
1876 int (*f
)(int)=identity
;
1882 if (mapflags
& LCMAP_UPPERCASE
)
1884 else if (mapflags
& LCMAP_LOWERCASE
)
1886 for (i
=0; i
< srclen
; i
++)
1887 dststr
[i
] = (WCHAR
) f(srcstr
[i
]);
1892 /***********************************************************************
1893 * CompareString16 (OLE2NLS.8)
1895 UINT16 WINAPI
CompareString16(DWORD lcid
,DWORD fdwStyle
,
1896 LPCSTR s1
,DWORD l1
,LPCSTR s2
,DWORD l2
)
1898 return (UINT16
)CompareString32A(lcid
,fdwStyle
,s1
,l1
,s2
,l2
);
1901 /***********************************************************************
1902 * CompareString32A [KERNEL32.29] Compares two strings using locale
1906 * success: CSTR_LESS_THAN, CSTR_EQUAL, CSTR_GREATER_THAN
1911 * Defaults to a word sort, but uses a string sort if
1912 * SORT_STRINGSORT is set.
1913 * Calls SetLastError for ERROR_INVALID_FLAGS, ERROR_INVALID_PARAMETER.
1917 * This implementation ignores the locale
1921 * Quite inefficient.
1923 UINT32 WINAPI
CompareString32A(
1924 DWORD lcid
, /* locale ID */
1925 DWORD fdwStyle
, /* comparison-style options */
1926 LPCSTR s1
, /* first string */
1927 DWORD l1
, /* length of first string */
1928 LPCSTR s2
, /* second string */
1929 DWORD l2
) /* length of second string */
1931 int mapstring_flags
;
1935 TRACE(ole
,"%s and %s\n",
1936 debugstr_a (s1
), debugstr_a (s2
));
1938 if ( (s1
==NULL
) || (s2
==NULL
) )
1940 ERR(ole
, "(s1=%s,s2=%s): Invalid NULL string\n", s1
, s2
);
1941 SetLastError(ERROR_INVALID_PARAMETER
);
1945 if(fdwStyle
& NORM_IGNORESYMBOLS
)
1946 FIXME(ole
, "IGNORESYMBOLS not supported\n");
1948 mapstring_flags
= LCMAP_SORTKEY
| fdwStyle
;
1949 len1
= LCMapString32A(lcid
,mapstring_flags
,s1
,l1
,NULL
,0);
1950 len2
= LCMapString32A(lcid
,mapstring_flags
,s2
,l2
,NULL
,0);
1952 if ((len1
==0)||(len2
==0))
1953 return 0; /* something wrong happened */
1955 sk1
= (LPSTR
)HeapAlloc(GetProcessHeap(),0,len1
);
1956 sk2
= (LPSTR
)HeapAlloc(GetProcessHeap(),0,len2
);
1957 if ( (!LCMapString32A(lcid
,mapstring_flags
,s1
,l1
,sk1
,len1
))
1958 || (!LCMapString32A(lcid
,mapstring_flags
,s2
,l2
,sk2
,len2
)) )
1960 ERR(ole
,"Bug in LCmapString32A.\n");
1965 /* strcmp doesn't necessarily return -1, 0, or 1 */
1966 result
= strcmp(sk1
,sk2
);
1968 HeapFree(GetProcessHeap(),0,sk1
);
1969 HeapFree(GetProcessHeap(),0,sk2
);
1976 /* must be greater, if we reach this point */
1980 /***********************************************************************
1981 * CompareString32W (KERNEL32.30)
1982 * This implementation ignores the locale
1983 * FIXME : Does only string sort. Should
1984 * be reimplemented the same way as CompareString32A.
1986 UINT32 WINAPI
CompareString32W(DWORD lcid
, DWORD fdwStyle
,
1987 LPCWSTR s1
, DWORD l1
, LPCWSTR s2
,DWORD l2
)
1990 if(fdwStyle
& NORM_IGNORENONSPACE
)
1991 FIXME(ole
,"IGNORENONSPACE not supprted\n");
1992 if(fdwStyle
& NORM_IGNORESYMBOLS
)
1993 FIXME(ole
,"IGNORESYMBOLS not supported\n");
1995 /* Is strcmp defaulting to string sort or to word sort?? */
1996 /* FIXME: Handle NORM_STRINGSORT */
1997 l1
= (l1
==-1)?lstrlen32W(s1
):l1
;
1998 l2
= (l2
==-1)?lstrlen32W(s2
):l2
;
1999 len
= l1
<l2
? l1
:l2
;
2000 ret
= (fdwStyle
& NORM_IGNORECASE
) ?
2001 lstrncmpi32W(s1
,s2
,len
) : lstrncmp32W(s1
,s2
,len
);
2002 /* not equal, return 1 or 3 */
2003 if(ret
!=0) return ret
+2;
2004 /* same len, return 2 */
2005 if(l1
==l2
) return 2;
2006 /* the longer one is lexically greater */
2007 return (l1
<l2
)? 1 : 3;
2010 /*****************************************************************
2012 * OLE_GetFormatA() [internal]
2015 This function implements stuff for GetDateFormat() and
2018 d single-digit (no leading zero) day (of month)
2019 dd two-digit day (of month)
2020 ddd short day-of-week name
2021 dddd long day-of-week name
2022 M single-digit month
2024 MMM short month name
2025 MMMM full month name
2026 y two-digit year, no leading 0
2028 yyyy four-digit year
2030 h hours with no leading zero (12-hour)
2031 hh hours with full two digits
2032 H hours with no leading zero (24-hour)
2033 HH hours with full two digits
2034 m minutes with no leading zero
2035 mm minutes with full two digits
2036 s seconds with no leading zero
2037 ss seconds with full two digits
2038 t time marker (A or P)
2039 tt time marker (AM, PM)
2040 '' used to quote literal characters
2041 '' (within a quoted string) indicates a literal '
2043 These functions REQUIRE valid locale, date, and format.
2047 INT32 WINAPI
OLE_GetFormatA(LCID locale
,
2052 LPSTR date
, INT32 datelen
)
2054 INT32 inpos
, outpos
;
2055 int count
, type
, inquote
, Overflow
;
2061 const char * _dgfmt
[] = { "%d", "%02d" };
2062 const char ** dgfmt
= _dgfmt
- 1;
2064 /* report, for debugging */
2065 TRACE(ole
, "(0x%lx,0x%lx, 0x%lx, time(d=%d,h=%d,m=%d,s=%d), fmt:\'%s\' (at %p), %p (%s), len=%d)\n",
2066 locale
, flags
, tflags
,
2067 xtime
->wDay
, xtime
->wHour
, xtime
->wMinute
, xtime
->wSecond
,
2068 format
, format
, date
, date
, datelen
);
2070 /* initalize state variables and output buffer */
2072 count
= 0; inquote
= 0; Overflow
= 0;
2074 date
[0] = buf
[0] = '\0';
2076 strcpy(format
,_format
);
2078 /* alter the formatstring, while it works for all languages now in wine
2079 its possible that it fails when the time looks like ss:mm:hh as example*/
2080 if (tflags
& (TIME_NOMINUTESORSECONDS
))
2081 { if ((pos
= strstr ( format
, ":mm")))
2082 { memcpy ( pos
, pos
+3, strlen(format
)-(pos
-format
)-2 );
2085 if (tflags
& (TIME_NOSECONDS
))
2086 { if ((pos
= strstr ( format
, ":ss")))
2087 { memcpy ( pos
, pos
+3, strlen(format
)-(pos
-format
)-2 );
2091 for (inpos
= 0;; inpos
++) {
2092 /* 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]); */
2094 if (format
[inpos
] == '\'') {
2095 if (format
[inpos
+1] == '\'') {
2097 date
[outpos
++] = '\'';
2100 continue; /* we did nothing to the output */
2102 } else if (format
[inpos
] == '\0') {
2103 date
[outpos
++] = '\0';
2104 if (outpos
> datelen
) Overflow
= 1;
2107 date
[outpos
++] = format
[inpos
];
2108 if (outpos
> datelen
) {
2110 date
[outpos
-1] = '\0'; /* this is the last place where
2111 it's safe to write */
2115 } else if ( (count
&& (format
[inpos
] != type
))
2117 || (count
== 2 && strchr("ghHmst", type
)) )
2121 GetLocaleInfo32A(locale
,
2123 + xtime
->wDayOfWeek
- 1,
2125 } else if (count
== 3) {
2126 GetLocaleInfo32A(locale
,
2127 LOCALE_SABBREVDAYNAME1
2128 + xtime
->wDayOfWeek
- 1,
2131 sprintf(buf
, dgfmt
[count
], xtime
->wDay
);
2133 } else if (type
== 'M') {
2135 GetLocaleInfo32A(locale
,
2136 LOCALE_SABBREVMONTHNAME1
2137 + xtime
->wMonth
- 1,
2139 } else if (count
== 4) {
2140 GetLocaleInfo32A(locale
,
2142 + xtime
->wMonth
- 1,
2145 sprintf(buf
, dgfmt
[count
], xtime
->wMonth
);
2147 } else if (type
== 'y') {
2149 sprintf(buf
, "%d", xtime
->wYear
);
2150 } else if (count
== 3) {
2152 WARN(ole
, "unknown format, c=%c, n=%d\n", type
, count
);
2154 sprintf(buf
, dgfmt
[count
], xtime
->wYear
% 100);
2156 } else if (type
== 'g') {
2158 FIXME(ole
, "LOCALE_ICALENDARTYPE unimp.\n");
2162 WARN(ole
, "unknown format, c=%c, n=%d\n", type
, count
);
2164 } else if (type
== 'h') {
2165 /* gives us hours 1:00 -- 12:00 */
2166 sprintf(buf
, dgfmt
[count
], (xtime
->wHour
-1)%12 +1);
2167 } else if (type
== 'H') {
2169 sprintf(buf
, dgfmt
[count
], xtime
->wHour
);
2170 } else if ( type
== 'm') {
2171 sprintf(buf
, dgfmt
[count
], xtime
->wMinute
);
2172 } else if ( type
== 's') {
2173 sprintf(buf
, dgfmt
[count
], xtime
->wSecond
);
2174 } else if (type
== 't') {
2176 sprintf(buf
, "%c", (xtime
->wHour
< 12) ? 'A' : 'P');
2177 } else if (count
== 2) {
2178 /* sprintf(buf, "%s", (xtime->wHour < 12) ? "AM" : "PM"); */
2179 GetLocaleInfo32A(locale
,
2181 ? LOCALE_S1159
: LOCALE_S2359
,
2186 /* we need to check the next char in the format string
2187 again, no matter what happened */
2190 /* add the contents of buf to the output */
2191 buflen
= strlen(buf
);
2192 if (outpos
+ buflen
< datelen
) {
2193 date
[outpos
] = '\0'; /* for strcat to hook onto */
2197 date
[outpos
] = '\0';
2198 strncat(date
, buf
, datelen
- outpos
);
2199 date
[datelen
- 1] = '\0';
2200 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2201 WARN(ole
, "insufficient buffer\n");
2205 /* reset the variables we used to keep track of this item */
2208 } else if (format
[inpos
] == '\0') {
2209 /* we can't check for this at the loop-head, because
2210 that breaks the printing of the last format-item */
2211 date
[outpos
] = '\0';
2214 /* continuing a code for an item */
2217 } else if (strchr("hHmstyMdg", format
[inpos
])) {
2218 type
= format
[inpos
];
2221 } else if (format
[inpos
] == '\'') {
2225 date
[outpos
++] = format
[inpos
];
2227 /* now deal with a possible buffer overflow */
2228 if (outpos
>= datelen
) {
2229 date
[datelen
- 1] = '\0';
2230 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2236 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2239 /* finish it off with a string terminator */
2242 if (outpos
> datelen
-1) outpos
= datelen
-1;
2243 date
[outpos
] = '\0';
2245 TRACE(ole
, "OLE_GetFormatA returns string '%s', len %d\n",
2250 /**************************************************************
2251 * OLE_GetFormatW [internal]
2253 INT32 WINAPI
OLE_GetFormatW(LCID locale
, DWORD flags
, DWORD tflags
,
2256 LPWSTR output
, INT32 outlen
)
2258 INT32 inpos
, outpos
;
2259 int count
, type
=0, inquote
;
2260 int Overflow
; /* loop check */
2261 int usedate
, usetime
;
2265 WCHAR arg0
[] = {0}, arg1
[] = {'%','d',0};
2266 WCHAR arg2
[] = {'%','0','2','d',0};
2267 WCHAR
*argarr
[] = {arg0
, arg1
, arg2
};
2268 int datevars
=0, timevars
=0;
2270 /* make a debug report */
2271 lstrcpynWtoA(abuf
, format
, sizeof(format
));
2272 TRACE(ole
, "args: 0x%lx, 0x%lx, 0x%lx, time(d=%d,h=%d,m=%d,s=%d), fmt:\'%s\' (at %p), %p with max len %d\n",
2273 locale
, flags
, tflags
,
2274 xtime
->wDay
, xtime
->wHour
, xtime
->wMinute
, xtime
->wSecond
,
2275 abuf
, format
, output
, outlen
);
2278 /* initialize state variables */
2281 inquote
= Overflow
= 0;
2282 /* this is really just a sanity check */
2283 output
[0] = buf
[0] = 0;
2285 /* for compatibility with official Windows behavior */
2286 usedate
= flags
& DATE_DATEVARSONLY
;
2287 usetime
= flags
& TIME_TIMEVARSONLY
;
2289 /* this loop is the core of the function */
2290 for (inpos
= 0; /* we have several break points */ ; inpos
++) {
2292 if (format
[inpos
] == (WCHAR
) '\'') {
2293 if (format
[inpos
+1] == '\'') {
2295 output
[outpos
++] = '\'';
2300 } else if (format
[inpos
] == 0) {
2301 output
[outpos
++] = 0;
2302 if (outpos
> outlen
) Overflow
= 1;
2303 break; /* normal exit (within a quote) */
2305 output
[outpos
++] = format
[inpos
]; /* copy input */
2306 if (outpos
> outlen
) {
2308 output
[outpos
-1] = 0;
2312 } else if ( (count
&& (format
[inpos
] != type
))
2313 || ( (count
==4 && type
=='y') ||
2314 (count
==4 && type
=='M') ||
2315 (count
==4 && type
=='d') ||
2316 (count
==2 && type
=='g') ||
2317 (count
==2 && type
=='h') ||
2318 (count
==2 && type
=='H') ||
2319 (count
==2 && type
=='m') ||
2320 (count
==2 && type
=='s') ||
2321 (count
==2 && type
=='t') ) ) {
2324 GetLocaleInfo32W(locale
,
2325 LOCALE_SDAYNAME1
+ xtime
->wDayOfWeek
-1,
2326 buf
, sizeof(buf
)/sizeof(WCHAR
) );
2327 } else if (count
== 3) {
2328 GetLocaleInfo32W(locale
,
2329 LOCALE_SABBREVDAYNAME1
+
2330 xtime
->wDayOfWeek
-1,
2331 buf
, sizeof(buf
)/sizeof(WCHAR
) );
2333 wsnprintf32W(buf
, 5, argarr
[count
], xtime
->wDay
);
2335 } else if (type
== 'M') {
2337 GetLocaleInfo32W(locale
, LOCALE_SMONTHNAME1
+
2338 xtime
->wMonth
-1, buf
,
2339 sizeof(buf
)/sizeof(WCHAR
) );
2340 } else if (count
== 3) {
2341 GetLocaleInfo32W(locale
, LOCALE_SABBREVMONTHNAME1
+
2342 xtime
->wMonth
-1, buf
,
2343 sizeof(buf
)/sizeof(WCHAR
) );
2345 wsnprintf32W(buf
, 5, argarr
[count
], xtime
->wMonth
);
2347 } else if (type
== 'y') {
2349 wsnprintf32W(buf
, 6, argarr
[1] /* "%d" */,
2351 } else if (count
== 3) {
2352 lstrcpynAtoW(buf
, "yyy", 5);
2354 wsnprintf32W(buf
, 6, argarr
[count
],
2355 xtime
->wYear
% 100);
2357 } else if (type
== 'g') {
2359 FIXME(ole
, "LOCALE_ICALENDARTYPE unimplemented\n");
2360 lstrcpynAtoW(buf
, "AD", 5);
2362 /* Win API sez we copy it verbatim */
2363 lstrcpynAtoW(buf
, "g", 5);
2365 } else if (type
== 'h') {
2366 /* hours 1:00-12:00 --- is this right? */
2367 wsnprintf32W(buf
, 5, argarr
[count
],
2368 (xtime
->wHour
-1)%12 +1);
2369 } else if (type
== 'H') {
2370 wsnprintf32W(buf
, 5, argarr
[count
],
2372 } else if (type
== 'm' ) {
2373 wsnprintf32W(buf
, 5, argarr
[count
],
2375 } else if (type
== 's' ) {
2376 wsnprintf32W(buf
, 5, argarr
[count
],
2378 } else if (type
== 't') {
2379 GetLocaleInfo32W(locale
, (xtime
->wHour
< 12) ?
2380 LOCALE_S1159
: LOCALE_S2359
,
2387 /* no matter what happened, we need to check this next
2388 character the next time we loop through */
2391 /* cat buf onto the output */
2392 outlen
= lstrlen32W(buf
);
2393 if (outpos
+ buflen
< outlen
) {
2394 output
[outpos
] = 0; /* a "hook" for strcat */
2395 lstrcat32W(output
, buf
);
2399 lstrcatn32W(output
, buf
, outlen
- outpos
);
2400 output
[outlen
- 1] = 0;
2402 break; /* Abnormal exit */
2405 /* reset the variables we used this time */
2408 } else if (format
[inpos
] == 0) {
2409 /* we can't check for this at the beginning, because that
2410 would keep us from printing a format spec that ended the
2413 break; /* NORMAL EXIT */
2415 /* how we keep track of the middle of a format spec */
2418 } else if ( (datevars
&& (format
[inpos
]=='d' ||
2419 format
[inpos
]=='M' ||
2420 format
[inpos
]=='y' ||
2421 format
[inpos
]=='g') ) ||
2422 (timevars
&& (format
[inpos
]=='H' ||
2423 format
[inpos
]=='h' ||
2424 format
[inpos
]=='m' ||
2425 format
[inpos
]=='s' ||
2426 format
[inpos
]=='t') ) ) {
2427 type
= format
[inpos
];
2430 } else if (format
[inpos
] == '\'') {
2434 /* unquoted literals */
2435 output
[outpos
++] = format
[inpos
];
2440 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2441 WARN(ole
, " buffer overflow\n");
2444 /* final string terminator and sanity check */
2446 if (outpos
> outlen
-1) outpos
= outlen
-1;
2447 output
[outpos
] = '0';
2449 lstrcpynWtoA(abuf
, output
, sizeof(abuf
) );
2450 TRACE(ole
, " returning string \'%s\'\n", abuf
);
2452 return (!Overflow
) ? outlen
: 0;
2457 /*****************************************************************
2458 * GetDateFormat32A() [KERNEL32.310] Makes an ASCII string of the date
2460 * This function uses format to format the date, or, if format
2461 * is NULL, uses the default for the locale. format is a string
2462 * of literal fields and characters as follows:
2464 * - d single-digit (no leading zero) day (of month)
2465 * - dd two-digit day (of month)
2466 * - ddd short day-of-week name
2467 * - dddd long day-of-week name
2468 * - M single-digit month
2469 * - MM two-digit month
2470 * - MMM short month name
2471 * - MMMM full month name
2472 * - y two-digit year, no leading 0
2473 * - yy two-digit year
2474 * - yyyy four-digit year
2479 INT32 WINAPI
GetDateFormat32A(LCID locale
,DWORD flags
,
2481 LPCSTR format
, LPSTR date
,INT32 datelen
)
2484 char format_buf
[40];
2487 LPSYSTEMTIME thistime
;
2492 TRACE(ole
,"(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",
2493 locale
,flags
,xtime
,format
,date
,datelen
);
2496 locale
= LOCALE_SYSTEM_DEFAULT
;
2499 if (locale
== LOCALE_SYSTEM_DEFAULT
) {
2500 thislocale
= GetSystemDefaultLCID();
2501 } else if (locale
== LOCALE_USER_DEFAULT
) {
2502 thislocale
= GetUserDefaultLCID();
2504 thislocale
= locale
;
2507 if (xtime
== NULL
) {
2514 if (format
== NULL
) {
2515 GetLocaleInfo32A(thislocale
, ((flags
&DATE_LONGDATE
)
2517 : LOCALE_SSHORTDATE
),
2518 format_buf
, sizeof(format_buf
));
2519 thisformat
= format_buf
;
2521 thisformat
= format
;
2525 ret
= OLE_GetFormatA(thislocale
, flags
, 0, thistime
, thisformat
,
2530 "GetDateFormat32A() returning %d, with data=%s\n",
2535 /* ****************************************************************
2536 * GetDateFormat32W() [KERNEL32.311] Makes a Unicode string of the date
2538 * Acts the same as GetDateFormat32A(), except that it's Unicode.
2539 * Accepts & returns sizes as counts of Unicode characters.
2542 INT32 WINAPI
GetDateFormat32W(LCID locale
,DWORD flags
,
2545 LPWSTR date
, INT32 datelen
)
2547 short datearr
[] = {'1','9','9','4','-','1','-','1',0};
2549 FIXME(ole
, "STUB (should call OLE_GetFormatW)\n");
2550 lstrcpyn32W(date
, datearr
, datelen
);
2551 return ( datelen
< 9) ? datelen
: 9;
2557 /**************************************************************************
2558 * GetNumberFormat32A (KERNEL32.355)
2559 * NOTE: type of lpFormat should be CONST NUMBERFORMAT
2561 INT32 WINAPI
GetNumberFormat32A(LCID locale
, DWORD dwflags
,
2562 LPCSTR lpvalue
, char *lpFormat
,
2563 LPSTR lpNumberStr
, int cchNumber
)
2567 FIXME(file
,"%s: stub, no reformating done\n",lpvalue
);
2569 n
= strlen(lpvalue
);
2571 strncpy(lpNumberStr
,lpvalue
,cchNumber
);
2572 if (cchNumber
<= n
) {
2573 lpNumberStr
[cchNumber
-1] = 0;
2582 /*****************************************************************
2584 * GetTimeFormat32A() [KERNEL32.422] Makes an ASCII string of the time
2586 * Formats date according to format, or locale default if format is
2587 * NULL. The format consists of literal characters and fields as follows:
2589 * h hours with no leading zero (12-hour)
2590 * hh hours with full two digits
2591 * H hours with no leading zero (24-hour)
2592 * HH hours with full two digits
2593 * m minutes with no leading zero
2594 * mm minutes with full two digits
2595 * s seconds with no leading zero
2596 * ss seconds with full two digits
2597 * t time marker (A or P)
2598 * tt time marker (AM, PM)
2603 GetTimeFormat32A(LCID locale
, /* in */
2604 DWORD flags
, /* in */
2605 LPSYSTEMTIME xtime
, /* in */
2606 LPCSTR format
, /* in */
2607 LPSTR timestr
, /* out */
2608 INT32 timelen
/* in */)
2609 { char format_buf
[40];
2612 LPSYSTEMTIME thistime
;
2614 DWORD thisflags
=LOCALE_STIMEFORMAT
; /* standart timeformat */;
2616 TRACE(ole
,"GetTimeFormat(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",locale
,flags
,xtime
,format
,timestr
,timelen
);
2619 { locale
= LOCALE_SYSTEM_DEFAULT
;
2622 if (locale
== LOCALE_SYSTEM_DEFAULT
)
2623 { thislocale
= GetSystemDefaultLCID();
2625 else if (locale
== LOCALE_USER_DEFAULT
)
2626 { thislocale
= GetUserDefaultLCID();
2629 { thislocale
= locale
;
2632 if ( flags
& (TIME_NOTIMEMARKER
| TIME_FORCE24HOURFORMAT
))
2633 { FIXME(ole
,"TIME_NOTIMEMARKER or TIME_FORCE24HOURFORMAT not implemented\n");
2635 flags
&= (TIME_NOSECONDS
| TIME_NOMINUTESORSECONDS
); /* mask for OLE_GetFormatA*/
2638 { if (flags
& LOCALE_NOUSEROVERRIDE
) /*use system default*/
2639 { thislocale
= GetSystemDefaultLCID();
2641 GetLocaleInfo32A(thislocale
, thisflags
, format_buf
, sizeof(format_buf
));
2642 thisformat
= format_buf
;
2645 { thisformat
= format
;
2648 if (xtime
== NULL
) /* NULL means use the current local time*/
2649 { GetSystemTime(&t
);
2655 return OLE_GetFormatA(thislocale
, thisflags
, flags
, thistime
, thisformat
, timestr
, timelen
);
2659 /* ****************************************************************
2660 * GetTimeFormat32W() [KERNEL32.423] Makes a Unicode string of the time
2666 GetTimeFormat32W(LCID locale
,DWORD flags
,
2669 LPWSTR timestr
,INT32 timelen
)
2673 LPCWSTR realformat
=0;
2675 LPSYSTEMTIME realtime
;
2676 WCHAR
* fmt_buf
= NULL
;
2677 int fmt_buf_size
= 0; /* units of WCHARs */
2680 lstrcpynWtoA(debugbuf
, format
, (sizeof(buf
))/2);
2681 TRACE(ole
, "GetTimeFormatW len %d flags 0x%lX format >%s<\n",
2682 timelen
, flags
, debugbuf
);
2684 /* Enforce the Windows behavior */
2685 flags
|= ~LOCALE_TIMEDATEBOTH
;
2686 flags
|= TIME_TIMEVARSONLY
;
2688 /* take care of the format or locale not being given */
2690 realformat
= format
;
2691 } else if (locale
) {
2692 /* allocate memory */
2693 retval
= ERROR_INSUFFICIENT_BUFFER
;
2694 fmt_buf
= malloc((fmt_buf_size
+=7) * sizeof(WCHAR
));
2698 while(!GetLocaleInfo32W(locale
, LOCALE_STIMEFORMAT
,
2699 fmt_buf
, fmt_buf_size
)) {
2700 retval
= ERROR_OUTOFMEMORY
;
2701 fmt_buf
= realloc(fmt_buf
,
2702 (fmt_buf_size
+= 10) * sizeof(WCHAR
));
2706 realformat
= fmt_buf
;
2708 FIXME(ole
, "caller gave no locale, no format; what should we do?\n");
2709 SetLastError(ERROR_BAD_FORMAT
);
2712 locale
= GetSystemDefaultLCID();
2717 GetSystemTime(realtime
);
2720 retval
= OLE_GetFormatW(locale
, flags
, 0, realtime
, realformat
, timestr
, timelen
);
2726 SetLastError(retval
);
2727 WARN(ole
, "could not allocate %d chars of memory\n", fmt_buf_size
);