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 (WORD
)GetUserDefaultLCID();
242 /***********************************************************************
243 * GetSystemDefaultLangID (OLE2NLS.4)
245 LANGID WINAPI
GetSystemDefaultLangID()
247 return 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
,"(%8lX,%8lX,%p,%4X)\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 int is_punctuation(unsigned char c
)
1227 /* punctuation characters are :
1228 1-8, 14-31, 39, 45, 127-129, 141-144, 150-151, 157-158, 173
1230 "punctuation character" in this context is a character which is
1231 considered "less important" during word sort comparison.
1232 See LCMapString for the precise definition of "less important". */
1236 return (c
<=144) || (c
>=150);
1244 return (c
<=31) || (c
==39) || (c
==45);
1248 static int identity(int c
)
1253 static const unsigned char LCM_Unicode_LUT
[] = {
1286 7 , 28, /* ! - 33 */
1287 7 , 29, /* " - 34 */ /* " */
1288 7 , 31, /* # - 35 */
1289 7 , 33, /* $ - 36 */
1290 7 , 35, /* % - 37 */
1291 7 , 37, /* & - 38 */
1292 6 , 128, /* ' - 39 */
1293 7 , 39, /* ( - 40 */
1294 7 , 42, /* ) - 41 */
1295 7 , 45, /* * - 42 */
1297 7 , 47, /* , - 44 */
1298 6 , 130, /* - - 45 */
1299 7 , 51, /* . - 46 */
1300 7 , 53, /* / - 47 */
1301 12 , 3, /* 0 - 48 */
1302 12 , 33, /* 1 - 49 */
1303 12 , 51, /* 2 - 50 */
1304 12 , 70, /* 3 - 51 */
1305 12 , 88, /* 4 - 52 */
1306 12 , 106, /* 5 - 53 */
1307 12 , 125, /* 6 - 54 */
1308 12 , 144, /* 7 - 55 */
1309 12 , 162, /* 8 - 56 */
1310 12 , 180, /* 9 - 57 */
1311 7 , 55, /* : - 58 */
1312 7 , 58, /* ; - 59 */
1313 8 , 14, /* < - 60 */
1314 8 , 18, /* = - 61 */
1315 8 , 20, /* > - 62 */
1316 7 , 60, /* ? - 63 */
1317 7 , 62, /* @ - 64 */
1318 14 , 2, /* A - 65 */
1319 14 , 9, /* B - 66 */
1320 14 , 10, /* C - 67 */
1321 14 , 26, /* D - 68 */
1322 14 , 33, /* E - 69 */
1323 14 , 35, /* F - 70 */
1324 14 , 37, /* G - 71 */
1325 14 , 44, /* H - 72 */
1326 14 , 50, /* I - 73 */
1327 14 , 53, /* J - 74 */
1328 14 , 54, /* K - 75 */
1329 14 , 72, /* L - 76 */
1330 14 , 81, /* M - 77 */
1331 14 , 112, /* N - 78 */
1332 14 , 124, /* O - 79 */
1333 14 , 126, /* P - 80 */
1334 14 , 137, /* Q - 81 */
1335 14 , 138, /* R - 82 */
1336 14 , 145, /* S - 83 */
1337 14 , 153, /* T - 84 */
1338 14 , 159, /* U - 85 */
1339 14 , 162, /* V - 86 */
1340 14 , 164, /* W - 87 */
1341 14 , 166, /* X - 88 */
1342 14 , 167, /* Y - 89 */
1343 14 , 169, /* Z - 90 */
1344 7 , 63, /* [ - 91 */
1345 7 , 65, /* \ - 92 */
1346 7 , 66, /* ] - 93 */
1347 7 , 67, /* ^ - 94 */
1348 7 , 68, /* _ - 95 */
1349 7 , 72, /* ` - 96 */
1350 14 , 2, /* a - 97 */
1351 14 , 9, /* b - 98 */
1352 14 , 10, /* c - 99 */
1353 14 , 26, /* d - 100 */
1354 14 , 33, /* e - 101 */
1355 14 , 35, /* f - 102 */
1356 14 , 37, /* g - 103 */
1357 14 , 44, /* h - 104 */
1358 14 , 50, /* i - 105 */
1359 14 , 53, /* j - 106 */
1360 14 , 54, /* k - 107 */
1361 14 , 72, /* l - 108 */
1362 14 , 81, /* m - 109 */
1363 14 , 112, /* n - 110 */
1364 14 , 124, /* o - 111 */
1365 14 , 126, /* p - 112 */
1366 14 , 137, /* q - 113 */
1367 14 , 138, /* r - 114 */
1368 14 , 145, /* s - 115 */
1369 14 , 153, /* t - 116 */
1370 14 , 159, /* u - 117 */
1371 14 , 162, /* v - 118 */
1372 14 , 164, /* w - 119 */
1373 14 , 166, /* x - 120 */
1374 14 , 167, /* y - 121 */
1375 14 , 169, /* z - 122 */
1376 7 , 74, /* { - 123 */
1377 7 , 76, /* | - 124 */
1378 7 , 78, /* } - 125 */
1379 7 , 80, /* ~ - 126 */
1380 6 , 29, /* \x7f - 127 */
1381 6 , 30, /* € - 128 */
1382 6 , 31, /* � - 129 */
1383 7 , 123, /* ‚ - 130 */
1384 14 , 35, /* ƒ - 131 */
1385 7 , 127, /* „ - 132 */
1386 10 , 21, /* … - 133 */
1387 10 , 15, /* † - 134 */
1388 10 , 16, /* ‡ - 135 */
1389 7 , 67, /* ˆ - 136 */
1390 10 , 22, /* ‰ - 137 */
1391 14 , 145, /* Š - 138 */
1392 7 , 136, /* ‹ - 139 */
1393 14 + 16 , 124, /* Œ - 140 */
1394 6 , 43, /* � - 141 */
1395 6 , 44, /* Ž - 142 */
1396 6 , 45, /* � - 143 */
1397 6 , 46, /* � - 144 */
1398 7 , 121, /* ‘ - 145 */
1399 7 , 122, /* ’ - 146 */
1400 7 , 125, /* “ - 147 */
1401 7 , 126, /* ” - 148 */
1402 10 , 17, /* • - 149 */
1403 6 , 137, /* – - 150 */
1404 6 , 139, /* — - 151 */
1405 7 , 93, /* ˜ - 152 */
1406 14 , 156, /* ™ - 153 */
1407 14 , 145, /* š - 154 */
1408 7 , 137, /* › - 155 */
1409 14 + 16 , 124, /* œ - 156 */
1410 6 , 59, /* � - 157 */
1411 6 , 60, /* ž - 158 */
1412 14 , 167, /* Ÿ - 159 */
1414 7 , 81, /* ¡ - 161 */
1415 10 , 2, /* ¢ - 162 */
1416 10 , 3, /* £ - 163 */
1417 10 , 4, /* ¤ - 164 */
1418 10 , 5, /* ¥ - 165 */
1419 7 , 82, /* ¦ - 166 */
1420 10 , 6, /* § - 167 */
1421 7 , 83, /* ¨ - 168 */
1422 10 , 7, /* © - 169 */
1423 14 , 2, /* ª - 170 */
1424 8 , 24, /* « - 171 */
1425 10 , 8, /* ¬ - 172 */
1426 6 , 131, /* - 173 */
1427 10 , 9, /* ® - 174 */
1428 7 , 84, /* ¯ - 175 */
1429 10 , 10, /* ° - 176 */
1430 8 , 23, /* ± - 177 */
1431 12 , 51, /* ² - 178 */
1432 12 , 70, /* ³ - 179 */
1433 7 , 85, /* ´ - 180 */
1434 10 , 11, /* µ - 181 */
1435 10 , 12, /* ¶ - 182 */
1436 10 , 13, /* · - 183 */
1437 7 , 86, /* ¸ - 184 */
1438 12 , 33, /* ¹ - 185 */
1439 14 , 124, /* º - 186 */
1440 8 , 26, /* » - 187 */
1441 12 , 21, /* ¼ - 188 */
1442 12 , 25, /* ½ - 189 */
1443 12 , 29, /* ¾ - 190 */
1444 7 , 87, /* ¿ - 191 */
1445 14 , 2, /* À - 192 */
1446 14 , 2, /* Á - 193 */
1447 14 , 2, /* Â - 194 */
1448 14 , 2, /* Ã - 195 */
1449 14 , 2, /* Ä - 196 */
1450 14 , 2, /* Å - 197 */
1451 14 + 16 , 2, /* Æ - 198 */
1452 14 , 10, /* Ç - 199 */
1453 14 , 33, /* È - 200 */
1454 14 , 33, /* É - 201 */
1455 14 , 33, /* Ê - 202 */
1456 14 , 33, /* Ë - 203 */
1457 14 , 50, /* Ì - 204 */
1458 14 , 50, /* Í - 205 */
1459 14 , 50, /* Î - 206 */
1460 14 , 50, /* Ï - 207 */
1461 14 , 26, /* Ð - 208 */
1462 14 , 112, /* Ñ - 209 */
1463 14 , 124, /* Ò - 210 */
1464 14 , 124, /* Ó - 211 */
1465 14 , 124, /* Ô - 212 */
1466 14 , 124, /* Õ - 213 */
1467 14 , 124, /* Ö - 214 */
1468 8 , 28, /* × - 215 */
1469 14 , 124, /* Ø - 216 */
1470 14 , 159, /* Ù - 217 */
1471 14 , 159, /* Ú - 218 */
1472 14 , 159, /* Û - 219 */
1473 14 , 159, /* Ü - 220 */
1474 14 , 167, /* Ý - 221 */
1475 14 + 32 , 153, /* Þ - 222 */
1476 14 + 48 , 145, /* ß - 223 */
1477 14 , 2, /* à - 224 */
1478 14 , 2, /* á - 225 */
1479 14 , 2, /* â - 226 */
1480 14 , 2, /* ã - 227 */
1481 14 , 2, /* ä - 228 */
1482 14 , 2, /* å - 229 */
1483 14 + 16 , 2, /* æ - 230 */
1484 14 , 10, /* ç - 231 */
1485 14 , 33, /* è - 232 */
1486 14 , 33, /* é - 233 */
1487 14 , 33, /* ê - 234 */
1488 14 , 33, /* ë - 235 */
1489 14 , 50, /* ì - 236 */
1490 14 , 50, /* í - 237 */
1491 14 , 50, /* î - 238 */
1492 14 , 50, /* ï - 239 */
1493 14 , 26, /* ð - 240 */
1494 14 , 112, /* ñ - 241 */
1495 14 , 124, /* ò - 242 */
1496 14 , 124, /* ó - 243 */
1497 14 , 124, /* ô - 244 */
1498 14 , 124, /* õ - 245 */
1499 14 , 124, /* ö - 246 */
1500 8 , 29, /* ÷ - 247 */
1501 14 , 124, /* ø - 248 */
1502 14 , 159, /* ù - 249 */
1503 14 , 159, /* ú - 250 */
1504 14 , 159, /* û - 251 */
1505 14 , 159, /* ü - 252 */
1506 14 , 167, /* ý - 253 */
1507 14 + 32 , 153, /* þ - 254 */
1508 14 , 167 /* ÿ - 255 */ };
1510 static const unsigned char LCM_Unicode_LUT_2
[] = { 33, 44, 145 };
1512 #define LCM_Diacritic_Start 131
1514 static const unsigned char LCM_Diacritic_LUT
[] = {
1642 /*************************************************************************
1643 * Convert a string, or generate a sort key from it.
1645 * If (mapflags & LCMAP_SORTKEY), the function will generate
1646 * a sort key for the source string. Else, it will convert it
1647 * accordingly to the flags LCMAP_UPPERCASE, LCMAP_LOWERCASE,...
1651 * Success : length of the result string.
1654 * If called with scrlen = -1, the function will compute the length
1655 * of the 0-terminated string strsrc by itself.
1657 * If called with dstlen = 0, returns the buffer length that
1658 * would be required.
1660 INT32 WINAPI
LCMapString32A(
1661 LCID lcid
/* locale identifier created with MAKELCID;
1662 LOCALE_SYSTEM_DEFAULT and LOCALE_USER_DEFAULT are predefined
1664 DWORD mapflags
/* flags */,
1665 LPCSTR srcstr
/* source buffer */,
1666 INT32 srclen
/* source length */,
1667 LPSTR dststr
/* destination buffer */,
1668 INT32 dstlen
/* destination buffer length */)
1672 TRACE(string
,"(0x%04lx,0x%08lx,%s,%d,%p,%d)\n",
1673 lcid
,mapflags
,srcstr
,srclen
,dststr
,dstlen
);
1675 if ( ((dstlen
!=0) && (dststr
==NULL
)) || (srcstr
==NULL
) )
1677 SetLastError(ERROR_INVALID_PARAMETER
);
1681 srclen
= lstrlen32A(srcstr
) + 1 ; /* (include final '\0') */
1683 if (mapflags
& ~ ( LCMAP_UPPERCASE
| LCMAP_LOWERCASE
| LCMAP_SORTKEY
|
1684 NORM_IGNORECASE
| NORM_IGNORENONSPACE
| SORT_STRINGSORT
) )
1686 FIXME(string
,"(0x%04lx,0x%08lx,%p,%d,%p,%d): "
1687 "unimplemented flags: 0x%08lx\n",
1688 lcid
,mapflags
,srcstr
,srclen
,dststr
,dstlen
,mapflags
);
1691 if ( !(mapflags
& LCMAP_SORTKEY
) )
1693 int (*f
)(int)=identity
;
1696 return srclen
; /* dstlen=0 means "do nothing but return required length" */
1698 srclen
=dstlen
; /* No, this case is not an error under Windows 95.
1699 And no '\0' gets written. */
1700 if (mapflags
& LCMAP_UPPERCASE
)
1702 else if (mapflags
& LCMAP_LOWERCASE
)
1704 for (i
=0; i
< srclen
; i
++)
1705 dststr
[i
] = (CHAR
) f(srcstr
[i
]);
1709 /* else ... (mapflags & LCMAP_SORTKEY) */
1713 int diacritic_len
=0;
1714 int delayed_punctuation_len
=0;
1715 char *case_component
;
1716 char *diacritic_component
;
1717 char *delayed_punctuation_component
;
1719 int flag_stringsort
= mapflags
& SORT_STRINGSORT
;
1721 /* compute how much room we will need */
1722 for (i
=0;i
<srclen
;i
++)
1725 unsigned char source_char
= srcstr
[i
];
1726 if (source_char
!='\0')
1728 if (flag_stringsort
|| !is_punctuation(source_char
))
1731 if ( LCM_Unicode_LUT
[-2+2*source_char
] & ~15 )
1732 unicode_len
++; /* double letter */
1736 delayed_punctuation_len
++;
1740 if (isupper(source_char
))
1741 case_len
=unicode_len
;
1743 ofs
= source_char
- LCM_Diacritic_Start
;
1744 if ((ofs
>=0) && (LCM_Diacritic_LUT
[ofs
]!=2))
1745 diacritic_len
=unicode_len
;
1748 if (mapflags
& NORM_IGNORECASE
)
1750 if (mapflags
& NORM_IGNORENONSPACE
)
1753 room
= 2 * unicode_len
/* "unicode" component */
1754 + diacritic_len
/* "diacritic" component */
1755 + case_len
/* "case" component */
1756 + 4 * delayed_punctuation_len
/* punctuation in word sort mode */
1757 + 4 /* four '\1' separators */
1758 + 1 ; /* terminal '\0' */
1761 else if (dstlen
<room
)
1763 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1767 /*FIXME the Pointercheck should not be nessesary */
1768 if (IsBadWritePtr32 (dststr
,room
))
1769 { ERR (string
,"bad destination buffer (dststr) : %p,%d\n",dststr
,dstlen
);
1770 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1774 /* locate each component, write separators */
1775 diacritic_component
= dststr
+ 2*unicode_len
;
1776 *diacritic_component
++ = '\1';
1777 case_component
= diacritic_component
+ diacritic_len
;
1778 *case_component
++ = '\1';
1779 delayed_punctuation_component
= case_component
+ case_len
;
1780 *delayed_punctuation_component
++ = '\1';
1781 *delayed_punctuation_component
++ = '\1';
1783 /* read source string char by char, write
1784 corresponding weight in each component. */
1785 for (i
=0,count
=0;i
<srclen
;i
++)
1787 unsigned char source_char
=srcstr
[i
];
1788 if (source_char
!='\0')
1791 type
= LCM_Unicode_LUT
[-2+2*source_char
];
1792 longcode
= type
>> 4;
1794 if (!flag_stringsort
&& is_punctuation(source_char
))
1796 UINT16 encrypted_location
= (1<<15) + 7 + 4*count
;
1797 *delayed_punctuation_component
++ = (unsigned char) (encrypted_location
>>8);
1798 *delayed_punctuation_component
++ = (unsigned char) (encrypted_location
&255);
1799 /* big-endian is used here because it lets string comparison be
1800 compatible with numerical comparison */
1802 *delayed_punctuation_component
++ = type
;
1803 *delayed_punctuation_component
++ = LCM_Unicode_LUT
[-1+2*source_char
];
1804 /* assumption : a punctuation character is never a
1805 double or accented letter */
1809 dststr
[2*count
] = type
;
1810 dststr
[2*count
+1] = LCM_Unicode_LUT
[-1+2*source_char
];
1814 case_component
[count
] = ( isupper(source_char
) ? 18 : 2 ) ;
1815 if (count
<diacritic_len
)
1816 diacritic_component
[count
] = 2; /* assumption: a double letter
1817 is never accented */
1820 dststr
[2*count
] = type
;
1821 dststr
[2*count
+1] = *(LCM_Unicode_LUT_2
- 1 + longcode
);
1822 /* 16 in the first column of LCM_Unicode_LUT --> longcode = 1
1823 32 in the first column of LCM_Unicode_LUT --> longcode = 2
1824 48 in the first column of LCM_Unicode_LUT --> longcode = 3 */
1828 case_component
[count
] = ( isupper(source_char
) ? 18 : 2 ) ;
1829 if (count
<diacritic_len
)
1831 int ofs
= source_char
- LCM_Diacritic_Start
;
1832 diacritic_component
[count
] = (ofs
>=0 ? LCM_Diacritic_LUT
[ofs
] : 2);
1838 dststr
[room
-1] = '\0';
1843 INT32 WINAPI
LCMapString32W(
1844 LCID lcid
,DWORD mapflags
,LPCWSTR srcstr
,INT32 srclen
,LPWSTR dststr
,
1849 TRACE(string
,"(0x%04lx,0x%08lx,%p,%d,%p,%d)\n",
1850 lcid
,mapflags
,srcstr
,srclen
,dststr
,dstlen
);
1852 if ( ((dstlen
!=0) && (dststr
==NULL
)) || (srcstr
==NULL
) )
1854 SetLastError(ERROR_INVALID_PARAMETER
);
1858 srclen
= lstrlen32W(srcstr
)+1;
1859 if (mapflags
& LCMAP_SORTKEY
)
1861 FIXME(string
,"(0x%04lx,0x%08lx,%p,%d,%p,%d): "
1862 "unimplemented flags: 0x%08lx\n",
1863 lcid
,mapflags
,srcstr
,srclen
,dststr
,dstlen
,mapflags
);
1868 int (*f
)(int)=identity
;
1874 if (mapflags
& LCMAP_UPPERCASE
)
1876 else if (mapflags
& LCMAP_LOWERCASE
)
1878 for (i
=0; i
< srclen
; i
++)
1879 dststr
[i
] = (WCHAR
) f(srcstr
[i
]);
1884 /***********************************************************************
1885 * CompareString16 (OLE2NLS.8)
1887 UINT16 WINAPI
CompareString16(DWORD lcid
,DWORD fdwStyle
,
1888 LPCSTR s1
,DWORD l1
,LPCSTR s2
,DWORD l2
)
1890 return (UINT16
)CompareString32A(lcid
,fdwStyle
,s1
,l1
,s2
,l2
);
1893 /***********************************************************************
1894 * CompareString32A (KERNEL32.29)
1895 * This implementation ignores the locale
1897 * Moreover it is quite inefficient. FIXME too!
1899 UINT32 WINAPI
CompareString32A(DWORD lcid
, DWORD fdwStyle
,
1900 LPCSTR s1
, DWORD l1
, LPCSTR s2
,DWORD l2
)
1902 int mapstring_flags
;
1906 TRACE(ole
,"%s and %s\n",
1907 debugstr_a (s1
), debugstr_a (s2
));
1909 if ( (s1
==NULL
) || (s2
==NULL
) )
1911 SetLastError(ERROR_INVALID_PARAMETER
);
1915 if(fdwStyle
& NORM_IGNORESYMBOLS
)
1916 FIXME(ole
, "IGNORESYMBOLS not supported\n");
1918 mapstring_flags
= LCMAP_SORTKEY
| fdwStyle
;
1919 len1
= LCMapString32A(lcid
,mapstring_flags
,s1
,l1
,NULL
,0);
1920 len2
= LCMapString32A(lcid
,mapstring_flags
,s2
,l2
,NULL
,0);
1922 if ((len1
==0)||(len2
==0))
1923 return 0; /* something wrong happened */
1925 sk1
= (LPSTR
)HeapAlloc(GetProcessHeap(),0,len1
);
1926 sk2
= (LPSTR
)HeapAlloc(GetProcessHeap(),0,len2
);
1927 if ( (!LCMapString32A(lcid
,mapstring_flags
,s1
,l1
,sk1
,len1
))
1928 || (!LCMapString32A(lcid
,mapstring_flags
,s2
,l2
,sk2
,len2
)) )
1929 { ERR(ole
,"Bug in LCmapString32A.\n");
1933 { result
= strcmp(sk1
,sk2
)+2;
1935 HeapFree(GetProcessHeap(),0,sk1
);
1936 HeapFree(GetProcessHeap(),0,sk2
);
1940 /***********************************************************************
1941 * CompareString32W (KERNEL32.30)
1942 * This implementation ignores the locale
1943 * FIXME : Does only string sort. Should
1944 * be reimplemented the same way as CompareString32A.
1946 UINT32 WINAPI
CompareString32W(DWORD lcid
, DWORD fdwStyle
,
1947 LPCWSTR s1
, DWORD l1
, LPCWSTR s2
,DWORD l2
)
1950 if(fdwStyle
& NORM_IGNORENONSPACE
)
1951 FIXME(ole
,"IGNORENONSPACE not supprted\n");
1952 if(fdwStyle
& NORM_IGNORESYMBOLS
)
1953 FIXME(ole
,"IGNORESYMBOLS not supported\n");
1955 /* Is strcmp defaulting to string sort or to word sort?? */
1956 /* FIXME: Handle NORM_STRINGSORT */
1957 l1
= (l1
==-1)?lstrlen32W(s1
):l1
;
1958 l2
= (l2
==-1)?lstrlen32W(s2
):l2
;
1959 len
= l1
<l2
? l1
:l2
;
1960 ret
= (fdwStyle
& NORM_IGNORECASE
) ?
1961 lstrncmpi32W(s1
,s2
,len
) : lstrncmp32W(s1
,s2
,len
);
1962 /* not equal, return 1 or 3 */
1963 if(ret
!=0) return ret
+2;
1964 /* same len, return 2 */
1965 if(l1
==l2
) return 2;
1966 /* the longer one is lexically greater */
1967 return (l1
<l2
)? 1 : 3;
1970 /*****************************************************************
1972 * OLE_GetFormatA() [internal]
1975 This function implements stuff for GetDateFormat() and
1978 d single-digit (no leading zero) day (of month)
1979 dd two-digit day (of month)
1980 ddd short day-of-week name
1981 dddd long day-of-week name
1982 M single-digit month
1984 MMM short month name
1985 MMMM full month name
1986 y two-digit year, no leading 0
1988 yyyy four-digit year
1990 h hours with no leading zero (12-hour)
1991 hh hours with full two digits
1992 H hours with no leading zero (24-hour)
1993 HH hours with full two digits
1994 m minutes with no leading zero
1995 mm minutes with full two digits
1996 s seconds with no leading zero
1997 ss seconds with full two digits
1998 t time marker (A or P)
1999 tt time marker (AM, PM)
2000 '' used to quote literal characters
2001 '' (within a quoted string) indicates a literal '
2003 These functions REQUIRE valid locale, date, and format.
2007 INT32 WINAPI
OLE_GetFormatA(LCID locale
,
2011 LPSTR date
, INT32 datelen
)
2013 INT32 inpos
, outpos
;
2014 int count
, type
, inquote
, Overflow
;
2018 const char * _dgfmt
[] = { "%d", "%02d" };
2019 const char ** dgfmt
= _dgfmt
- 1;
2021 /* report, for debugging */
2022 TRACE(ole
, "func(%8lx,%8lx, time(d=%d,h=%d,m=%d,s=%d), fmt:\'%s\' (at %p), %p (%9s), len=%d)\n", locale
, flags
,
2023 xtime
->wDay
, xtime
->wHour
, xtime
->wMinute
, xtime
->wSecond
,
2024 format
, format
, date
, date
, datelen
);
2026 /* initalize state variables and output buffer */
2028 count
= 0; inquote
= 0; Overflow
= 0;
2030 date
[0] = buf
[0] = '\0';
2032 for (inpos
= 0;; inpos
++) {
2033 /* 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]); */
2035 if (format
[inpos
] == '\'') {
2036 if (format
[inpos
+1] == '\'') {
2038 date
[outpos
++] = '\'';
2041 continue; /* we did nothing to the output */
2043 } else if (format
[inpos
] == '\0') {
2044 date
[outpos
++] = '\0';
2045 if (outpos
> datelen
) Overflow
= 1;
2048 date
[outpos
++] = format
[inpos
];
2049 if (outpos
> datelen
) {
2051 date
[outpos
-1] = '\0'; /* this is the last place where
2052 it's safe to write */
2056 } else if ( (count
&& (format
[inpos
] != type
))
2058 || (count
== 2 && strchr("ghHmst", type
)) )
2062 GetLocaleInfo32A(locale
,
2064 + xtime
->wDayOfWeek
- 1,
2066 } else if (count
== 3) {
2067 GetLocaleInfo32A(locale
,
2068 LOCALE_SABBREVDAYNAME1
2069 + xtime
->wDayOfWeek
- 1,
2072 sprintf(buf
, dgfmt
[count
], xtime
->wDay
);
2074 } else if (type
== 'M') {
2076 GetLocaleInfo32A(locale
,
2077 LOCALE_SABBREVMONTHNAME1
2078 + xtime
->wMonth
- 1,
2080 } else if (count
== 4) {
2081 GetLocaleInfo32A(locale
,
2083 + xtime
->wMonth
- 1,
2086 sprintf(buf
, dgfmt
[count
], xtime
->wMonth
);
2088 } else if (type
== 'y') {
2090 sprintf(buf
, "%d", xtime
->wYear
);
2091 } else if (count
== 3) {
2095 c=%c, n=%d\n", type
, count
);
2097 sprintf(buf
, dgfmt
[count
], xtime
->wYear
% 100);
2099 } else if (type
== 'g') {
2101 FIXME(ole
, "LOCALE_ICALENDARTYPE unimp.\n");
2107 c=%c, n=%d\n", type
, count
);
2109 } else if (type
== 'h') {
2110 /* gives us hours 1:00 -- 12:00 */
2111 sprintf(buf
, dgfmt
[count
], (xtime
->wHour
-1)%12 +1);
2112 } else if (type
== 'H') {
2114 sprintf(buf
, dgfmt
[count
], xtime
->wHour
);
2115 } else if (type
== 'm') {
2116 sprintf(buf
, dgfmt
[count
], xtime
->wMinute
);
2117 } else if (type
== 's') {
2118 sprintf(buf
, dgfmt
[count
], xtime
->wSecond
);
2119 } else if (type
== 't') {
2121 sprintf(buf
, "%c", (xtime
->wHour
< 12) ? 'A' : 'P');
2122 } else if (count
== 2) {
2123 /* sprintf(buf, "%s", (xtime->wHour < 12) ? "AM" : "PM"); */
2124 GetLocaleInfo32A(locale
,
2126 ? LOCALE_S1159
: LOCALE_S2359
,
2131 /* we need to check the next char in the format string
2132 again, no matter what happened */
2135 /* add the contents of buf to the output */
2136 buflen
= strlen(buf
);
2137 if (outpos
+ buflen
< datelen
) {
2138 date
[outpos
] = '\0'; /* for strcat to hook onto */
2142 date
[outpos
] = '\0';
2143 strncat(date
, buf
, datelen
- outpos
);
2144 date
[datelen
- 1] = '\0';
2145 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2146 WARN(ole
, "insufficient buffer\n");
2150 /* reset the variables we used to keep track of this item */
2153 } else if (format
[inpos
] == '\0') {
2154 /* we can't check for this at the loop-head, because
2155 that breaks the printing of the last format-item */
2156 date
[outpos
] = '\0';
2159 /* continuing a code for an item */
2162 } else if (strchr("hHmstyMdg", format
[inpos
])) {
2163 type
= format
[inpos
];
2166 } else if (format
[inpos
] == '\'') {
2170 date
[outpos
++] = format
[inpos
];
2172 /* now deal with a possible buffer overflow */
2173 if (outpos
>= datelen
) {
2174 date
[datelen
- 1] = '\0';
2175 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2181 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2184 /* finish it off with a string terminator */
2187 if (outpos
> datelen
-1) outpos
= datelen
-1;
2188 date
[outpos
] = '\0';
2190 TRACE(ole
, "OLE_GetFormatA returns string '%s', len %d\n",
2195 /**************************************************************
2196 * OLE_GetFormatW [internal]
2198 INT32 WINAPI
OLE_GetFormatW(LCID locale
, DWORD flags
,
2201 LPWSTR output
, INT32 outlen
)
2203 INT32 inpos
, outpos
;
2204 int count
, type
=0, inquote
;
2205 int Overflow
; /* loop check */
2206 int usedate
, usetime
;
2210 WCHAR arg0
[] = {0}, arg1
[] = {'%','d',0};
2211 WCHAR arg2
[] = {'%','0','2','d',0};
2212 WCHAR
*argarr
[] = {arg0
, arg1
, arg2
};
2213 int datevars
=0, timevars
=0;
2215 /* make a debug report */
2216 lstrcpynWtoA(abuf
, format
, sizeof(format
));
2217 TRACE(ole
, "args: %8lx, %8lx, time(d=%d,h=%d,m=%d,s=%d), fmt:\'%s\' (at %p), %p with max len %d\n",
2219 xtime
->wDay
, xtime
->wHour
, xtime
->wMinute
, xtime
->wSecond
,
2220 abuf
, format
, output
, outlen
);
2223 /* initialize state variables */
2226 inquote
= Overflow
= 0;
2227 /* this is really just a sanity check */
2228 output
[0] = buf
[0] = 0;
2230 /* for compatibility with official Windows behavior */
2231 usedate
= flags
& DATE_DATEVARSONLY
;
2232 usetime
= flags
& TIME_TIMEVARSONLY
;
2234 /* this loop is the core of the function */
2235 for (inpos
= 0; /* we have several break points */ ; inpos
++) {
2237 if (format
[inpos
] == (WCHAR
) '\'') {
2238 if (format
[inpos
+1] == '\'') {
2240 output
[outpos
++] = '\'';
2245 } else if (format
[inpos
] == 0) {
2246 output
[outpos
++] = 0;
2247 if (outpos
> outlen
) Overflow
= 1;
2248 break; /* normal exit (within a quote) */
2250 output
[outpos
++] = format
[inpos
]; /* copy input */
2251 if (outpos
> outlen
) {
2253 output
[outpos
-1] = 0;
2257 } else if ( (count
&& (format
[inpos
] != type
))
2258 || ( (count
==4 && type
=='y') ||
2259 (count
==4 && type
=='M') ||
2260 (count
==4 && type
=='d') ||
2261 (count
==2 && type
=='g') ||
2262 (count
==2 && type
=='h') ||
2263 (count
==2 && type
=='H') ||
2264 (count
==2 && type
=='m') ||
2265 (count
==2 && type
=='s') ||
2266 (count
==2 && type
=='t') ) ) {
2269 GetLocaleInfo32W(locale
,
2270 LOCALE_SDAYNAME1
+ xtime
->wDayOfWeek
-1,
2271 buf
, sizeof(buf
)/sizeof(WCHAR
) );
2272 } else if (count
== 3) {
2273 GetLocaleInfo32W(locale
,
2274 LOCALE_SABBREVDAYNAME1
+
2275 xtime
->wDayOfWeek
-1,
2276 buf
, sizeof(buf
)/sizeof(WCHAR
) );
2278 wsnprintf32W(buf
, 5, argarr
[count
], xtime
->wDay
);
2280 } else if (type
== 'M') {
2282 GetLocaleInfo32W(locale
, LOCALE_SMONTHNAME1
+
2283 xtime
->wMonth
-1, buf
,
2284 sizeof(buf
)/sizeof(WCHAR
) );
2285 } else if (count
== 3) {
2286 GetLocaleInfo32W(locale
, LOCALE_SABBREVMONTHNAME1
+
2287 xtime
->wMonth
-1, buf
,
2288 sizeof(buf
)/sizeof(WCHAR
) );
2290 wsnprintf32W(buf
, 5, argarr
[count
], xtime
->wMonth
);
2292 } else if (type
== 'y') {
2294 wsnprintf32W(buf
, 6, argarr
[1] /* "%d" */,
2296 } else if (count
== 3) {
2297 lstrcpynAtoW(buf
, "yyy", 5);
2299 wsnprintf32W(buf
, 6, argarr
[count
],
2300 xtime
->wYear
% 100);
2302 } else if (type
== 'g') {
2304 FIXME(ole
, "LOCALE_ICALENDARTYPE unimplemented\n");
2305 lstrcpynAtoW(buf
, "AD", 5);
2307 /* Win API sez we copy it verbatim */
2308 lstrcpynAtoW(buf
, "g", 5);
2310 } else if (type
== 'h') {
2311 /* hours 1:00-12:00 --- is this right? */
2312 wsnprintf32W(buf
, 5, argarr
[count
],
2313 (xtime
->wHour
-1)%12 +1);
2314 } else if (type
== 'H') {
2315 wsnprintf32W(buf
, 5, argarr
[count
],
2317 } else if (type
== 'm') {
2318 wsnprintf32W(buf
, 5, argarr
[count
],
2320 } else if (type
== 's') {
2321 wsnprintf32W(buf
, 5, argarr
[count
],
2323 } else if (type
== 't') {
2324 GetLocaleInfo32W(locale
, (xtime
->wHour
< 12) ?
2325 LOCALE_S1159
: LOCALE_S2359
,
2332 /* no matter what happened, we need to check this next
2333 character the next time we loop through */
2336 /* cat buf onto the output */
2337 outlen
= lstrlen32W(buf
);
2338 if (outpos
+ buflen
< outlen
) {
2339 output
[outpos
] = 0; /* a "hook" for strcat */
2340 lstrcat32W(output
, buf
);
2344 lstrcatn32W(output
, buf
, outlen
- outpos
);
2345 output
[outlen
- 1] = 0;
2347 break; /* Abnormal exit */
2350 /* reset the variables we used this time */
2353 } else if (format
[inpos
] == 0) {
2354 /* we can't check for this at the beginning, because that
2355 would keep us from printing a format spec that ended the
2358 break; /* NORMAL EXIT */
2360 /* how we keep track of the middle of a format spec */
2363 } else if ( (datevars
&& (format
[inpos
]=='d' ||
2364 format
[inpos
]=='M' ||
2365 format
[inpos
]=='y' ||
2366 format
[inpos
]=='g') ) ||
2367 (timevars
&& (format
[inpos
]=='H' ||
2368 format
[inpos
]=='h' ||
2369 format
[inpos
]=='m' ||
2370 format
[inpos
]=='s' ||
2371 format
[inpos
]=='t') ) ) {
2372 type
= format
[inpos
];
2375 } else if (format
[inpos
] == '\'') {
2379 /* unquoted literals */
2380 output
[outpos
++] = format
[inpos
];
2385 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2386 WARN(ole
, " buffer overflow\n");
2389 /* final string terminator and sanity check */
2391 if (outpos
> outlen
-1) outpos
= outlen
-1;
2392 output
[outpos
] = '0';
2394 lstrcpynWtoA(abuf
, output
, sizeof(abuf
) );
2395 TRACE(ole
, " returning string \'%s\'\n", abuf
);
2397 return (!Overflow
) ? outlen
: 0;
2402 /*****************************************************************
2403 * GetDateFormat32A() [KERNEL32.310] Makes an ASCII string of the date
2405 * This function uses format to format the date, or, if format
2406 * is NULL, uses the default for the locale. format is a string
2407 * of literal fields and characters as follows:
2409 * - d single-digit (no leading zero) day (of month)
2410 * - dd two-digit day (of month)
2411 * - ddd short day-of-week name
2412 * - dddd long day-of-week name
2413 * - M single-digit month
2414 * - MM two-digit month
2415 * - MMM short month name
2416 * - MMMM full month name
2417 * - y two-digit year, no leading 0
2418 * - yy two-digit year
2419 * - yyyy four-digit year
2424 INT32 WINAPI
GetDateFormat32A(LCID locale
,DWORD flags
,
2426 LPCSTR format
, LPSTR date
,INT32 datelen
)
2429 char format_buf
[40];
2432 LPSYSTEMTIME thistime
;
2437 TRACE(ole
,"(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",
2438 locale
,flags
,xtime
,format
,date
,datelen
);
2441 locale
= LOCALE_SYSTEM_DEFAULT
;
2444 if (locale
== LOCALE_SYSTEM_DEFAULT
) {
2445 thislocale
= GetSystemDefaultLCID();
2446 } else if (locale
== LOCALE_USER_DEFAULT
) {
2447 thislocale
= GetUserDefaultLCID();
2449 thislocale
= locale
;
2452 if (xtime
== NULL
) {
2459 if (format
== NULL
) {
2460 GetLocaleInfo32A(thislocale
, ((flags
&DATE_LONGDATE
)
2462 : LOCALE_SSHORTDATE
),
2463 format_buf
, sizeof(format_buf
));
2464 thisformat
= format_buf
;
2466 thisformat
= format
;
2470 ret
= OLE_GetFormatA(thislocale
, flags
, thistime
, thisformat
,
2475 "GetDateFormat32A() returning %d, with data=%s\n",
2480 /* ****************************************************************
2481 * GetDateFormat32W() [KERNEL32.311] Makes a Unicode string of the date
2483 * Acts the same as GetDateFormat32A(), except that it's Unicode.
2484 * Accepts & returns sizes as counts of Unicode characters.
2487 INT32 WINAPI
GetDateFormat32W(LCID locale
,DWORD flags
,
2490 LPWSTR date
, INT32 datelen
)
2492 short datearr
[] = {'1','9','9','4','-','1','-','1',0};
2494 FIXME(ole
, "STUB (should call OLE_GetFormatW)\n");
2495 lstrcpyn32W(date
, datearr
, datelen
);
2496 return ( datelen
< 9) ? datelen
: 9;
2502 /**************************************************************************
2503 * GetNumberFormat32A (KERNEL32.355)
2504 * NOTE: type of lpFormat should be CONST NUMBERFORMAT
2506 INT32 WINAPI
GetNumberFormat32A(LCID locale
, DWORD dwflags
,
2507 LPCSTR lpvalue
, char *lpFormat
,
2508 LPSTR lpNumberStr
, int cchNumber
)
2512 FIXME(file
,"%s: stub, no reformating done\n",lpvalue
);
2514 n
= strlen(lpvalue
);
2516 strncpy(lpNumberStr
,lpvalue
,cchNumber
);
2517 if (cchNumber
<= n
) {
2518 lpNumberStr
[cchNumber
-1] = 0;
2527 /*****************************************************************
2529 * GetTimeFormat32A() [KERNEL32.422] Makes an ASCII string of the time
2531 * Formats date according to format, or locale default if format is
2532 * NULL. The format consists of literal characters and fields as follows:
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)
2548 GetTimeFormat32A(LCID locale
, /* in */
2549 DWORD flags
, /* in */
2550 LPSYSTEMTIME xtime
, /* in */
2551 LPCSTR format
, /* in */
2552 LPSTR timestr
, /* out */
2553 INT32 timelen
/* in */)
2558 TRACE(ole
,"GetTimeFormat(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",
2559 locale
,flags
,xtime
,format
,timestr
,timelen
);
2562 realformat
= format
;
2563 } else if (locale
) {
2564 GetLocaleInfo32A(locale
, LOCALE_STIMEFORMAT
,
2565 fmt_buf
, sizeof(fmt_buf
));
2566 realformat
= fmt_buf
;
2568 WARN(ole
, "Caller gave no locale and no format\n");
2569 realformat
= "hh:mm:ss";
2572 locale
= GetSystemDefaultLCID();
2574 return OLE_GetFormatA(locale
, flags
, xtime
, realformat
, timestr
, timelen
);
2578 /* ****************************************************************
2579 * GetTimeFormat32W() [KERNEL32.423] Makes a Unicode string of the time
2585 GetTimeFormat32W(LCID locale
,DWORD flags
,
2588 LPWSTR timestr
,INT32 timelen
)
2592 LPCWSTR realformat
=0;
2594 LPSYSTEMTIME realtime
;
2595 WCHAR
* fmt_buf
= NULL
;
2596 int fmt_buf_size
= 0; /* units of WCHARs */
2599 lstrcpynWtoA(debugbuf
, format
, (sizeof(buf
))/2);
2600 TRACE(ole
, "GetTimeFormatW len %d flags 0x%lX format >%s<\n",
2601 timelen
, flags
, debugbuf
);
2603 /* Enforce the Windows behavior */
2604 flags
|= ~LOCALE_TIMEDATEBOTH
;
2605 flags
|= TIME_TIMEVARSONLY
;
2607 /* take care of the format or locale not being given */
2609 realformat
= format
;
2610 } else if (locale
) {
2611 /* allocate memory */
2612 retval
= ERROR_INSUFFICIENT_BUFFER
;
2613 fmt_buf
= malloc((fmt_buf_size
+=7) * sizeof(WCHAR
));
2617 while(!GetLocaleInfo32W(locale
, LOCALE_STIMEFORMAT
,
2618 fmt_buf
, fmt_buf_size
)) {
2619 retval
= ERROR_OUTOFMEMORY
;
2620 fmt_buf
= realloc(fmt_buf
,
2621 (fmt_buf_size
+= 10) * sizeof(WCHAR
));
2625 realformat
= fmt_buf
;
2627 FIXME(ole
, "caller gave no locale, no format; what should we do?\n");
2628 SetLastError(ERROR_BAD_FORMAT
);
2631 locale
= GetSystemDefaultLCID();
2636 GetSystemTime(realtime
);
2639 retval
= OLE_GetFormatW(locale
, flags
, realtime
, realformat
, timestr
, timelen
);
2645 SetLastError(retval
);
2646 WARN(ole
, "could not allocate %d chars of memory\n", fmt_buf_size
);