2 * National Language Support library
4 * Copyright 1995 Martin von Loewis
5 * Copyright 1998 David Lee Lambert
6 * Copyright 2000 Julio César Gázquez
17 #include "wine/unicode.h"
24 #include "debugtools.h"
26 DEFAULT_DEBUG_CHANNEL(string);
28 /* Locale name to id map. used by EnumSystemLocales, GetLocaleInfoA
29 * MUST contain all #defines from winnls.h
30 * last entry has NULL name, 0 id.
32 #define LOCALE_ENTRY(x) {#x,LOCALE_##x}
33 static const struct tagLOCALE_NAME2ID {
37 LOCALE_ENTRY(ILANGUAGE),
38 LOCALE_ENTRY(SLANGUAGE),
39 LOCALE_ENTRY(SENGLANGUAGE),
40 LOCALE_ENTRY(SABBREVLANGNAME),
41 LOCALE_ENTRY(SNATIVELANGNAME),
42 LOCALE_ENTRY(ICOUNTRY),
43 LOCALE_ENTRY(SCOUNTRY),
44 LOCALE_ENTRY(SENGCOUNTRY),
45 LOCALE_ENTRY(SABBREVCTRYNAME),
46 LOCALE_ENTRY(SNATIVECTRYNAME),
47 LOCALE_ENTRY(IDEFAULTLANGUAGE),
48 LOCALE_ENTRY(IDEFAULTCOUNTRY),
49 LOCALE_ENTRY(IDEFAULTCODEPAGE),
50 LOCALE_ENTRY(IDEFAULTANSICODEPAGE),
51 LOCALE_ENTRY(IDEFAULTMACCODEPAGE),
53 LOCALE_ENTRY(IMEASURE),
54 LOCALE_ENTRY(SDECIMAL),
55 LOCALE_ENTRY(STHOUSAND),
56 LOCALE_ENTRY(SGROUPING),
57 LOCALE_ENTRY(IDIGITS),
59 LOCALE_ENTRY(INEGNUMBER),
60 LOCALE_ENTRY(SNATIVEDIGITS),
61 LOCALE_ENTRY(SCURRENCY),
62 LOCALE_ENTRY(SINTLSYMBOL),
63 LOCALE_ENTRY(SMONDECIMALSEP),
64 LOCALE_ENTRY(SMONTHOUSANDSEP),
65 LOCALE_ENTRY(SMONGROUPING),
66 LOCALE_ENTRY(ICURRDIGITS),
67 LOCALE_ENTRY(IINTLCURRDIGITS),
68 LOCALE_ENTRY(ICURRENCY),
69 LOCALE_ENTRY(INEGCURR),
72 LOCALE_ENTRY(SSHORTDATE),
73 LOCALE_ENTRY(SLONGDATE),
74 LOCALE_ENTRY(STIMEFORMAT),
78 LOCALE_ENTRY(ITIMEMARKPOSN),
79 LOCALE_ENTRY(ICENTURY),
80 LOCALE_ENTRY(ITLZERO),
81 LOCALE_ENTRY(IDAYLZERO),
82 LOCALE_ENTRY(IMONLZERO),
85 LOCALE_ENTRY(ICALENDARTYPE),
86 LOCALE_ENTRY(IOPTIONALCALENDAR),
87 LOCALE_ENTRY(IFIRSTDAYOFWEEK),
88 LOCALE_ENTRY(IFIRSTWEEKOFYEAR),
89 LOCALE_ENTRY(SDAYNAME1),
90 LOCALE_ENTRY(SDAYNAME2),
91 LOCALE_ENTRY(SDAYNAME3),
92 LOCALE_ENTRY(SDAYNAME4),
93 LOCALE_ENTRY(SDAYNAME5),
94 LOCALE_ENTRY(SDAYNAME6),
95 LOCALE_ENTRY(SDAYNAME7),
96 LOCALE_ENTRY(SABBREVDAYNAME1),
97 LOCALE_ENTRY(SABBREVDAYNAME2),
98 LOCALE_ENTRY(SABBREVDAYNAME3),
99 LOCALE_ENTRY(SABBREVDAYNAME4),
100 LOCALE_ENTRY(SABBREVDAYNAME5),
101 LOCALE_ENTRY(SABBREVDAYNAME6),
102 LOCALE_ENTRY(SABBREVDAYNAME7),
103 LOCALE_ENTRY(SMONTHNAME1),
104 LOCALE_ENTRY(SMONTHNAME2),
105 LOCALE_ENTRY(SMONTHNAME3),
106 LOCALE_ENTRY(SMONTHNAME4),
107 LOCALE_ENTRY(SMONTHNAME5),
108 LOCALE_ENTRY(SMONTHNAME6),
109 LOCALE_ENTRY(SMONTHNAME7),
110 LOCALE_ENTRY(SMONTHNAME8),
111 LOCALE_ENTRY(SMONTHNAME9),
112 LOCALE_ENTRY(SMONTHNAME10),
113 LOCALE_ENTRY(SMONTHNAME11),
114 LOCALE_ENTRY(SMONTHNAME12),
115 LOCALE_ENTRY(SMONTHNAME13),
116 LOCALE_ENTRY(SABBREVMONTHNAME1),
117 LOCALE_ENTRY(SABBREVMONTHNAME2),
118 LOCALE_ENTRY(SABBREVMONTHNAME3),
119 LOCALE_ENTRY(SABBREVMONTHNAME4),
120 LOCALE_ENTRY(SABBREVMONTHNAME5),
121 LOCALE_ENTRY(SABBREVMONTHNAME6),
122 LOCALE_ENTRY(SABBREVMONTHNAME7),
123 LOCALE_ENTRY(SABBREVMONTHNAME8),
124 LOCALE_ENTRY(SABBREVMONTHNAME9),
125 LOCALE_ENTRY(SABBREVMONTHNAME10),
126 LOCALE_ENTRY(SABBREVMONTHNAME11),
127 LOCALE_ENTRY(SABBREVMONTHNAME12),
128 LOCALE_ENTRY(SABBREVMONTHNAME13),
129 LOCALE_ENTRY(SPOSITIVESIGN),
130 LOCALE_ENTRY(SNEGATIVESIGN),
131 LOCALE_ENTRY(IPOSSIGNPOSN),
132 LOCALE_ENTRY(INEGSIGNPOSN),
133 LOCALE_ENTRY(IPOSSYMPRECEDES),
134 LOCALE_ENTRY(IPOSSEPBYSPACE),
135 LOCALE_ENTRY(INEGSYMPRECEDES),
136 LOCALE_ENTRY(INEGSEPBYSPACE),
137 LOCALE_ENTRY(FONTSIGNATURE),
138 LOCALE_ENTRY(SISO639LANGNAME),
139 LOCALE_ENTRY(SISO3166CTRYNAME),
143 static char *GetLocaleSubkeyName( DWORD lctype );
145 /***********************************************************************
146 * GetUserDefaultLCID [KERNEL32.425]
148 LCID WINAPI GetUserDefaultLCID(void)
150 return MAKELCID( GetUserDefaultLangID() , SORT_DEFAULT );
153 /***********************************************************************
154 * GetSystemDefaultLCID [KERNEL32.400]
156 LCID WINAPI GetSystemDefaultLCID(void)
158 return GetUserDefaultLCID();
161 #define NLS_MAX_LANGUAGES 20
165 LANGID found_lang_id[NLS_MAX_LANGUAGES];
166 char found_language[NLS_MAX_LANGUAGES][3];
167 char found_country[NLS_MAX_LANGUAGES][3];
171 static BOOL CALLBACK NLS_FindLanguageID_ProcA(HMODULE hModule, LPCSTR type,
172 LPCSTR name, WORD LangID, LONG lParam)
174 LANG_FIND_DATA *l_data = (LANG_FIND_DATA *)lParam;
175 LCID lcid = MAKELCID(LangID, SORT_DEFAULT);
176 char buf_language[128];
177 char buf_country[128];
178 char buf_en_language[128];
180 TRACE("%04X\n", (UINT)LangID);
181 if(PRIMARYLANGID(LangID) == LANG_NEUTRAL)
182 return TRUE; /* continue search */
187 GetLocaleInfoA(lcid, LOCALE_SISO639LANGNAME|LOCALE_NOUSEROVERRIDE,
188 buf_language, sizeof(buf_language));
189 TRACE("LOCALE_SISO639LANGNAME: %s\n", buf_language);
191 GetLocaleInfoA(lcid, LOCALE_SISO3166CTRYNAME|LOCALE_NOUSEROVERRIDE,
192 buf_country, sizeof(buf_country));
193 TRACE("LOCALE_SISO3166CTRYNAME: %s\n", buf_country);
195 if(l_data->lang && strlen(l_data->lang) > 0 && !strcasecmp(l_data->lang, buf_language))
197 if(l_data->country && strlen(l_data->country) > 0)
199 if(!strcasecmp(l_data->country, buf_country))
201 l_data->found_lang_id[0] = LangID;
203 TRACE("Found lang_id %04X for %s_%s\n", LangID, l_data->lang, l_data->country);
204 return FALSE; /* stop enumeration */
207 else /* l_data->country not specified */
209 if(l_data->n_found < NLS_MAX_LANGUAGES)
211 l_data->found_lang_id[l_data->n_found] = LangID;
212 strncpy(l_data->found_country[l_data->n_found], buf_country, 3);
213 strncpy(l_data->found_language[l_data->n_found], buf_language, 3);
215 TRACE("Found lang_id %04X for %s\n", LangID, l_data->lang);
216 return TRUE; /* continue search */
221 /* Just in case, check LOCALE_SENGLANGUAGE too,
222 * in hope that possible alias name might have that value.
224 buf_en_language[0] = 0;
225 GetLocaleInfoA(lcid, LOCALE_SENGLANGUAGE|LOCALE_NOUSEROVERRIDE,
226 buf_en_language, sizeof(buf_en_language));
227 TRACE("LOCALE_SENGLANGUAGE: %s\n", buf_en_language);
229 if(l_data->lang && strlen(l_data->lang) > 0 && !strcasecmp(l_data->lang, buf_en_language))
231 l_data->found_lang_id[l_data->n_found] = LangID;
232 strncpy(l_data->found_country[l_data->n_found], buf_country, 3);
233 strncpy(l_data->found_language[l_data->n_found], buf_language, 3);
235 TRACE("Found lang_id %04X for %s\n", LangID, l_data->lang);
238 return TRUE; /* continue search */
241 /***********************************************************************
245 * Lang: a string whose two first chars are the iso name of a language.
246 * Country: a string whose two first chars are the iso name of country
247 * Charset: a string defining the chossen charset encoding
248 * Dialect: a string defining a variation of the locale
250 * all those values are from the standardized format of locale
251 * name in unix which is: Lang[_Country][.Charset][@Dialect]
254 * the numeric code of the language used by Windows
256 * FIXME: Charset and Dialect are not handled
258 static LANGID NLS_GetLanguageID(LPCSTR Lang, LPCSTR Country, LPCSTR Charset, LPCSTR Dialect)
260 LANG_FIND_DATA l_data;
261 char lang_string[256];
265 l_data.found_lang_id[0] = MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT);
269 memset(&l_data, 0, sizeof(LANG_FIND_DATA));
270 strncpy(l_data.lang, Lang, sizeof(l_data.lang));
272 if(Country && strlen(Country) > 0)
273 strncpy(l_data.country, Country, sizeof(l_data.country));
275 EnumResourceLanguagesA(GetModuleHandleA("KERNEL32"), RT_STRINGA,
276 (LPCSTR)LOCALE_ILANGUAGE, NLS_FindLanguageID_ProcA, (LONG)&l_data);
278 strcpy(lang_string, l_data.lang);
279 if(l_data.country && strlen(l_data.country) > 0)
281 strcat(lang_string, "_");
282 strcat(lang_string, l_data.country);
287 if(l_data.country && strlen(l_data.country) > 0)
289 MESSAGE("Warning: Language '%s' was not found, retrying without country name...\n", lang_string);
290 l_data.country[0] = 0;
291 EnumResourceLanguagesA(GetModuleHandleA("KERNEL32"), RT_STRINGA,
292 (LPCSTR)LOCALE_ILANGUAGE, NLS_FindLanguageID_ProcA, (LONG)&l_data);
296 /* Re-evaluate lang_string */
297 strcpy(lang_string, l_data.lang);
298 if(l_data.country && strlen(l_data.country) > 0)
300 strcat(lang_string, "_");
301 strcat(lang_string, l_data.country);
306 MESSAGE("Warning: Language '%s' was not recognized, defaulting to English\n", lang_string);
307 l_data.found_lang_id[0] = MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT);
311 if(l_data.n_found == 1)
312 TRACE("For language '%s' lang_id %04X was found\n", lang_string, l_data.found_lang_id[0]);
313 else /* l_data->n_found > 1 */
316 MESSAGE("For language '%s' several language ids were found:\n", lang_string);
317 for(i = 0; i < l_data.n_found; i++)
318 MESSAGE("%s_%s - %04X; ", l_data.found_language[i], l_data.found_country[i], l_data.found_lang_id[i]);
320 MESSAGE("\nInstead of using first in the list, suggest to define\n"
321 "your LANG environment variable like this: LANG=%s_%s\n",
322 l_data.found_language[0], l_data.found_country[0]);
326 TRACE("Returning %04X\n", l_data.found_lang_id[0]);
327 return l_data.found_lang_id[0];
330 /***********************************************************************
331 * GetUserDefaultLangID [KERNEL32.426]
333 LANGID WINAPI GetUserDefaultLangID(void)
335 /* caching result, if defined from environment, which should (?) not change during a WINE session */
336 static LANGID userLCID = 0;
341 char *lang,*country,*charset,*dialect,*next;
343 if (GetEnvironmentVariableA( "LANGUAGE", buf, sizeof(buf) )) goto ok;
344 if (GetEnvironmentVariableA( "LANG", buf, sizeof(buf) )) goto ok;
345 if (GetEnvironmentVariableA( "LC_ALL", buf, sizeof(buf) )) goto ok;
346 if (GetEnvironmentVariableA( "LC_MESSAGES", buf, sizeof(buf) )) goto ok;
347 if (GetEnvironmentVariableA( "LC_CTYPE", buf, sizeof(buf) )) goto ok;
349 return userLCID = MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT );
352 if (!strcmp(buf,"POSIX") || !strcmp(buf,"C"))
353 return userLCID = MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT );
358 next=strchr(lang,':'); if (next) *next++='\0';
359 dialect=strchr(lang,'@'); if (dialect) *dialect++='\0';
360 charset=strchr(lang,'.'); if (charset) *charset++='\0';
361 country=strchr(lang,'_'); if (country) *country++='\0';
363 userLCID = NLS_GetLanguageID(lang, country, charset, dialect);
366 } while (lang && !userLCID);
370 MESSAGE( "Warning: language '%s' not recognized, defaulting to English\n",
372 userLCID = MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT );
378 /***********************************************************************
379 * GetSystemDefaultLangID [KERNEL32.401]
381 LANGID WINAPI GetSystemDefaultLangID(void)
383 return GetUserDefaultLangID();
386 /******************************************************************************
387 * ConvertDefaultLocale [KERNEL32.147]
389 LCID WINAPI ConvertDefaultLocale (LCID lcid)
391 { case LOCALE_SYSTEM_DEFAULT:
392 return GetSystemDefaultLCID();
393 case LOCALE_USER_DEFAULT:
394 return GetUserDefaultLCID();
396 return MAKELCID (LANG_NEUTRAL, SUBLANG_NEUTRAL);
398 return MAKELANGID( PRIMARYLANGID(lcid), SUBLANG_NEUTRAL);
401 /* Enhanced version of LoadStringW.
402 * It takes LanguageId to find and load language dependant resources.
403 * Resource is copied as is: "binary" strings are not truncated.
404 * Return: length of resource + 1 to distinguish absent resources
405 * from the resources with zero length.
407 static INT NLS_LoadStringExW(HMODULE hModule, LANGID lang_id, UINT res_id, LPWSTR buffer, INT buflen)
415 hrsrc = FindResourceExW(hModule, RT_STRINGW, (LPCWSTR)((res_id >> 4) + 1), lang_id);
418 hmem = LoadResource(hModule, hrsrc);
421 p = LockResource(hmem);
422 string_num = res_id & 0x000f;
423 for(i = 0; i < string_num; i++)
426 TRACE("strlen = %d\n", (int)*p );
428 if (buffer == NULL) return *p;
429 i = min(buflen - 1, *p);
431 memcpy(buffer, p + 1, i * sizeof (WCHAR));
432 buffer[i] = (WCHAR) 0;
435 buffer[0] = (WCHAR) 0;
439 TRACE("\"%s\" loaded!\n", debugstr_w(buffer));
443 /******************************************************************************
444 * GetLocaleInfoA [KERNEL32.342]
447 * LANG_NEUTRAL is equal to LOCALE_SYSTEM_DEFAULT
449 * MS online documentation states that the string returned is NULL terminated
450 * except for LOCALE_FONTSIGNATURE which "will return a non-NULL
451 * terminated string".
453 INT WINAPI GetLocaleInfoA(LCID lcid,LCTYPE LCType,LPSTR buf,INT len)
455 LPCSTR retString = NULL;
459 DWORD dwBufferSize=128;
462 TRACE("(lcid=0x%lx,lctype=0x%lx,%p,%x)\n",lcid,LCType,buf,len);
464 if (len && (! buf) ) {
465 SetLastError(ERROR_INSUFFICIENT_BUFFER);
469 if (lcid == LOCALE_NEUTRAL || lcid == LANG_SYSTEM_DEFAULT)
471 lcid = GetSystemDefaultLCID();
473 else if (lcid == LANG_USER_DEFAULT) /*0x800*/
475 lcid = GetUserDefaultLCID();
478 /* LOCALE_NOUSEROVERRIDE means: do not get user redefined settings
479 from the registry. Instead, use system default values. */
480 NoUserOverride = (LCType & LOCALE_NOUSEROVERRIDE) != 0;
482 LCType &= ~(LOCALE_NOUSEROVERRIDE|LOCALE_USE_CP_ACP);
484 /* First, check if it's in the registry. */
485 /* All user customized values are stored in the registry by SetLocaleInfo */
486 if ( !NoUserOverride && (pacKey = GetLocaleSubkeyName(LCType)) )
491 sprintf( acRealKey, "Control Panel\\International\\%s", pacKey );
493 if ( RegOpenKeyExA( HKEY_CURRENT_USER, acRealKey,
494 0, KEY_READ, &hKey) == ERROR_SUCCESS )
496 if ( RegQueryValueExA( hKey, NULL, NULL, NULL, (LPBYTE)acBuffer,
497 &dwBufferSize ) == ERROR_SUCCESS )
499 retString = acBuffer;
506 /* If not in the registry, get it from the NLS entries. */
511 /* check if language is registered in the kernel32 resources */
512 if((res_size = NLS_LoadStringExW(GetModuleHandleA("KERNEL32"), LANGIDFROMLCID(lcid),
513 LCType, wcBuffer, sizeof(wcBuffer)/sizeof(wcBuffer[0])))) {
514 WideCharToMultiByte(CP_ACP, 0, wcBuffer, res_size, acBuffer, dwBufferSize, NULL, NULL);
515 retString = acBuffer;
520 /* if not found report a most descriptive error */
523 /* If we are through all of this, retLen should not be zero anymore.
524 If it is, the value is not supported */
526 while (locale_name2id[i].name!=NULL) {
527 if (LCType == locale_name2id[i].id) {
528 retString = locale_name2id[i].name;
534 FIXME("Unkown LC type %lX\n", LCType);
536 FIXME("'%s' is not defined for your language (%04X).\n"
537 "Please define it in dlls/kernel/nls/YourLanguage.nls\n"
538 "and submit patch for inclusion into the next Wine release.\n",
539 retString, LOWORD(lcid));
540 SetLastError(ERROR_INVALID_PARAMETER);
544 /* a FONTSIGNATURE is not a string, just 6 DWORDs */
545 if (LCType == LOCALE_FONTSIGNATURE) {
547 len = (len < sizeof(FONTSIGNATURE)) ? len : sizeof(FONTSIGNATURE);
548 memcpy(buf, retString, len);
551 return sizeof(FONTSIGNATURE);
553 /* if len=0 return only the length, don't touch the buffer*/
555 lstrcpynA(buf,retString,len);
556 return strlen(buf) + 1;
558 return strlen(retString)+1;
561 /******************************************************************************
562 * GetLocaleInfoW [KERNEL32.343]
565 * MS documentation states that len "specifies the size, in bytes (ANSI version)
566 * or characters (Unicode version), of" wbuf. Thus the number returned is
567 * the same between GetLocaleInfoW and GetLocaleInfoA.
569 INT WINAPI GetLocaleInfoW(LCID lcid,LCTYPE LCType,LPWSTR wbuf,INT len)
573 if (len && (! wbuf) )
574 { SetLastError(ERROR_INSUFFICIENT_BUFFER);
578 abuf = (LPSTR)HeapAlloc(GetProcessHeap(),0,len);
579 wlen = GetLocaleInfoA(lcid, LCType, abuf, len);
581 if (wlen && len) /* if len=0 return only the length*/
582 MultiByteToWideChar( CP_ACP, 0, abuf, -1, wbuf, len );
584 HeapFree(GetProcessHeap(),0,abuf);
588 /******************************************************************************
590 * GetLocaleSubkeyName [helper function]
592 * - For use with the registry.
593 * - Gets the registry subkey name for a given lctype.
595 static char *GetLocaleSubkeyName( DWORD lctype )
601 /* These values are used by SetLocaleInfo and GetLocaleInfo, and
602 * the values are stored in the registry, confirmed under Windows,
603 * for the ones that actually assign pacKey. Cases that aren't finished
604 * have not been confirmed, so that must be done before they can be
607 case LOCALE_SDATE : /* The date separator. */
610 case LOCALE_ICURRDIGITS:
611 pacKey = "iCurrDigits";
613 case LOCALE_SDECIMAL :
616 case LOCALE_ICURRENCY:
617 pacKey = "iCurrency";
619 case LOCALE_SGROUPING :
620 pacKey = "sGrouping";
628 /* case LOCALE_ICALENDARTYPE: */
629 /* case LOCALE_IFIRSTDAYOFWEEK: */
630 /* case LOCALE_IFIRSTWEEKOFYEAR: */
631 /* case LOCALE_SYEARMONTH : */
632 /* case LOCALE_SPOSITIVESIGN : */
633 /* case LOCALE_IPAPERSIZE: */
635 case LOCALE_SLONGDATE :
636 pacKey = "sLongDate";
638 case LOCALE_SMONDECIMALSEP :
639 pacKey = "sMonDecimalSep";
641 case LOCALE_SMONGROUPING:
642 pacKey = "sMonGrouping";
644 case LOCALE_IMEASURE:
647 case LOCALE_SMONTHOUSANDSEP :
648 pacKey = "sMonThousandSep";
650 case LOCALE_INEGCURR:
653 case LOCALE_SNEGATIVESIGN :
654 pacKey = "sNegativeSign";
656 case LOCALE_INEGNUMBER:
657 pacKey = "iNegNumber";
659 case LOCALE_SSHORTDATE :
660 pacKey = "sShortDate";
662 case LOCALE_ILDATE: /* Long Date format ordering specifier. */
671 case LOCALE_ITIME: /* Time format specifier. */
674 case LOCALE_STHOUSAND :
675 pacKey = "sThousand";
677 case LOCALE_S1159: /* AM */
683 case LOCALE_S2359: /* PM */
686 case LOCALE_STIMEFORMAT :
687 pacKey = "sTimeFormat";
689 case LOCALE_SCURRENCY:
690 pacKey = "sCurrency";
693 /* The following are not listed under MSDN as supported,
694 * but seem to be used and also stored in the registry.
700 case LOCALE_SCOUNTRY:
703 case LOCALE_ICOUNTRY:
706 case LOCALE_SLANGUAGE:
707 pacKey = "sLanguage";
717 /******************************************************************************
718 * SetLocaleInfoA [KERNEL32.656]
720 BOOL WINAPI SetLocaleInfoA(DWORD lcid, DWORD lctype, LPCSTR data)
726 if ( (pacKey = GetLocaleSubkeyName(lctype)) )
728 sprintf( acRealKey, "Control Panel\\International\\%s", pacKey );
729 if ( RegCreateKeyA( HKEY_CURRENT_USER, acRealKey,
730 &hKey ) == ERROR_SUCCESS )
732 if ( RegSetValueExA( hKey, NULL, 0, REG_SZ,
733 data, strlen(data)+1 ) != ERROR_SUCCESS )
735 ERR("SetLocaleInfoA: %s did not work\n", pacKey );
742 FIXME("(%ld,%ld,%s): stub\n",lcid,lctype,data);
747 /******************************************************************************
748 * IsValidLocale [KERNEL32.489]
750 BOOL WINAPI IsValidLocale(LCID lcid,DWORD flags)
752 /* check if language is registered in the kernel32 resources */
753 if(!FindResourceExW(GetModuleHandleA("KERNEL32"), RT_STRINGW, (LPCWSTR)LOCALE_ILANGUAGE, LOWORD(lcid)))
759 static BOOL CALLBACK EnumResourceLanguagesProcW(HMODULE hModule, LPCWSTR type,
760 LPCWSTR name, WORD LangID, LONG lParam)
764 LOCALE_ENUMPROCW lpfnLocaleEnum = (LOCALE_ENUMPROCW)lParam;
765 sprintf(bufA, "%08X", (UINT)LangID);
766 MultiByteToWideChar(CP_ACP, 0, bufA, -1, bufW, sizeof(bufW)/sizeof(bufW[0]));
767 return lpfnLocaleEnum(bufW);
770 /******************************************************************************
771 * EnumSystemLocalesW [KERNEL32.209]
773 BOOL WINAPI EnumSystemLocalesW( LOCALE_ENUMPROCW lpfnLocaleEnum,
776 TRACE("(%p,%08lx)\n", lpfnLocaleEnum,flags);
778 EnumResourceLanguagesW(GetModuleHandleA("KERNEL32"), RT_STRINGW,
779 (LPCWSTR)LOCALE_ILANGUAGE, EnumResourceLanguagesProcW,
780 (LONG)lpfnLocaleEnum);
785 static BOOL CALLBACK EnumResourceLanguagesProcA(HMODULE hModule, LPCSTR type,
786 LPCSTR name, WORD LangID, LONG lParam)
789 LOCALE_ENUMPROCA lpfnLocaleEnum = (LOCALE_ENUMPROCA)lParam;
790 sprintf(bufA, "%08X", (UINT)LangID);
791 return lpfnLocaleEnum(bufA);
794 /******************************************************************************
795 * EnumSystemLocalesA [KERNEL32.208]
797 BOOL WINAPI EnumSystemLocalesA(LOCALE_ENUMPROCA lpfnLocaleEnum,
800 TRACE("(%p,%08lx)\n", lpfnLocaleEnum,flags);
802 EnumResourceLanguagesA(GetModuleHandleA("KERNEL32"), RT_STRINGA,
803 (LPCSTR)LOCALE_ILANGUAGE, EnumResourceLanguagesProcA,
804 (LONG)lpfnLocaleEnum);
809 static const unsigned char CT_CType2_LUT[] = {
810 C2_NOTAPPLICABLE, /* - 0 */
811 C2_NOTAPPLICABLE, /* - 1 */
812 C2_NOTAPPLICABLE, /* - 2 */
813 C2_NOTAPPLICABLE, /* - 3 */
814 C2_NOTAPPLICABLE, /* - 4 */
815 C2_NOTAPPLICABLE, /* - 5 */
816 C2_NOTAPPLICABLE, /* - 6 */
817 C2_NOTAPPLICABLE, /* - 7 */
818 C2_NOTAPPLICABLE, /* - 8 */
819 C2_SEGMENTSEPARATOR, /* - 9 */
820 C2_NOTAPPLICABLE, /* - 10 */
821 C2_NOTAPPLICABLE, /* - 11 */
822 C2_NOTAPPLICABLE, /* - 12 */
823 C2_NOTAPPLICABLE, /* - 13 */
824 C2_NOTAPPLICABLE, /* - 14 */
825 C2_NOTAPPLICABLE, /* - 15 */
826 C2_NOTAPPLICABLE, /* - 16 */
827 C2_NOTAPPLICABLE, /* - 17 */
828 C2_NOTAPPLICABLE, /* - 18 */
829 C2_NOTAPPLICABLE, /* - 19 */
830 C2_NOTAPPLICABLE, /* - 20 */
831 C2_NOTAPPLICABLE, /* - 21 */
832 C2_NOTAPPLICABLE, /* - 22 */
833 C2_NOTAPPLICABLE, /* - 23 */
834 C2_NOTAPPLICABLE, /* - 24 */
835 C2_NOTAPPLICABLE, /* - 25 */
836 C2_NOTAPPLICABLE, /* - 26 */
837 C2_NOTAPPLICABLE, /* - 27 */
838 C2_NOTAPPLICABLE, /* - 28 */
839 C2_NOTAPPLICABLE, /* - 29 */
840 C2_NOTAPPLICABLE, /* - 30 */
841 C2_NOTAPPLICABLE, /* - 31 */
842 C2_WHITESPACE, /* - 32 */
843 C2_OTHERNEUTRAL, /* ! - 33 */
844 C2_OTHERNEUTRAL, /* " - 34 */ /* " */
845 C2_EUROPETERMINATOR, /* # - 35 */
846 C2_EUROPETERMINATOR, /* $ - 36 */
847 C2_EUROPETERMINATOR, /* % - 37 */
848 C2_LEFTTORIGHT, /* & - 38 */
849 C2_OTHERNEUTRAL, /* ' - 39 */
850 C2_OTHERNEUTRAL, /* ( - 40 */
851 C2_OTHERNEUTRAL, /* ) - 41 */
852 C2_OTHERNEUTRAL, /* * - 42 */
853 C2_EUROPETERMINATOR, /* + - 43 */
854 C2_COMMONSEPARATOR, /* , - 44 */
855 C2_EUROPETERMINATOR, /* - - 45 */
856 C2_EUROPESEPARATOR, /* . - 46 */
857 C2_EUROPESEPARATOR, /* / - 47 */
858 C2_EUROPENUMBER, /* 0 - 48 */
859 C2_EUROPENUMBER, /* 1 - 49 */
860 C2_EUROPENUMBER, /* 2 - 50 */
861 C2_EUROPENUMBER, /* 3 - 51 */
862 C2_EUROPENUMBER, /* 4 - 52 */
863 C2_EUROPENUMBER, /* 5 - 53 */
864 C2_EUROPENUMBER, /* 6 - 54 */
865 C2_EUROPENUMBER, /* 7 - 55 */
866 C2_EUROPENUMBER, /* 8 - 56 */
867 C2_EUROPENUMBER, /* 9 - 57 */
868 C2_COMMONSEPARATOR, /* : - 58 */
869 C2_OTHERNEUTRAL, /* ; - 59 */
870 C2_OTHERNEUTRAL, /* < - 60 */
871 C2_OTHERNEUTRAL, /* = - 61 */
872 C2_OTHERNEUTRAL, /* > - 62 */
873 C2_OTHERNEUTRAL, /* ? - 63 */
874 C2_LEFTTORIGHT, /* @ - 64 */
875 C2_LEFTTORIGHT, /* A - 65 */
876 C2_LEFTTORIGHT, /* B - 66 */
877 C2_LEFTTORIGHT, /* C - 67 */
878 C2_LEFTTORIGHT, /* D - 68 */
879 C2_LEFTTORIGHT, /* E - 69 */
880 C2_LEFTTORIGHT, /* F - 70 */
881 C2_LEFTTORIGHT, /* G - 71 */
882 C2_LEFTTORIGHT, /* H - 72 */
883 C2_LEFTTORIGHT, /* I - 73 */
884 C2_LEFTTORIGHT, /* J - 74 */
885 C2_LEFTTORIGHT, /* K - 75 */
886 C2_LEFTTORIGHT, /* L - 76 */
887 C2_LEFTTORIGHT, /* M - 77 */
888 C2_LEFTTORIGHT, /* N - 78 */
889 C2_LEFTTORIGHT, /* O - 79 */
890 C2_LEFTTORIGHT, /* P - 80 */
891 C2_LEFTTORIGHT, /* Q - 81 */
892 C2_LEFTTORIGHT, /* R - 82 */
893 C2_LEFTTORIGHT, /* S - 83 */
894 C2_LEFTTORIGHT, /* T - 84 */
895 C2_LEFTTORIGHT, /* U - 85 */
896 C2_LEFTTORIGHT, /* V - 86 */
897 C2_LEFTTORIGHT, /* W - 87 */
898 C2_LEFTTORIGHT, /* X - 88 */
899 C2_LEFTTORIGHT, /* Y - 89 */
900 C2_LEFTTORIGHT, /* Z - 90 */
901 C2_OTHERNEUTRAL, /* [ - 91 */
902 C2_OTHERNEUTRAL, /* \ - 92 */
903 C2_OTHERNEUTRAL, /* ] - 93 */
904 C2_OTHERNEUTRAL, /* ^ - 94 */
905 C2_OTHERNEUTRAL, /* _ - 95 */
906 C2_OTHERNEUTRAL, /* ` - 96 */
907 C2_LEFTTORIGHT, /* a - 97 */
908 C2_LEFTTORIGHT, /* b - 98 */
909 C2_LEFTTORIGHT, /* c - 99 */
910 C2_LEFTTORIGHT, /* d - 100 */
911 C2_LEFTTORIGHT, /* e - 101 */
912 C2_LEFTTORIGHT, /* f - 102 */
913 C2_LEFTTORIGHT, /* g - 103 */
914 C2_LEFTTORIGHT, /* h - 104 */
915 C2_LEFTTORIGHT, /* i - 105 */
916 C2_LEFTTORIGHT, /* j - 106 */
917 C2_LEFTTORIGHT, /* k - 107 */
918 C2_LEFTTORIGHT, /* l - 108 */
919 C2_LEFTTORIGHT, /* m - 109 */
920 C2_LEFTTORIGHT, /* n - 110 */
921 C2_LEFTTORIGHT, /* o - 111 */
922 C2_LEFTTORIGHT, /* p - 112 */
923 C2_LEFTTORIGHT, /* q - 113 */
924 C2_LEFTTORIGHT, /* r - 114 */
925 C2_LEFTTORIGHT, /* s - 115 */
926 C2_LEFTTORIGHT, /* t - 116 */
927 C2_LEFTTORIGHT, /* u - 117 */
928 C2_LEFTTORIGHT, /* v - 118 */
929 C2_LEFTTORIGHT, /* w - 119 */
930 C2_LEFTTORIGHT, /* x - 120 */
931 C2_LEFTTORIGHT, /* y - 121 */
932 C2_LEFTTORIGHT, /* z - 122 */
933 C2_OTHERNEUTRAL, /* { - 123 */
934 C2_OTHERNEUTRAL, /* | - 124 */
935 C2_OTHERNEUTRAL, /* } - 125 */
936 C2_OTHERNEUTRAL, /* ~ - 126 */
937 C2_NOTAPPLICABLE, /*
\7f - 127 */
938 C2_NOTAPPLICABLE, /*
\80 - 128 */
939 C2_NOTAPPLICABLE, /*
\81 - 129 */
940 C2_OTHERNEUTRAL, /*
\82 - 130 */
941 C2_LEFTTORIGHT, /*
\83 - 131 */
942 C2_OTHERNEUTRAL, /*
\84 - 132 */
943 C2_OTHERNEUTRAL, /*
\85 - 133 */
944 C2_OTHERNEUTRAL, /*
\86 - 134 */
945 C2_OTHERNEUTRAL, /*
\87 - 135 */
946 C2_LEFTTORIGHT, /*
\88 - 136 */
947 C2_EUROPETERMINATOR, /*
\89 - 137 */
948 C2_LEFTTORIGHT, /*
\8a - 138 */
949 C2_OTHERNEUTRAL, /*
\8b - 139 */
950 C2_LEFTTORIGHT, /*
\8c - 140 */
951 C2_NOTAPPLICABLE, /*
\8d - 141 */
952 C2_NOTAPPLICABLE, /*
\8e - 142 */
953 C2_NOTAPPLICABLE, /*
\8f - 143 */
954 C2_NOTAPPLICABLE, /*
\90 - 144 */
955 C2_OTHERNEUTRAL, /*
\91 - 145 */
956 C2_OTHERNEUTRAL, /*
\92 - 146 */
957 C2_OTHERNEUTRAL, /*
\93 - 147 */
958 C2_OTHERNEUTRAL, /*
\94 - 148 */
959 C2_OTHERNEUTRAL, /*
\95 - 149 */
960 C2_OTHERNEUTRAL, /*
\96 - 150 */
961 C2_OTHERNEUTRAL, /*
\97 - 151 */
962 C2_LEFTTORIGHT, /*
\98 - 152 */
963 C2_OTHERNEUTRAL, /*
\99 - 153 */
964 C2_LEFTTORIGHT, /*
\9a - 154 */
965 C2_OTHERNEUTRAL, /*
\9b - 155 */
966 C2_LEFTTORIGHT, /*
\9c - 156 */
967 C2_NOTAPPLICABLE, /*
\9d - 157 */
968 C2_NOTAPPLICABLE, /*
\9e - 158 */
969 C2_LEFTTORIGHT, /*
\9f - 159 */
970 C2_WHITESPACE, /* - 160 */
971 C2_OTHERNEUTRAL, /* ¡ - 161 */
972 C2_EUROPETERMINATOR, /* ¢ - 162 */
973 C2_EUROPETERMINATOR, /* £ - 163 */
974 C2_EUROPETERMINATOR, /* ¤ - 164 */
975 C2_EUROPETERMINATOR, /* ¥ - 165 */
976 C2_OTHERNEUTRAL, /* ¦ - 166 */
977 C2_OTHERNEUTRAL, /* § - 167 */
978 C2_OTHERNEUTRAL, /* ¨ - 168 */
979 C2_OTHERNEUTRAL, /* © - 169 */
980 C2_OTHERNEUTRAL, /* ª - 170 */
981 C2_OTHERNEUTRAL, /* « - 171 */
982 C2_OTHERNEUTRAL, /* ¬ - 172 */
983 C2_OTHERNEUTRAL, /* - 173 */
984 C2_OTHERNEUTRAL, /* ® - 174 */
985 C2_OTHERNEUTRAL, /* ¯ - 175 */
986 C2_EUROPETERMINATOR, /* ° - 176 */
987 C2_EUROPETERMINATOR, /* ± - 177 */
988 C2_EUROPENUMBER, /* ² - 178 */
989 C2_EUROPENUMBER, /* ³ - 179 */
990 C2_OTHERNEUTRAL, /* ´ - 180 */
991 C2_OTHERNEUTRAL, /* µ - 181 */
992 C2_OTHERNEUTRAL, /* ¶ - 182 */
993 C2_OTHERNEUTRAL, /* · - 183 */
994 C2_OTHERNEUTRAL, /* ¸ - 184 */
995 C2_EUROPENUMBER, /* ¹ - 185 */
996 C2_OTHERNEUTRAL, /* º - 186 */
997 C2_OTHERNEUTRAL, /* » - 187 */
998 C2_OTHERNEUTRAL, /* ¼ - 188 */
999 C2_OTHERNEUTRAL, /* ½ - 189 */
1000 C2_OTHERNEUTRAL, /* ¾ - 190 */
1001 C2_OTHERNEUTRAL, /* ¿ - 191 */
1002 C2_LEFTTORIGHT, /* À - 192 */
1003 C2_LEFTTORIGHT, /* Á - 193 */
1004 C2_LEFTTORIGHT, /* Â - 194 */
1005 C2_LEFTTORIGHT, /* Ã - 195 */
1006 C2_LEFTTORIGHT, /* Ä - 196 */
1007 C2_LEFTTORIGHT, /* Å - 197 */
1008 C2_LEFTTORIGHT, /* Æ - 198 */
1009 C2_LEFTTORIGHT, /* Ç - 199 */
1010 C2_LEFTTORIGHT, /* È - 200 */
1011 C2_LEFTTORIGHT, /* É - 201 */
1012 C2_LEFTTORIGHT, /* Ê - 202 */
1013 C2_LEFTTORIGHT, /* Ë - 203 */
1014 C2_LEFTTORIGHT, /* Ì - 204 */
1015 C2_LEFTTORIGHT, /* Í - 205 */
1016 C2_LEFTTORIGHT, /* Î - 206 */
1017 C2_LEFTTORIGHT, /* Ï - 207 */
1018 C2_LEFTTORIGHT, /* Ð - 208 */
1019 C2_LEFTTORIGHT, /* Ñ - 209 */
1020 C2_LEFTTORIGHT, /* Ò - 210 */
1021 C2_LEFTTORIGHT, /* Ó - 211 */
1022 C2_LEFTTORIGHT, /* Ô - 212 */
1023 C2_LEFTTORIGHT, /* Õ - 213 */
1024 C2_LEFTTORIGHT, /* Ö - 214 */
1025 C2_OTHERNEUTRAL, /* × - 215 */
1026 C2_LEFTTORIGHT, /* Ø - 216 */
1027 C2_LEFTTORIGHT, /* Ù - 217 */
1028 C2_LEFTTORIGHT, /* Ú - 218 */
1029 C2_LEFTTORIGHT, /* Û - 219 */
1030 C2_LEFTTORIGHT, /* Ü - 220 */
1031 C2_LEFTTORIGHT, /* Ý - 221 */
1032 C2_LEFTTORIGHT, /* Þ - 222 */
1033 C2_LEFTTORIGHT, /* ß - 223 */
1034 C2_LEFTTORIGHT, /* à - 224 */
1035 C2_LEFTTORIGHT, /* á - 225 */
1036 C2_LEFTTORIGHT, /* â - 226 */
1037 C2_LEFTTORIGHT, /* ã - 227 */
1038 C2_LEFTTORIGHT, /* ä - 228 */
1039 C2_LEFTTORIGHT, /* å - 229 */
1040 C2_LEFTTORIGHT, /* æ - 230 */
1041 C2_LEFTTORIGHT, /* ç - 231 */
1042 C2_LEFTTORIGHT, /* è - 232 */
1043 C2_LEFTTORIGHT, /* é - 233 */
1044 C2_LEFTTORIGHT, /* ê - 234 */
1045 C2_LEFTTORIGHT, /* ë - 235 */
1046 C2_LEFTTORIGHT, /* ì - 236 */
1047 C2_LEFTTORIGHT, /* í - 237 */
1048 C2_LEFTTORIGHT, /* î - 238 */
1049 C2_LEFTTORIGHT, /* ï - 239 */
1050 C2_LEFTTORIGHT, /* ð - 240 */
1051 C2_LEFTTORIGHT, /* ñ - 241 */
1052 C2_LEFTTORIGHT, /* ò - 242 */
1053 C2_LEFTTORIGHT, /* ó - 243 */
1054 C2_LEFTTORIGHT, /* ô - 244 */
1055 C2_LEFTTORIGHT, /* õ - 245 */
1056 C2_LEFTTORIGHT, /* ö - 246 */
1057 C2_OTHERNEUTRAL, /* ÷ - 247 */
1058 C2_LEFTTORIGHT, /* ø - 248 */
1059 C2_LEFTTORIGHT, /* ù - 249 */
1060 C2_LEFTTORIGHT, /* ú - 250 */
1061 C2_LEFTTORIGHT, /* û - 251 */
1062 C2_LEFTTORIGHT, /* ü - 252 */
1063 C2_LEFTTORIGHT, /* ý - 253 */
1064 C2_LEFTTORIGHT, /* þ - 254 */
1065 C2_LEFTTORIGHT /* ÿ - 255 */
1068 const WORD OLE2NLS_CT_CType3_LUT[] = {
1102 0x0048, /* ! - 33 */
1103 0x0448, /* " - 34 */ /* " */
1104 0x0048, /* # - 35 */
1105 0x0448, /* $ - 36 */
1106 0x0048, /* % - 37 */
1107 0x0048, /* & - 38 */
1108 0x0440, /* ' - 39 */
1109 0x0048, /* ( - 40 */
1110 0x0048, /* ) - 41 */
1111 0x0048, /* * - 42 */
1112 0x0048, /* + - 43 */
1113 0x0048, /* , - 44 */
1114 0x0440, /* - - 45 */
1115 0x0048, /* . - 46 */
1116 0x0448, /* / - 47 */
1117 0x0040, /* 0 - 48 */
1118 0x0040, /* 1 - 49 */
1119 0x0040, /* 2 - 50 */
1120 0x0040, /* 3 - 51 */
1121 0x0040, /* 4 - 52 */
1122 0x0040, /* 5 - 53 */
1123 0x0040, /* 6 - 54 */
1124 0x0040, /* 7 - 55 */
1125 0x0040, /* 8 - 56 */
1126 0x0040, /* 9 - 57 */
1127 0x0048, /* : - 58 */
1128 0x0048, /* ; - 59 */
1129 0x0048, /* < - 60 */
1130 0x0448, /* = - 61 */
1131 0x0048, /* > - 62 */
1132 0x0048, /* ? - 63 */
1133 0x0448, /* @ - 64 */
1134 0x8040, /* A - 65 */
1135 0x8040, /* B - 66 */
1136 0x8040, /* C - 67 */
1137 0x8040, /* D - 68 */
1138 0x8040, /* E - 69 */
1139 0x8040, /* F - 70 */
1140 0x8040, /* G - 71 */
1141 0x8040, /* H - 72 */
1142 0x8040, /* I - 73 */
1143 0x8040, /* J - 74 */
1144 0x8040, /* K - 75 */
1145 0x8040, /* L - 76 */
1146 0x8040, /* M - 77 */
1147 0x8040, /* N - 78 */
1148 0x8040, /* O - 79 */
1149 0x8040, /* P - 80 */
1150 0x8040, /* Q - 81 */
1151 0x8040, /* R - 82 */
1152 0x8040, /* S - 83 */
1153 0x8040, /* T - 84 */
1154 0x8040, /* U - 85 */
1155 0x8040, /* V - 86 */
1156 0x8040, /* W - 87 */
1157 0x8040, /* X - 88 */
1158 0x8040, /* Y - 89 */
1159 0x8040, /* Z - 90 */
1160 0x0048, /* [ - 91 */
1161 0x0448, /* \ - 92 */
1162 0x0048, /* ] - 93 */
1163 0x0448, /* ^ - 94 */
1164 0x0448, /* _ - 95 */
1165 0x0448, /* ` - 96 */
1166 0x8040, /* a - 97 */
1167 0x8040, /* b - 98 */
1168 0x8040, /* c - 99 */
1169 0x8040, /* d - 100 */
1170 0x8040, /* e - 101 */
1171 0x8040, /* f - 102 */
1172 0x8040, /* g - 103 */
1173 0x8040, /* h - 104 */
1174 0x8040, /* i - 105 */
1175 0x8040, /* j - 106 */
1176 0x8040, /* k - 107 */
1177 0x8040, /* l - 108 */
1178 0x8040, /* m - 109 */
1179 0x8040, /* n - 110 */
1180 0x8040, /* o - 111 */
1181 0x8040, /* p - 112 */
1182 0x8040, /* q - 113 */
1183 0x8040, /* r - 114 */
1184 0x8040, /* s - 115 */
1185 0x8040, /* t - 116 */
1186 0x8040, /* u - 117 */
1187 0x8040, /* v - 118 */
1188 0x8040, /* w - 119 */
1189 0x8040, /* x - 120 */
1190 0x8040, /* y - 121 */
1191 0x8040, /* z - 122 */
1192 0x0048, /* { - 123 */
1193 0x0048, /* | - 124 */
1194 0x0048, /* } - 125 */
1195 0x0448, /* ~ - 126 */
1196 0x0000, /*
\7f - 127 */
1197 0x0000, /*
\80 - 128 */
1198 0x0000, /*
\81 - 129 */
1199 0x0008, /*
\82 - 130 */
1200 0x8000, /*
\83 - 131 */
1201 0x0008, /*
\84 - 132 */
1202 0x0008, /*
\85 - 133 */
1203 0x0008, /*
\86 - 134 */
1204 0x0008, /*
\87 - 135 */
1205 0x0001, /*
\88 - 136 */
1206 0x0008, /*
\89 - 137 */
1207 0x8003, /*
\8a - 138 */
1208 0x0008, /*
\8b - 139 */
1209 0x8000, /*
\8c - 140 */
1210 0x0000, /*
\8d - 141 */
1211 0x0000, /*
\8e - 142 */
1212 0x0000, /*
\8f - 143 */
1213 0x0000, /*
\90 - 144 */
1214 0x0088, /*
\91 - 145 */
1215 0x0088, /*
\92 - 146 */
1216 0x0088, /*
\93 - 147 */
1217 0x0088, /*
\94 - 148 */
1218 0x0008, /*
\95 - 149 */
1219 0x0400, /*
\96 - 150 */
1220 0x0400, /*
\97 - 151 */
1221 0x0408, /*
\98 - 152 */
1222 0x0000, /*
\99 - 153 */
1223 0x8003, /*
\9a - 154 */
1224 0x0008, /*
\9b - 155 */
1225 0x8000, /*
\9c - 156 */
1226 0x0000, /*
\9d - 157 */
1227 0x0000, /*
\9e - 158 */
1228 0x8003, /*
\9f - 159 */
1230 0x0008, /* ¡ - 161 */
1231 0x0048, /* ¢ - 162 */
1232 0x0048, /* £ - 163 */
1233 0x0008, /* ¤ - 164 */
1234 0x0048, /* ¥ - 165 */
1235 0x0048, /* ¦ - 166 */
1236 0x0008, /* § - 167 */
1237 0x0408, /* ¨ - 168 */
1238 0x0008, /* © - 169 */
1239 0x0400, /* ª - 170 */
1240 0x0008, /* « - 171 */
1241 0x0048, /* ¬ - 172 */
1242 0x0408, /* - 173 */
1243 0x0008, /* ® - 174 */
1244 0x0448, /* ¯ - 175 */
1245 0x0008, /* ° - 176 */
1246 0x0008, /* ± - 177 */
1247 0x0000, /* ² - 178 */
1248 0x0000, /* ³ - 179 */
1249 0x0408, /* ´ - 180 */
1250 0x0008, /* µ - 181 */
1251 0x0008, /* ¶ - 182 */
1252 0x0008, /* · - 183 */
1253 0x0408, /* ¸ - 184 */
1254 0x0000, /* ¹ - 185 */
1255 0x0400, /* º - 186 */
1256 0x0008, /* » - 187 */
1257 0x0000, /* ¼ - 188 */
1258 0x0000, /* ½ - 189 */
1259 0x0000, /* ¾ - 190 */
1260 0x0008, /* ¿ - 191 */
1261 0x8003, /* À - 192 */
1262 0x8003, /* Á - 193 */
1263 0x8003, /* Â - 194 */
1264 0x8003, /* Ã - 195 */
1265 0x8003, /* Ä - 196 */
1266 0x8003, /* Å - 197 */
1267 0x8000, /* Æ - 198 */
1268 0x8003, /* Ç - 199 */
1269 0x8003, /* È - 200 */
1270 0x8003, /* É - 201 */
1271 0x8003, /* Ê - 202 */
1272 0x8003, /* Ë - 203 */
1273 0x8003, /* Ì - 204 */
1274 0x8003, /* Í - 205 */
1275 0x8003, /* Î - 206 */
1276 0x8003, /* Ï - 207 */
1277 0x8000, /* Ð - 208 */
1278 0x8003, /* Ñ - 209 */
1279 0x8003, /* Ò - 210 */
1280 0x8003, /* Ó - 211 */
1281 0x8003, /* Ô - 212 */
1282 0x8003, /* Õ - 213 */
1283 0x8003, /* Ö - 214 */
1284 0x0008, /* × - 215 */
1285 0x8003, /* Ø - 216 */
1286 0x8003, /* Ù - 217 */
1287 0x8003, /* Ú - 218 */
1288 0x8003, /* Û - 219 */
1289 0x8003, /* Ü - 220 */
1290 0x8003, /* Ý - 221 */
1291 0x8000, /* Þ - 222 */
1292 0x8000, /* ß - 223 */
1293 0x8003, /* à - 224 */
1294 0x8003, /* á - 225 */
1295 0x8003, /* â - 226 */
1296 0x8003, /* ã - 227 */
1297 0x8003, /* ä - 228 */
1298 0x8003, /* å - 229 */
1299 0x8000, /* æ - 230 */
1300 0x8003, /* ç - 231 */
1301 0x8003, /* è - 232 */
1302 0x8003, /* é - 233 */
1303 0x8003, /* ê - 234 */
1304 0x8003, /* ë - 235 */
1305 0x8003, /* ì - 236 */
1306 0x8003, /* í - 237 */
1307 0x8003, /* î - 238 */
1308 0x8003, /* ï - 239 */
1309 0x8000, /* ð - 240 */
1310 0x8003, /* ñ - 241 */
1311 0x8003, /* ò - 242 */
1312 0x8003, /* ó - 243 */
1313 0x8003, /* ô - 244 */
1314 0x8003, /* õ - 245 */
1315 0x8003, /* ö - 246 */
1316 0x0008, /* ÷ - 247 */
1317 0x8003, /* ø - 248 */
1318 0x8003, /* ù - 249 */
1319 0x8003, /* ú - 250 */
1320 0x8003, /* û - 251 */
1321 0x8003, /* ü - 252 */
1322 0x8003, /* ý - 253 */
1323 0x8000, /* þ - 254 */
1324 0x8003 /* ÿ - 255 */
1327 /******************************************************************************
1328 * GetStringTypeA [KERNEL32.396]
1330 BOOL WINAPI GetStringTypeA(LCID locale,DWORD dwInfoType,LPCSTR src,
1331 INT cchSrc,LPWORD chartype)
1333 return GetStringTypeExA(locale,dwInfoType,src,cchSrc,chartype);
1336 /******************************************************************************
1337 * GetStringTypeExA [KERNEL32.397]
1339 * FIXME: Ignores the locale.
1341 BOOL WINAPI GetStringTypeExA(LCID locale,DWORD dwInfoType,LPCSTR src,
1342 INT cchSrc,LPWORD chartype)
1346 if ((src==NULL) || (chartype==NULL) || (src==(LPSTR)chartype))
1348 SetLastError(ERROR_INVALID_PARAMETER);
1353 cchSrc=strlen(src)+1;
1355 switch (dwInfoType) {
1357 for (i=0;i<cchSrc;i++)
1360 if (isdigit(src[i])) chartype[i]|=C1_DIGIT;
1361 if (isalpha(src[i])) chartype[i]|=C1_ALPHA;
1362 if (islower(src[i])) chartype[i]|=C1_LOWER;
1363 if (isupper(src[i])) chartype[i]|=C1_UPPER;
1364 if (isspace(src[i])) chartype[i]|=C1_SPACE;
1365 if (ispunct(src[i])) chartype[i]|=C1_PUNCT;
1366 if (iscntrl(src[i])) chartype[i]|=C1_CNTRL;
1367 /* FIXME: isblank() is a GNU extension */
1368 /* if (isblank(src[i])) chartype[i]|=C1_BLANK; */
1369 if ((src[i] == ' ') || (src[i] == '\t')) chartype[i]|=C1_BLANK;
1375 for (i=0;i<cchSrc;i++)
1377 chartype[i]=(WORD)CT_CType2_LUT[i];
1382 for (i=0;i<cchSrc;i++)
1384 chartype[i]=OLE2NLS_CT_CType3_LUT[i];
1389 ERR("Unknown dwInfoType:%ld\n",dwInfoType);
1394 /***********************************************************************
1395 * VerLanguageNameA [KERNEL32.709][VERSION.9]
1397 DWORD WINAPI VerLanguageNameA( UINT wLang, LPSTR szLang, UINT nSize )
1402 return GetLocaleInfoA(MAKELCID(wLang, SORT_DEFAULT), LOCALE_SENGLANGUAGE, szLang, nSize);
1405 /***********************************************************************
1406 * VerLanguageNameW [KERNEL32.710][VERSION.10]
1408 DWORD WINAPI VerLanguageNameW( UINT wLang, LPWSTR szLang, UINT nSize )
1413 return GetLocaleInfoW(MAKELCID(wLang, SORT_DEFAULT), LOCALE_SENGLANGUAGE, szLang, nSize);
1417 static const unsigned char LCM_Unicode_LUT[] = {
1450 7 , 28, /* ! - 33 */
1451 7 , 29, /* " - 34 */ /* " */
1452 7 , 31, /* # - 35 */
1453 7 , 33, /* $ - 36 */
1454 7 , 35, /* % - 37 */
1455 7 , 37, /* & - 38 */
1456 6 , 128, /* ' - 39 */
1457 7 , 39, /* ( - 40 */
1458 7 , 42, /* ) - 41 */
1459 7 , 45, /* * - 42 */
1461 7 , 47, /* , - 44 */
1462 6 , 130, /* - - 45 */
1463 7 , 51, /* . - 46 */
1464 7 , 53, /* / - 47 */
1465 12 , 3, /* 0 - 48 */
1466 12 , 33, /* 1 - 49 */
1467 12 , 51, /* 2 - 50 */
1468 12 , 70, /* 3 - 51 */
1469 12 , 88, /* 4 - 52 */
1470 12 , 106, /* 5 - 53 */
1471 12 , 125, /* 6 - 54 */
1472 12 , 144, /* 7 - 55 */
1473 12 , 162, /* 8 - 56 */
1474 12 , 180, /* 9 - 57 */
1475 7 , 55, /* : - 58 */
1476 7 , 58, /* ; - 59 */
1477 8 , 14, /* < - 60 */
1478 8 , 18, /* = - 61 */
1479 8 , 20, /* > - 62 */
1480 7 , 60, /* ? - 63 */
1481 7 , 62, /* @ - 64 */
1482 14 , 2, /* A - 65 */
1483 14 , 9, /* B - 66 */
1484 14 , 10, /* C - 67 */
1485 14 , 26, /* D - 68 */
1486 14 , 33, /* E - 69 */
1487 14 , 35, /* F - 70 */
1488 14 , 37, /* G - 71 */
1489 14 , 44, /* H - 72 */
1490 14 , 50, /* I - 73 */
1491 14 , 53, /* J - 74 */
1492 14 , 54, /* K - 75 */
1493 14 , 72, /* L - 76 */
1494 14 , 81, /* M - 77 */
1495 14 , 112, /* N - 78 */
1496 14 , 124, /* O - 79 */
1497 14 , 126, /* P - 80 */
1498 14 , 137, /* Q - 81 */
1499 14 , 138, /* R - 82 */
1500 14 , 145, /* S - 83 */
1501 14 , 153, /* T - 84 */
1502 14 , 159, /* U - 85 */
1503 14 , 162, /* V - 86 */
1504 14 , 164, /* W - 87 */
1505 14 , 166, /* X - 88 */
1506 14 , 167, /* Y - 89 */
1507 14 , 169, /* Z - 90 */
1508 7 , 63, /* [ - 91 */
1509 7 , 65, /* \ - 92 */
1510 7 , 66, /* ] - 93 */
1511 7 , 67, /* ^ - 94 */
1512 7 , 68, /* _ - 95 */
1513 7 , 72, /* ` - 96 */
1514 14 , 2, /* a - 97 */
1515 14 , 9, /* b - 98 */
1516 14 , 10, /* c - 99 */
1517 14 , 26, /* d - 100 */
1518 14 , 33, /* e - 101 */
1519 14 , 35, /* f - 102 */
1520 14 , 37, /* g - 103 */
1521 14 , 44, /* h - 104 */
1522 14 , 50, /* i - 105 */
1523 14 , 53, /* j - 106 */
1524 14 , 54, /* k - 107 */
1525 14 , 72, /* l - 108 */
1526 14 , 81, /* m - 109 */
1527 14 , 112, /* n - 110 */
1528 14 , 124, /* o - 111 */
1529 14 , 126, /* p - 112 */
1530 14 , 137, /* q - 113 */
1531 14 , 138, /* r - 114 */
1532 14 , 145, /* s - 115 */
1533 14 , 153, /* t - 116 */
1534 14 , 159, /* u - 117 */
1535 14 , 162, /* v - 118 */
1536 14 , 164, /* w - 119 */
1537 14 , 166, /* x - 120 */
1538 14 , 167, /* y - 121 */
1539 14 , 169, /* z - 122 */
1540 7 , 74, /* { - 123 */
1541 7 , 76, /* | - 124 */
1542 7 , 78, /* } - 125 */
1543 7 , 80, /* ~ - 126 */
1544 6 , 29, /*
\7f - 127 */
1545 6 , 30, /*
\80 - 128 */
1546 6 , 31, /*
\81 - 129 */
1547 7 , 123, /*
\82 - 130 */
1548 14 , 35, /*
\83 - 131 */
1549 7 , 127, /*
\84 - 132 */
1550 10 , 21, /*
\85 - 133 */
1551 10 , 15, /*
\86 - 134 */
1552 10 , 16, /*
\87 - 135 */
1553 7 , 67, /*
\88 - 136 */
1554 10 , 22, /*
\89 - 137 */
1555 14 , 145, /*
\8a - 138 */
1556 7 , 136, /*
\8b - 139 */
1557 14 + 16 , 124, /*
\8c - 140 */
1558 6 , 43, /*
\8d - 141 */
1559 6 , 44, /*
\8e - 142 */
1560 6 , 45, /*
\8f - 143 */
1561 6 , 46, /*
\90 - 144 */
1562 7 , 121, /*
\91 - 145 */
1563 7 , 122, /*
\92 - 146 */
1564 7 , 125, /*
\93 - 147 */
1565 7 , 126, /*
\94 - 148 */
1566 10 , 17, /*
\95 - 149 */
1567 6 , 137, /*
\96 - 150 */
1568 6 , 139, /*
\97 - 151 */
1569 7 , 93, /*
\98 - 152 */
1570 14 , 156, /*
\99 - 153 */
1571 14 , 145, /*
\9a - 154 */
1572 7 , 137, /*
\9b - 155 */
1573 14 + 16 , 124, /*
\9c - 156 */
1574 6 , 59, /*
\9d - 157 */
1575 6 , 60, /*
\9e - 158 */
1576 14 , 167, /*
\9f - 159 */
1578 7 , 81, /* ¡ - 161 */
1579 10 , 2, /* ¢ - 162 */
1580 10 , 3, /* £ - 163 */
1581 10 , 4, /* ¤ - 164 */
1582 10 , 5, /* ¥ - 165 */
1583 7 , 82, /* ¦ - 166 */
1584 10 , 6, /* § - 167 */
1585 7 , 83, /* ¨ - 168 */
1586 10 , 7, /* © - 169 */
1587 14 , 2, /* ª - 170 */
1588 8 , 24, /* « - 171 */
1589 10 , 8, /* ¬ - 172 */
1590 6 , 131, /* - 173 */
1591 10 , 9, /* ® - 174 */
1592 7 , 84, /* ¯ - 175 */
1593 10 , 10, /* ° - 176 */
1594 8 , 23, /* ± - 177 */
1595 12 , 51, /* ² - 178 */
1596 12 , 70, /* ³ - 179 */
1597 7 , 85, /* ´ - 180 */
1598 10 , 11, /* µ - 181 */
1599 10 , 12, /* ¶ - 182 */
1600 10 , 13, /* · - 183 */
1601 7 , 86, /* ¸ - 184 */
1602 12 , 33, /* ¹ - 185 */
1603 14 , 124, /* º - 186 */
1604 8 , 26, /* » - 187 */
1605 12 , 21, /* ¼ - 188 */
1606 12 , 25, /* ½ - 189 */
1607 12 , 29, /* ¾ - 190 */
1608 7 , 87, /* ¿ - 191 */
1609 14 , 2, /* À - 192 */
1610 14 , 2, /* Á - 193 */
1611 14 , 2, /* Â - 194 */
1612 14 , 2, /* Ã - 195 */
1613 14 , 2, /* Ä - 196 */
1614 14 , 2, /* Å - 197 */
1615 14 + 16 , 2, /* Æ - 198 */
1616 14 , 10, /* Ç - 199 */
1617 14 , 33, /* È - 200 */
1618 14 , 33, /* É - 201 */
1619 14 , 33, /* Ê - 202 */
1620 14 , 33, /* Ë - 203 */
1621 14 , 50, /* Ì - 204 */
1622 14 , 50, /* Í - 205 */
1623 14 , 50, /* Î - 206 */
1624 14 , 50, /* Ï - 207 */
1625 14 , 26, /* Ð - 208 */
1626 14 , 112, /* Ñ - 209 */
1627 14 , 124, /* Ò - 210 */
1628 14 , 124, /* Ó - 211 */
1629 14 , 124, /* Ô - 212 */
1630 14 , 124, /* Õ - 213 */
1631 14 , 124, /* Ö - 214 */
1632 8 , 28, /* × - 215 */
1633 14 , 124, /* Ø - 216 */
1634 14 , 159, /* Ù - 217 */
1635 14 , 159, /* Ú - 218 */
1636 14 , 159, /* Û - 219 */
1637 14 , 159, /* Ü - 220 */
1638 14 , 167, /* Ý - 221 */
1639 14 + 32 , 153, /* Þ - 222 */
1640 14 + 48 , 145, /* ß - 223 */
1641 14 , 2, /* à - 224 */
1642 14 , 2, /* á - 225 */
1643 14 , 2, /* â - 226 */
1644 14 , 2, /* ã - 227 */
1645 14 , 2, /* ä - 228 */
1646 14 , 2, /* å - 229 */
1647 14 + 16 , 2, /* æ - 230 */
1648 14 , 10, /* ç - 231 */
1649 14 , 33, /* è - 232 */
1650 14 , 33, /* é - 233 */
1651 14 , 33, /* ê - 234 */
1652 14 , 33, /* ë - 235 */
1653 14 , 50, /* ì - 236 */
1654 14 , 50, /* í - 237 */
1655 14 , 50, /* î - 238 */
1656 14 , 50, /* ï - 239 */
1657 14 , 26, /* ð - 240 */
1658 14 , 112, /* ñ - 241 */
1659 14 , 124, /* ò - 242 */
1660 14 , 124, /* ó - 243 */
1661 14 , 124, /* ô - 244 */
1662 14 , 124, /* õ - 245 */
1663 14 , 124, /* ö - 246 */
1664 8 , 29, /* ÷ - 247 */
1665 14 , 124, /* ø - 248 */
1666 14 , 159, /* ù - 249 */
1667 14 , 159, /* ú - 250 */
1668 14 , 159, /* û - 251 */
1669 14 , 159, /* ü - 252 */
1670 14 , 167, /* ý - 253 */
1671 14 + 32 , 153, /* þ - 254 */
1672 14 , 167 /* ÿ - 255 */ };
1674 static const unsigned char LCM_Unicode_LUT_2[] = { 33, 44, 145 };
1676 #define LCM_Diacritic_Start 131
1678 static const unsigned char LCM_Diacritic_LUT[] = {
1679 123, /*
\83 - 131 */
1806 /******************************************************************************
1807 * OLE2NLS_isPunctuation [INTERNAL]
1809 static int OLE2NLS_isPunctuation(unsigned char c)
1811 /* "punctuation character" in this context is a character which is
1812 considered "less important" during word sort comparison.
1813 See LCMapString implementation for the precise definition
1814 of "less important". */
1816 return (LCM_Unicode_LUT[-2+2*c]==6);
1819 /******************************************************************************
1820 * OLE2NLS_isNonSpacing [INTERNAL]
1822 static int OLE2NLS_isNonSpacing(unsigned char c)
1824 /* This function is used by LCMapStringA. Characters
1825 for which it returns true are ignored when mapping a
1826 string with NORM_IGNORENONSPACE */
1827 return ((c==136) || (c==170) || (c==186));
1830 /******************************************************************************
1831 * OLE2NLS_isSymbol [INTERNAL]
1833 static int OLE2NLS_isSymbol(unsigned char c)
1835 /* This function is used by LCMapStringA. Characters
1836 for which it returns true are ignored when mapping a
1837 string with NORM_IGNORESYMBOLS */
1838 return ( (c!=0) && !IsCharAlphaNumericA(c) );
1841 /******************************************************************************
1842 * identity [Internal]
1844 static int identity(int c)
1849 /*************************************************************************
1850 * LCMapStringA [KERNEL32.492]
1852 * Convert a string, or generate a sort key from it.
1854 * If (mapflags & LCMAP_SORTKEY), the function will generate
1855 * a sort key for the source string. Else, it will convert it
1856 * accordingly to the flags LCMAP_UPPERCASE, LCMAP_LOWERCASE,...
1860 * Success : length of the result string.
1863 * If called with scrlen = -1, the function will compute the length
1864 * of the 0-terminated string strsrc by itself.
1866 * If called with dstlen = 0, returns the buffer length that
1867 * would be required.
1869 * NORM_IGNOREWIDTH means to compare ASCII and wide characters
1870 * as if they are equal.
1871 * In the only code page implemented so far, there may not be
1872 * wide characters in strings passed to LCMapStringA,
1873 * so there is nothing to be done for this flag.
1875 INT WINAPI LCMapStringA(
1876 LCID lcid, /* [in] locale identifier created with MAKELCID;
1877 LOCALE_SYSTEM_DEFAULT and LOCALE_USER_DEFAULT are
1878 predefined values. */
1879 DWORD mapflags, /* [in] flags */
1880 LPCSTR srcstr, /* [in] source buffer */
1881 INT srclen, /* [in] source length */
1882 LPSTR dststr, /* [out] destination buffer */
1883 INT dstlen) /* [in] destination buffer length */
1887 TRACE("(0x%04lx,0x%08lx,%s,%d,%p,%d)\n",
1888 lcid,mapflags,srcstr,srclen,dststr,dstlen);
1890 if ( ((dstlen!=0) && (dststr==NULL)) || (srcstr==NULL) )
1892 ERR("(src=%s,dest=%s): Invalid NULL string\n", srcstr, dststr);
1893 SetLastError(ERROR_INVALID_PARAMETER);
1897 srclen = strlen(srcstr) + 1 ; /* (include final '\0') */
1899 #define LCMAPSTRINGA_SUPPORTED_FLAGS (LCMAP_UPPERCASE | \
1903 NORM_IGNORENONSPACE | \
1905 NORM_IGNOREWIDTH | \
1906 NORM_IGNOREKANATYPE)
1907 /* FIXME: as long as we don't support Kanakana nor Hirigana
1908 * characters, we can support NORM_IGNOREKANATYPE
1910 if (mapflags & ~LCMAPSTRINGA_SUPPORTED_FLAGS)
1912 FIXME("(0x%04lx,0x%08lx,%p,%d,%p,%d): "
1913 "unimplemented flags: 0x%08lx\n",
1920 mapflags & ~LCMAPSTRINGA_SUPPORTED_FLAGS
1924 if ( !(mapflags & LCMAP_SORTKEY) )
1927 int (*f)(int) = identity;
1928 int flag_ignorenonspace = mapflags & NORM_IGNORENONSPACE;
1929 int flag_ignoresymbols = mapflags & NORM_IGNORESYMBOLS;
1931 if (flag_ignorenonspace || flag_ignoresymbols)
1933 /* For some values of mapflags, the length of the resulting
1934 string is not known at this point. Windows does map the string
1935 and does not SetLastError ERROR_INSUFFICIENT_BUFFER in
1939 /* Compute required length */
1940 for (i=j=0; i < srclen; i++)
1942 if ( !(flag_ignorenonspace && OLE2NLS_isNonSpacing(srcstr[i]))
1943 && !(flag_ignoresymbols && OLE2NLS_isSymbol(srcstr[i])) )
1955 SetLastError(ERROR_INSUFFICIENT_BUFFER);
1959 if (mapflags & LCMAP_UPPERCASE)
1961 else if (mapflags & LCMAP_LOWERCASE)
1963 /* FIXME: NORM_IGNORENONSPACE requires another conversion */
1964 for (i=j=0; (i<srclen) && (j<dstlen) ; i++)
1966 if ( !(flag_ignorenonspace && OLE2NLS_isNonSpacing(srcstr[i]))
1967 && !(flag_ignoresymbols && OLE2NLS_isSymbol(srcstr[i])) )
1969 dststr[j] = (CHAR) f(srcstr[i]);
1976 /* FIXME: This function completely ignores the "lcid" parameter. */
1977 /* else ... (mapflags & LCMAP_SORTKEY) */
1981 int diacritic_len=0;
1982 int delayed_punctuation_len=0;
1983 char *case_component;
1984 char *diacritic_component;
1985 char *delayed_punctuation_component;
1987 int flag_stringsort = mapflags & SORT_STRINGSORT;
1989 /* compute how much room we will need */
1990 for (i=0;i<srclen;i++)
1993 unsigned char source_char = srcstr[i];
1994 if (source_char!='\0')
1996 if (flag_stringsort || !OLE2NLS_isPunctuation(source_char))
1999 if ( LCM_Unicode_LUT[-2+2*source_char] & ~15 )
2000 unicode_len++; /* double letter */
2004 delayed_punctuation_len++;
2008 if (isupper(source_char))
2009 case_len=unicode_len;
2011 ofs = source_char - LCM_Diacritic_Start;
2012 if ((ofs>=0) && (LCM_Diacritic_LUT[ofs]!=2))
2013 diacritic_len=unicode_len;
2016 if (mapflags & NORM_IGNORECASE)
2018 if (mapflags & NORM_IGNORENONSPACE)
2021 room = 2 * unicode_len /* "unicode" component */
2022 + diacritic_len /* "diacritic" component */
2023 + case_len /* "case" component */
2024 + 4 * delayed_punctuation_len /* punctuation in word sort mode */
2025 + 4 /* four '\1' separators */
2026 + 1 ; /* terminal '\0' */
2029 else if (dstlen<room)
2031 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2035 /*FIXME the Pointercheck should not be nessesary */
2036 if (IsBadWritePtr (dststr,room))
2037 { ERR("bad destination buffer (dststr) : %p,%d\n",dststr,dstlen);
2038 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2042 /* locate each component, write separators */
2043 diacritic_component = dststr + 2*unicode_len ;
2044 *diacritic_component++ = '\1';
2045 case_component = diacritic_component + diacritic_len ;
2046 *case_component++ = '\1';
2047 delayed_punctuation_component = case_component + case_len ;
2048 *delayed_punctuation_component++ = '\1';
2049 *delayed_punctuation_component++ = '\1';
2051 /* read source string char by char, write
2052 corresponding weight in each component. */
2053 for (i=0,count=0;i<srclen;i++)
2055 unsigned char source_char=srcstr[i];
2056 if (source_char!='\0')
2059 type = LCM_Unicode_LUT[-2+2*source_char];
2060 longcode = type >> 4;
2062 if (!flag_stringsort && OLE2NLS_isPunctuation(source_char))
2064 WORD encrypted_location = (1<<15) + 7 + 4*count;
2065 *delayed_punctuation_component++ = (unsigned char) (encrypted_location>>8);
2066 *delayed_punctuation_component++ = (unsigned char) (encrypted_location&255);
2067 /* big-endian is used here because it lets string comparison be
2068 compatible with numerical comparison */
2070 *delayed_punctuation_component++ = type;
2071 *delayed_punctuation_component++ = LCM_Unicode_LUT[-1+2*source_char];
2072 /* assumption : a punctuation character is never a
2073 double or accented letter */
2077 dststr[2*count] = type;
2078 dststr[2*count+1] = LCM_Unicode_LUT[-1+2*source_char];
2082 case_component[count] = ( isupper(source_char) ? 18 : 2 ) ;
2083 if (count<diacritic_len)
2084 diacritic_component[count] = 2; /* assumption: a double letter
2085 is never accented */
2088 dststr[2*count] = type;
2089 dststr[2*count+1] = *(LCM_Unicode_LUT_2 - 1 + longcode);
2090 /* 16 in the first column of LCM_Unicode_LUT --> longcode = 1
2091 32 in the first column of LCM_Unicode_LUT --> longcode = 2
2092 48 in the first column of LCM_Unicode_LUT --> longcode = 3 */
2096 case_component[count] = ( isupper(source_char) ? 18 : 2 ) ;
2097 if (count<diacritic_len)
2099 int ofs = source_char - LCM_Diacritic_Start;
2100 diacritic_component[count] = (ofs>=0 ? LCM_Diacritic_LUT[ofs] : 2);
2106 dststr[room-1] = '\0';
2111 /*************************************************************************
2112 * LCMapStringW [KERNEL32.493]
2114 * Convert a string, or generate a sort key from it.
2118 * See LCMapStringA for documentation
2120 INT WINAPI LCMapStringW(
2121 LCID lcid,DWORD mapflags,LPCWSTR srcstr,INT srclen,LPWSTR dststr,
2126 TRACE("(0x%04lx,0x%08lx,%p,%d,%p,%d)\n",
2127 lcid, mapflags, srcstr, srclen, dststr, dstlen);
2129 if ( ((dstlen!=0) && (dststr==NULL)) || (srcstr==NULL) )
2131 ERR("(src=%p,dst=%p): Invalid NULL string\n", srcstr, dststr);
2132 SetLastError(ERROR_INVALID_PARAMETER);
2136 srclen = strlenW(srcstr)+1;
2138 /* FIXME: Both this function and it's companion LCMapStringA()
2139 * completely ignore the "lcid" parameter. In place of the "lcid"
2140 * parameter the application must set the "LC_COLLATE" or "LC_ALL"
2141 * environment variable prior to invoking this function. */
2142 if (mapflags & LCMAP_SORTKEY)
2144 /* Possible values of LC_COLLATE. */
2145 char *lc_collate_default = 0; /* value prior to this function */
2146 char *lc_collate_env = 0; /* value retrieved from the environment */
2148 /* General purpose index into strings of any type. */
2151 /* Lengths of various strings where the length is measured in
2152 * wide characters for wide character strings and in bytes for
2153 * native strings. The lengths include the NULL terminator. */
2154 size_t returned_len = 0;
2155 size_t src_native_len = 0;
2156 size_t dst_native_len = 0;
2157 size_t dststr_libc_len = 0;
2159 /* Native (character set determined by locale) versions of the
2160 * strings source and destination strings. */
2161 LPSTR src_native = 0;
2162 LPSTR dst_native = 0;
2164 /* Version of the source and destination strings using the
2165 * "wchar_t" Unicode data type needed by various libc functions. */
2166 wchar_t *srcstr_libc = 0;
2167 wchar_t *dststr_libc = 0;
2169 if(!(srcstr_libc = (wchar_t *)HeapAlloc(GetProcessHeap(), 0,
2170 srclen * sizeof(wchar_t))))
2172 ERR("Unable to allocate %d bytes for srcstr_libc\n",
2173 srclen * sizeof(wchar_t));
2174 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
2178 /* Convert source string to a libc Unicode string. */
2179 for(str_idx = 0; str_idx < srclen; str_idx++)
2181 srcstr_libc[str_idx] = srcstr[str_idx];
2184 /* src_native should contain at most 3 bytes for each
2185 * multibyte characters in the original srcstr string. */
2186 src_native_len = 3 * srclen;
2187 if(!(src_native = (LPSTR)HeapAlloc(GetProcessHeap(), 0,
2190 ERR("Unable to allocate %d bytes for src_native\n", src_native_len);
2191 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
2192 if(srcstr_libc) HeapFree(GetProcessHeap(), 0, srcstr_libc);
2196 /* FIXME: Prior to to setting the LC_COLLATE locale category the
2197 * current value is backed up so it can be restored after the
2198 * last LC_COLLATE sensitive function returns.
2200 * Even though the locale is adjusted for a minimum amount of
2201 * time a race condition exists where other threads may be
2202 * affected if they invoke LC_COLLATE sensitive functions. One
2203 * possible solution is to wrap all LC_COLLATE sensitive Wine
2204 * functions, like LCMapStringW(), in a mutex.
2206 * Another enhancement to the following would be to set the
2207 * LC_COLLATE locale category as a function of the "lcid"
2208 * parameter instead of the "LC_COLLATE" environment variable. */
2209 if(!(lc_collate_default = setlocale(LC_COLLATE, NULL)))
2211 ERR("Unable to query the LC_COLLATE catagory\n");
2212 SetLastError(ERROR_INVALID_PARAMETER);
2213 if(srcstr_libc) HeapFree(GetProcessHeap(), 0, srcstr_libc);
2214 if(src_native) HeapFree(GetProcessHeap(), 0, src_native);
2218 if(!(lc_collate_env = setlocale(LC_COLLATE, "")))
2220 ERR("Unable to inherit the LC_COLLATE locale category from the "
2221 "environment. The \"LC_COLLATE\" environment variable is "
2222 "\"%s\".\n", getenv("LC_COLLATE") ?
2223 getenv("LC_COLLATE") : "<unset>");
2224 SetLastError(ERROR_INVALID_PARAMETER);
2225 if(srcstr_libc) HeapFree(GetProcessHeap(), 0, srcstr_libc);
2226 if(src_native) HeapFree(GetProcessHeap(), 0, src_native);
2230 TRACE("lc_collate_default = %s\n", lc_collate_default);
2231 TRACE("lc_collate_env = %s\n", lc_collate_env);
2233 /* Convert the libc Unicode string to a native multibyte character
2235 returned_len = wcstombs(src_native, srcstr_libc, src_native_len) + 1;
2236 if(returned_len == 0)
2238 LPSTR srcstr_ascii = (LPSTR)HEAP_strdupWtoA(GetProcessHeap(),
2240 ERR("wcstombs failed. The string specified (%s) may contains an "
2241 "invalid character.\n", srcstr_ascii);
2242 SetLastError(ERROR_INVALID_PARAMETER);
2243 if(srcstr_ascii) HeapFree(GetProcessHeap(), 0, srcstr_ascii);
2244 if(srcstr_libc) HeapFree(GetProcessHeap(), 0, srcstr_libc);
2245 if(src_native) HeapFree(GetProcessHeap(), 0, src_native);
2246 setlocale(LC_COLLATE, lc_collate_default);
2249 else if(returned_len > src_native_len)
2251 src_native[src_native_len - 1] = 0;
2252 ERR("wcstombs returned a string (%s) that was longer (%d bytes) "
2253 "than expected (%d bytes).\n", src_native, returned_len,
2256 /* Since this is an internal error I'm not sure what the correct
2258 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
2260 if(srcstr_libc) HeapFree(GetProcessHeap(), 0, srcstr_libc);
2261 if(src_native) HeapFree(GetProcessHeap(), 0, src_native);
2262 setlocale(LC_COLLATE, lc_collate_default);
2265 src_native_len = returned_len;
2267 TRACE("src_native = %s src_native_len = %d\n",
2268 src_native, src_native_len);
2270 /* dst_native seems to contain at most 4 bytes for each byte in
2271 * the original src_native string. Change if need be since this
2272 * isn't documented by the strxfrm() man page. */
2273 dst_native_len = 4 * src_native_len;
2274 if(!(dst_native = (LPSTR)HeapAlloc(GetProcessHeap(), 0, dst_native_len)))
2276 ERR("Unable to allocate %d bytes for dst_native\n", dst_native_len);
2277 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
2278 if(srcstr_libc) HeapFree(GetProcessHeap(), 0, srcstr_libc);
2279 if(src_native) HeapFree(GetProcessHeap(), 0, src_native);
2280 setlocale(LC_COLLATE, lc_collate_default);
2284 /* The actual translation is done by the following call to
2285 * strxfrm(). The surrounding code could have been simplified
2286 * by calling wcsxfrm() instead except that wcsxfrm() is not
2287 * available on older Linux systems (RedHat 4.1 with
2290 * Also, it is possible that the translation could be done by
2291 * various tables as it is done in LCMapStringA(). However, I'm
2292 * not sure what those tables are. */
2293 returned_len = strxfrm(dst_native, src_native, dst_native_len) + 1;
2295 if(returned_len > dst_native_len)
2297 dst_native[dst_native_len - 1] = 0;
2298 ERR("strxfrm returned a string (%s) that was longer (%d bytes) "
2299 "than expected (%d bytes).\n", dst_native, returned_len,
2302 /* Since this is an internal error I'm not sure what the correct
2304 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
2306 if(srcstr_libc) HeapFree(GetProcessHeap(), 0, srcstr_libc);
2307 if(src_native) HeapFree(GetProcessHeap(), 0, src_native);
2308 if(dst_native) HeapFree(GetProcessHeap(), 0, dst_native);
2309 setlocale(LC_COLLATE, lc_collate_default);
2312 dst_native_len = returned_len;
2314 TRACE("dst_native = %s dst_native_len = %d\n",
2315 dst_native, dst_native_len);
2317 dststr_libc_len = dst_native_len;
2318 if(!(dststr_libc = (wchar_t *)HeapAlloc(GetProcessHeap(), 0,
2319 dststr_libc_len * sizeof(wchar_t))))
2321 ERR("Unable to allocate %d bytes for dststr_libc\n",
2322 dststr_libc_len * sizeof(wchar_t));
2323 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
2324 if(srcstr_libc) HeapFree(GetProcessHeap(), 0, srcstr_libc);
2325 if(src_native) HeapFree(GetProcessHeap(), 0, src_native);
2326 if(dst_native) HeapFree(GetProcessHeap(), 0, dst_native);
2327 setlocale(LC_COLLATE, lc_collate_default);
2331 /* Convert the native multibyte string to a libc Unicode string. */
2332 returned_len = mbstowcs(dststr_libc, dst_native, dst_native_len) + 1;
2334 /* Restore LC_COLLATE now that the last LC_COLLATE sensitive
2335 * function has returned. */
2336 setlocale(LC_COLLATE, lc_collate_default);
2338 if(returned_len == 0)
2340 ERR("mbstowcs failed. The native version of the translated string "
2341 "(%s) may contain an invalid character.\n", dst_native);
2342 SetLastError(ERROR_INVALID_PARAMETER);
2343 if(srcstr_libc) HeapFree(GetProcessHeap(), 0, srcstr_libc);
2344 if(src_native) HeapFree(GetProcessHeap(), 0, src_native);
2345 if(dst_native) HeapFree(GetProcessHeap(), 0, dst_native);
2346 if(dststr_libc) HeapFree(GetProcessHeap(), 0, dststr_libc);
2351 if(returned_len > dstlen)
2353 ERR("mbstowcs returned a string that was longer (%d chars) "
2354 "than the buffer provided (%d chars).\n", returned_len,
2356 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2357 if(srcstr_libc) HeapFree(GetProcessHeap(), 0, srcstr_libc);
2358 if(src_native) HeapFree(GetProcessHeap(), 0, src_native);
2359 if(dst_native) HeapFree(GetProcessHeap(), 0, dst_native);
2360 if(dststr_libc) HeapFree(GetProcessHeap(), 0, dststr_libc);
2363 dstlen = returned_len;
2365 /* Convert a libc Unicode string to the destination string. */
2366 for(str_idx = 0; str_idx < dstlen; str_idx++)
2368 dststr[str_idx] = dststr_libc[str_idx];
2370 TRACE("1st 4 int sized chunks of dststr = %x %x %x %x\n",
2371 *(((int *)dststr) + 0),
2372 *(((int *)dststr) + 1),
2373 *(((int *)dststr) + 2),
2374 *(((int *)dststr) + 3));
2378 dstlen = returned_len;
2380 TRACE("dstlen (return) = %d\n", dstlen);
2381 if(srcstr_libc) HeapFree(GetProcessHeap(), 0, srcstr_libc);
2382 if(src_native) HeapFree(GetProcessHeap(), 0, src_native);
2383 if(dst_native) HeapFree(GetProcessHeap(), 0, dst_native);
2384 if(dststr_libc) HeapFree(GetProcessHeap(), 0, dststr_libc);
2389 int (*f)(int)=identity;
2395 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2399 if (mapflags & LCMAP_UPPERCASE)
2401 else if (mapflags & LCMAP_LOWERCASE)
2403 for (i=0; i < srclen; i++)
2404 dststr[i] = (WCHAR) f(srcstr[i]);
2410 /***********************************************************************
2411 * OLE2NLS_EstimateMappingLength
2413 * Estimates the number of characters required to hold the string
2414 * computed by LCMapStringA.
2416 * The size is always over-estimated, with a fixed limit on the
2417 * amount of estimation error.
2419 * Note that len == -1 is not permitted.
2421 static inline int OLE2NLS_EstimateMappingLength(LCID lcid, DWORD dwMapFlags,
2422 LPCSTR str, DWORD len)
2424 /* Estimate only for small strings to keep the estimation error from
2425 * becoming too large. */
2426 if (len < 128) return len * 8 + 5;
2427 else return LCMapStringA(lcid, dwMapFlags, str, len, NULL, 0);
2430 /******************************************************************************
2431 * CompareStringA [KERNEL32.143]
2432 * Compares two strings using locale
2436 * success: CSTR_LESS_THAN, CSTR_EQUAL, CSTR_GREATER_THAN
2441 * Defaults to a word sort, but uses a string sort if
2442 * SORT_STRINGSORT is set.
2443 * Calls SetLastError for ERROR_INVALID_FLAGS, ERROR_INVALID_PARAMETER.
2447 * This implementation ignores the locale
2451 * Quite inefficient.
2453 UINT WINAPI CompareStringA(
2454 DWORD lcid, /* [in] locale ID */
2455 DWORD fdwStyle, /* [in] comparison-style options */
2456 LPCSTR s1, /* [in] first string */
2457 DWORD l1, /* [in] length of first string */
2458 LPCSTR s2, /* [in] second string */
2459 DWORD l2) /* [in] length of second string */
2461 int mapstring_flags;
2465 TRACE("%s and %s\n",
2466 debugstr_a (s1), debugstr_a (s2));
2468 if ( (s1==NULL) || (s2==NULL) )
2470 ERR("(s1=%s,s2=%s): Invalid NULL string\n", s1, s2);
2471 SetLastError(ERROR_INVALID_PARAMETER);
2475 if(fdwStyle & NORM_IGNORESYMBOLS)
2476 FIXME("IGNORESYMBOLS not supported\n");
2478 if (l1 == -1) l1 = strlen(s1);
2479 if (l2 == -1) l2 = strlen(s2);
2481 mapstring_flags = LCMAP_SORTKEY | fdwStyle ;
2482 len1 = OLE2NLS_EstimateMappingLength(lcid, mapstring_flags, s1, l1);
2483 len2 = OLE2NLS_EstimateMappingLength(lcid, mapstring_flags, s2, l2);
2485 if ((len1==0)||(len2==0))
2486 return 0; /* something wrong happened */
2488 sk1 = (LPSTR)HeapAlloc(GetProcessHeap(), 0, len1 + len2);
2490 if ( (!LCMapStringA(lcid,mapstring_flags,s1,l1,sk1,len1))
2491 || (!LCMapStringA(lcid,mapstring_flags,s2,l2,sk2,len2)) )
2493 ERR("Bug in LCmapStringA.\n");
2498 /* strcmp doesn't necessarily return -1, 0, or 1 */
2499 result = strcmp(sk1,sk2);
2501 HeapFree(GetProcessHeap(),0,sk1);
2508 /* must be greater, if we reach this point */
2512 /******************************************************************************
2513 * CompareStringW [KERNEL32.144]
2514 * This implementation ignores the locale
2515 * FIXME : Does only string sort. Should
2516 * be reimplemented the same way as CompareStringA.
2518 UINT WINAPI CompareStringW(DWORD lcid, DWORD fdwStyle,
2519 LPCWSTR s1, DWORD l1, LPCWSTR s2,DWORD l2)
2522 if(fdwStyle & NORM_IGNORENONSPACE)
2523 FIXME("IGNORENONSPACE not supprted\n");
2524 if(fdwStyle & NORM_IGNORESYMBOLS)
2525 FIXME("IGNORESYMBOLS not supported\n");
2527 /* Is strcmp defaulting to string sort or to word sort?? */
2528 /* FIXME: Handle NORM_STRINGSORT */
2529 l1 = (l1==-1)?strlenW(s1):l1;
2530 l2 = (l2==-1)?strlenW(s2):l2;
2531 len = l1<l2 ? l1:l2;
2532 ret = (fdwStyle & NORM_IGNORECASE) ? strncmpiW(s1,s2,len) : strncmpW(s1,s2,len);
2533 /* not equal, return 1 or 3 */
2535 /* need to translate result */
2536 return ((int)ret < 0) ? 1 : 3;
2538 /* same len, return 2 */
2539 if(l1==l2) return 2;
2540 /* the longer one is lexically greater */
2541 return (l1<l2)? 1 : 3;
2544 /******************************************************************************
2545 * OLE_GetFormatA [Internal]
2548 * If datelen == 0, it should return the reguired string length.
2550 This function implements stuff for GetDateFormat() and
2553 d single-digit (no leading zero) day (of month)
2554 dd two-digit day (of month)
2555 ddd short day-of-week name
2556 dddd long day-of-week name
2557 M single-digit month
2559 MMM short month name
2560 MMMM full month name
2561 y two-digit year, no leading 0
2563 yyyy four-digit year
2565 h hours with no leading zero (12-hour)
2566 hh hours with full two digits
2567 H hours with no leading zero (24-hour)
2568 HH hours with full two digits
2569 m minutes with no leading zero
2570 mm minutes with full two digits
2571 s seconds with no leading zero
2572 ss seconds with full two digits
2573 t time marker (A or P)
2574 tt time marker (AM, PM)
2575 '' used to quote literal characters
2576 '' (within a quoted string) indicates a literal '
2578 These functions REQUIRE valid locale, date, and format.
2580 static INT OLE_GetFormatA(LCID locale,
2584 LPCSTR _format, /*in*/
2589 int count, type, inquote, Overflow;
2595 const char * _dgfmt[] = { "%d", "%02d" };
2596 const char ** dgfmt = _dgfmt - 1;
2598 /* report, for debugging */
2599 TRACE("(0x%lx,0x%lx, 0x%lx, time(y=%d m=%d wd=%d d=%d,h=%d,m=%d,s=%d), fmt=%p \'%s\' , %p, len=%d)\n",
2600 locale, flags, tflags,
2601 xtime->wYear,xtime->wMonth,xtime->wDayOfWeek,xtime->wDay, xtime->wHour, xtime->wMinute, xtime->wSecond,
2602 _format, _format, date, datelen);
2605 FIXME("datelen = 0, returning 255\n");
2609 /* initalize state variables and output buffer */
2611 count = 0; inquote = 0; Overflow = 0;
2613 date[0] = buf[0] = '\0';
2615 strcpy(format,_format);
2617 /* alter the formatstring, while it works for all languages now in wine
2618 its possible that it fails when the time looks like ss:mm:hh as example*/
2619 if (tflags & (TIME_NOMINUTESORSECONDS))
2620 { if ((pos = strstr ( format, ":mm")))
2621 { memcpy ( pos, pos+3, strlen(format)-(pos-format)-2 );
2624 if (tflags & (TIME_NOSECONDS))
2625 { if ((pos = strstr ( format, ":ss")))
2626 { memcpy ( pos, pos+3, strlen(format)-(pos-format)-2 );
2630 for (inpos = 0;; inpos++) {
2631 /* TRACE("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]); */
2633 if (format[inpos] == '\'') {
2634 if (format[inpos+1] == '\'') {
2636 date[outpos++] = '\'';
2639 continue; /* we did nothing to the output */
2641 } else if (format[inpos] == '\0') {
2642 date[outpos++] = '\0';
2643 if (outpos > datelen) Overflow = 1;
2646 date[outpos++] = format[inpos];
2647 if (outpos > datelen) {
2649 date[outpos-1] = '\0'; /* this is the last place where
2650 it's safe to write */
2654 } else if ( (count && (format[inpos] != type))
2656 || (count == 2 && strchr("ghHmst", type)) )
2660 GetLocaleInfoA(locale,
2662 + (xtime->wDayOfWeek+6)%7,
2664 } else if (count == 3) {
2665 GetLocaleInfoA(locale,
2666 LOCALE_SABBREVDAYNAME1
2667 + (xtime->wDayOfWeek+6)%7,
2670 sprintf(buf, dgfmt[count], xtime->wDay);
2672 } else if (type == 'M') {
2674 GetLocaleInfoA(locale,
2675 LOCALE_SABBREVMONTHNAME1
2676 + xtime->wMonth - 1,
2678 } else if (count == 4) {
2679 GetLocaleInfoA(locale,
2681 + xtime->wMonth - 1,
2684 sprintf(buf, dgfmt[count], xtime->wMonth);
2686 } else if (type == 'y') {
2688 sprintf(buf, "%d", xtime->wYear);
2689 } else if (count == 3) {
2691 WARN("unknown format, c=%c, n=%d\n", type, count);
2693 sprintf(buf, dgfmt[count], xtime->wYear % 100);
2695 } else if (type == 'g') {
2697 FIXME("LOCALE_ICALENDARTYPE unimp.\n");
2701 WARN("unknown format, c=%c, n=%d\n", type, count);
2703 } else if (type == 'h') {
2704 /* gives us hours 1:00 -- 12:00 */
2705 sprintf(buf, dgfmt[count], (xtime->wHour-1)%12 +1);
2706 } else if (type == 'H') {
2708 sprintf(buf, dgfmt[count], xtime->wHour);
2709 } else if ( type == 'm') {
2710 sprintf(buf, dgfmt[count], xtime->wMinute);
2711 } else if ( type == 's') {
2712 sprintf(buf, dgfmt[count], xtime->wSecond);
2713 } else if (type == 't') {
2715 sprintf(buf, "%c", (xtime->wHour < 12) ? 'A' : 'P');
2716 } else if (count == 2) {
2717 /* sprintf(buf, "%s", (xtime->wHour < 12) ? "AM" : "PM"); */
2718 GetLocaleInfoA(locale,
2720 ? LOCALE_S1159 : LOCALE_S2359,
2725 /* we need to check the next char in the format string
2726 again, no matter what happened */
2729 /* add the contents of buf to the output */
2730 buflen = strlen(buf);
2731 if (outpos + buflen < datelen) {
2732 date[outpos] = '\0'; /* for strcat to hook onto */
2736 date[outpos] = '\0';
2737 strncat(date, buf, datelen - outpos);
2738 date[datelen - 1] = '\0';
2739 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2740 WARN("insufficient buffer\n");
2744 /* reset the variables we used to keep track of this item */
2747 } else if (format[inpos] == '\0') {
2748 /* we can't check for this at the loop-head, because
2749 that breaks the printing of the last format-item */
2750 date[outpos] = '\0';
2753 /* continuing a code for an item */
2756 } else if (strchr("hHmstyMdg", format[inpos])) {
2757 type = format[inpos];
2760 } else if (format[inpos] == '\'') {
2764 date[outpos++] = format[inpos];
2766 /* now deal with a possible buffer overflow */
2767 if (outpos >= datelen) {
2768 date[datelen - 1] = '\0';
2769 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2775 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2778 /* finish it off with a string terminator */
2781 if (outpos > datelen-1) outpos = datelen-1;
2782 date[outpos] = '\0';
2784 TRACE("OLE_GetFormatA returns string '%s', len %d\n",
2789 /******************************************************************************
2790 * OLE_GetFormatW [INTERNAL]
2792 static INT OLE_GetFormatW(LCID locale, DWORD flags, DWORD tflags,
2795 LPWSTR output, INT outlen)
2798 int count, type=0, inquote;
2799 int Overflow; /* loop check */
2803 WCHAR arg0[] = {0}, arg1[] = {'%','d',0};
2804 WCHAR arg2[] = {'%','0','2','d',0};
2806 int datevars=0, timevars=0;
2812 /* make a debug report */
2813 TRACE("args: 0x%lx, 0x%lx, 0x%lx, time(d=%d,h=%d,m=%d,s=%d), fmt:%s (at %p), "
2814 "%p with max len %d\n",
2815 locale, flags, tflags,
2816 xtime->wDay, xtime->wHour, xtime->wMinute, xtime->wSecond,
2817 debugstr_w(format), format, output, outlen);
2820 FIXME("outlen = 0, returning 255\n");
2824 /* initialize state variables */
2827 inquote = Overflow = 0;
2828 /* this is really just a sanity check */
2829 output[0] = buf[0] = 0;
2831 /* this loop is the core of the function */
2832 for (inpos = 0; /* we have several break points */ ; inpos++) {
2834 if (format[inpos] == (WCHAR) '\'') {
2835 if (format[inpos+1] == '\'') {
2837 output[outpos++] = '\'';
2842 } else if (format[inpos] == 0) {
2843 output[outpos++] = 0;
2844 if (outpos > outlen) Overflow = 1;
2845 break; /* normal exit (within a quote) */
2847 output[outpos++] = format[inpos]; /* copy input */
2848 if (outpos > outlen) {
2850 output[outpos-1] = 0;
2854 } else if ( (count && (format[inpos] != type))
2855 || ( (count==4 && type =='y') ||
2856 (count==4 && type =='M') ||
2857 (count==4 && type =='d') ||
2858 (count==2 && type =='g') ||
2859 (count==2 && type =='h') ||
2860 (count==2 && type =='H') ||
2861 (count==2 && type =='m') ||
2862 (count==2 && type =='s') ||
2863 (count==2 && type =='t') ) ) {
2868 GetLocaleInfoW(locale,
2869 LOCALE_SDAYNAME1 + (xtime->wDayOfWeek +6)%7,
2870 buf, sizeof(buf)/sizeof(WCHAR) );
2871 } else if (count == 3) {
2872 GetLocaleInfoW(locale,
2873 LOCALE_SABBREVDAYNAME1 +
2874 (xtime->wDayOfWeek +6)%7,
2875 buf, sizeof(buf)/sizeof(WCHAR) );
2877 sprintf( tmp, "%.*d", count, xtime->wDay );
2878 MultiByteToWideChar( CP_ACP, 0, tmp, -1, buf, sizeof(buf)/sizeof(WCHAR) );
2884 GetLocaleInfoW(locale, LOCALE_SMONTHNAME1 +
2885 xtime->wMonth -1, buf,
2886 sizeof(buf)/sizeof(WCHAR) );
2887 } else if (count == 3) {
2888 GetLocaleInfoW(locale, LOCALE_SABBREVMONTHNAME1 +
2889 xtime->wMonth -1, buf,
2890 sizeof(buf)/sizeof(WCHAR) );
2892 sprintf( tmp, "%.*d", count, xtime->wMonth );
2893 MultiByteToWideChar( CP_ACP, 0, tmp, -1, buf, sizeof(buf)/sizeof(WCHAR) );
2898 sprintf( tmp, "%d", xtime->wYear );
2899 } else if (count == 3) {
2900 strcpy( tmp, "yyy" );
2902 sprintf( tmp, "%.*d", count, xtime->wYear % 100 );
2904 MultiByteToWideChar( CP_ACP, 0, tmp, -1, buf, sizeof(buf)/sizeof(WCHAR) );
2909 FIXME("LOCALE_ICALENDARTYPE unimplemented\n");
2910 strcpy( tmp, "AD" );
2912 /* Win API sez we copy it verbatim */
2915 MultiByteToWideChar( CP_ACP, 0, tmp, -1, buf, sizeof(buf)/sizeof(WCHAR) );
2919 /* hours 1:00-12:00 --- is this right? */
2920 sprintf( tmp, "%.*d", count, (xtime->wHour-1)%12 +1);
2921 MultiByteToWideChar( CP_ACP, 0, tmp, -1, buf, sizeof(buf)/sizeof(WCHAR) );
2925 sprintf( tmp, "%.*d", count, xtime->wHour );
2926 MultiByteToWideChar( CP_ACP, 0, tmp, -1, buf, sizeof(buf)/sizeof(WCHAR) );
2930 sprintf( tmp, "%.*d", count, xtime->wMinute );
2931 MultiByteToWideChar( CP_ACP, 0, tmp, -1, buf, sizeof(buf)/sizeof(WCHAR) );
2935 sprintf( tmp, "%.*d", count, xtime->wSecond );
2936 MultiByteToWideChar( CP_ACP, 0, tmp, -1, buf, sizeof(buf)/sizeof(WCHAR) );
2940 GetLocaleInfoW(locale, (xtime->wHour < 12) ?
2941 LOCALE_S1159 : LOCALE_S2359,
2949 /* no matter what happened, we need to check this next
2950 character the next time we loop through */
2953 /* cat buf onto the output */
2954 outlen = strlenW(buf);
2955 if (outpos + buflen < outlen) {
2956 strcpyW( output + outpos, buf );
2959 lstrcpynW( output + outpos, buf, outlen - outpos );
2961 break; /* Abnormal exit */
2964 /* reset the variables we used this time */
2967 } else if (format[inpos] == 0) {
2968 /* we can't check for this at the beginning, because that
2969 would keep us from printing a format spec that ended the
2972 break; /* NORMAL EXIT */
2974 /* how we keep track of the middle of a format spec */
2977 } else if ( (datevars && (format[inpos]=='d' ||
2978 format[inpos]=='M' ||
2979 format[inpos]=='y' ||
2980 format[inpos]=='g') ) ||
2981 (timevars && (format[inpos]=='H' ||
2982 format[inpos]=='h' ||
2983 format[inpos]=='m' ||
2984 format[inpos]=='s' ||
2985 format[inpos]=='t') ) ) {
2986 type = format[inpos];
2989 } else if (format[inpos] == '\'') {
2993 /* unquoted literals */
2994 output[outpos++] = format[inpos];
2999 SetLastError(ERROR_INSUFFICIENT_BUFFER);
3000 WARN(" buffer overflow\n");
3003 /* final string terminator and sanity check */
3005 if (outpos > outlen-1) outpos = outlen-1;
3006 output[outpos] = '0';
3008 TRACE(" returning %s\n", debugstr_w(output));
3010 return (!Overflow) ? outlen : 0;
3015 /******************************************************************************
3016 * GetDateFormatA [KERNEL32.310]
3017 * Makes an ASCII string of the date
3019 * This function uses format to format the date, or, if format
3020 * is NULL, uses the default for the locale. format is a string
3021 * of literal fields and characters as follows:
3023 * - d single-digit (no leading zero) day (of month)
3024 * - dd two-digit day (of month)
3025 * - ddd short day-of-week name
3026 * - dddd long day-of-week name
3027 * - M single-digit month
3028 * - MM two-digit month
3029 * - MMM short month name
3030 * - MMMM full month name
3031 * - y two-digit year, no leading 0
3032 * - yy two-digit year
3033 * - yyyy four-digit year
3037 INT WINAPI GetDateFormatA(LCID locale,DWORD flags,
3039 LPCSTR format, LPSTR date,INT datelen)
3042 char format_buf[40];
3045 LPSYSTEMTIME thistime;
3051 TRACE("(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",
3052 locale,flags,xtime,format,date,datelen);
3055 locale = LOCALE_SYSTEM_DEFAULT;
3058 if (locale == LOCALE_SYSTEM_DEFAULT) {
3059 thislocale = GetSystemDefaultLCID();
3060 } else if (locale == LOCALE_USER_DEFAULT) {
3061 thislocale = GetUserDefaultLCID();
3063 thislocale = locale;
3066 if (xtime == NULL) {
3069 /* Silently correct wDayOfWeek by tranforming to FileTime and back again*/
3070 res=SystemTimeToFileTime(xtime,&ft);
3071 /* Check year(?)/month and date for range and set ERROR_INVALID_PARAMETER on error*/
3072 /*FIXME: SystemTimeToFileTime doesn't yet do that ckeck*/
3075 SetLastError(ERROR_INVALID_PARAMETER);
3078 FileTimeToSystemTime(&ft,&t);
3083 if (format == NULL) {
3084 GetLocaleInfoA(thislocale, ((flags&DATE_LONGDATE)
3086 : LOCALE_SSHORTDATE),
3087 format_buf, sizeof(format_buf));
3088 thisformat = format_buf;
3090 thisformat = format;
3094 ret = OLE_GetFormatA(thislocale, flags, 0, thistime, thisformat,
3099 "GetDateFormatA() returning %d, with data=%s\n",
3104 /******************************************************************************
3105 * GetDateFormatW [KERNEL32.311]
3106 * Makes a Unicode string of the date
3108 * Acts the same as GetDateFormatA(), except that it's Unicode.
3109 * Accepts & returns sizes as counts of Unicode characters.
3112 INT WINAPI GetDateFormatW(LCID locale,DWORD flags,
3115 LPWSTR date, INT datelen)
3117 unsigned short datearr[] = {'1','9','9','4','-','1','-','1',0};
3119 FIXME("STUB (should call OLE_GetFormatW)\n");
3120 lstrcpynW(date, datearr, datelen);
3121 return ( datelen < 9) ? datelen : 9;
3126 /**************************************************************************
3127 * EnumDateFormatsA (KERNEL32.198)
3129 BOOL WINAPI EnumDateFormatsA(
3130 DATEFMT_ENUMPROCA lpDateFmtEnumProc, LCID Locale, DWORD dwFlags)
3132 LCID Loc = GetUserDefaultLCID();
3133 if(!lpDateFmtEnumProc)
3135 SetLastError(ERROR_INVALID_PARAMETER);
3142 case 0x00000407: /* (Loc,"de_DE") */
3146 case DATE_SHORTDATE:
3147 if(!(*lpDateFmtEnumProc)("dd.MM.yy")) return TRUE;
3148 if(!(*lpDateFmtEnumProc)("d.M.yyyy")) return TRUE;
3149 if(!(*lpDateFmtEnumProc)("d.MM.yy")) return TRUE;
3150 if(!(*lpDateFmtEnumProc)("d.M.yy")) return TRUE;
3153 if(!(*lpDateFmtEnumProc)("dddd,d. MMMM yyyy")) return TRUE;
3154 if(!(*lpDateFmtEnumProc)("d. MMMM yyyy")) return TRUE;
3155 if(!(*lpDateFmtEnumProc)("d. MMM yyyy")) return TRUE;
3158 FIXME("Unknown date format (%ld)\n", dwFlags);
3159 SetLastError(ERROR_INVALID_PARAMETER);
3164 case 0x0000040c: /* (Loc,"fr_FR") */
3168 case DATE_SHORTDATE:
3169 if(!(*lpDateFmtEnumProc)("dd/MM/yy")) return TRUE;
3170 if(!(*lpDateFmtEnumProc)("dd.MM.yy")) return TRUE;
3171 if(!(*lpDateFmtEnumProc)("dd-MM-yy")) return TRUE;
3172 if(!(*lpDateFmtEnumProc)("dd/MM/yyyy")) return TRUE;
3175 if(!(*lpDateFmtEnumProc)("dddd d MMMM yyyy")) return TRUE;
3176 if(!(*lpDateFmtEnumProc)("d MMM yy")) return TRUE;
3177 if(!(*lpDateFmtEnumProc)("d MMMM yyyy")) return TRUE;
3180 FIXME("Unknown date format (%ld)\n", dwFlags);
3181 SetLastError(ERROR_INVALID_PARAMETER);
3186 case 0x00000c0c: /* (Loc,"fr_CA") */
3190 case DATE_SHORTDATE:
3191 if(!(*lpDateFmtEnumProc)("yy-MM-dd")) return TRUE;
3192 if(!(*lpDateFmtEnumProc)("dd-MM-yy")) return TRUE;
3193 if(!(*lpDateFmtEnumProc)("yy MM dd")) return TRUE;
3194 if(!(*lpDateFmtEnumProc)("dd/MM/yy")) return TRUE;
3197 if(!(*lpDateFmtEnumProc)("d MMMM, yyyy")) return TRUE;
3198 if(!(*lpDateFmtEnumProc)("d MMM yyyy")) return TRUE;
3201 FIXME("Unknown date format (%ld)\n", dwFlags);
3202 SetLastError(ERROR_INVALID_PARAMETER);
3207 case 0x00000809: /* (Loc,"en_UK") */
3211 case DATE_SHORTDATE:
3212 if(!(*lpDateFmtEnumProc)("dd/MM/yy")) return TRUE;
3213 if(!(*lpDateFmtEnumProc)("dd/MM/yyyy")) return TRUE;
3214 if(!(*lpDateFmtEnumProc)("d/M/yy")) return TRUE;
3215 if(!(*lpDateFmtEnumProc)("d.M.yy")) return TRUE;
3218 if(!(*lpDateFmtEnumProc)("dd MMMM yyyy")) return TRUE;
3219 if(!(*lpDateFmtEnumProc)("d MMMM yyyy")) return TRUE;
3222 FIXME("Unknown date format (%ld)\n", dwFlags);
3223 SetLastError(ERROR_INVALID_PARAMETER);
3228 case 0x00000c09: /* (Loc,"en_AU") */
3232 case DATE_SHORTDATE:
3233 if(!(*lpDateFmtEnumProc)("d/MM/yy")) return TRUE;
3234 if(!(*lpDateFmtEnumProc)("d/M/yy")) return TRUE;
3235 if(!(*lpDateFmtEnumProc)("dd/MM/yy")) return TRUE;
3238 if(!(*lpDateFmtEnumProc)("dddd,d MMMM yyyy")) return TRUE;
3239 if(!(*lpDateFmtEnumProc)("d MMMM yyyy")) return TRUE;
3242 FIXME("Unknown date format (%ld)\n", dwFlags);
3243 SetLastError(ERROR_INVALID_PARAMETER);
3248 case 0x00001009: /* (Loc,"en_CA") */
3252 case DATE_SHORTDATE:
3253 if(!(*lpDateFmtEnumProc)("dd/MM/yy")) return TRUE;
3254 if(!(*lpDateFmtEnumProc)("d/M/yy")) return TRUE;
3255 if(!(*lpDateFmtEnumProc)("yy-MM-dd")) return TRUE;
3256 if(!(*lpDateFmtEnumProc)("M/dd/yy")) return TRUE;
3259 if(!(*lpDateFmtEnumProc)("d-MMM-yy")) return TRUE;
3260 if(!(*lpDateFmtEnumProc)("MMMM d, yyyy")) return TRUE;
3263 FIXME("Unknown date format (%ld)\n", dwFlags);
3264 SetLastError(ERROR_INVALID_PARAMETER);
3269 case 0x00001409: /* (Loc,"en_NZ") */
3273 case DATE_SHORTDATE:
3274 if(!(*lpDateFmtEnumProc)("d/MM/yy")) return TRUE;
3275 if(!(*lpDateFmtEnumProc)("dd/MM/yy")) return TRUE;
3276 if(!(*lpDateFmtEnumProc)("d.MM.yy")) return TRUE;
3279 if(!(*lpDateFmtEnumProc)("d MMMM yyyy")) return TRUE;
3280 if(!(*lpDateFmtEnumProc)("dddd, d MMMM yyyy")) return TRUE;
3283 FIXME("Unknown date format (%ld)\n", dwFlags);
3284 SetLastError(ERROR_INVALID_PARAMETER);
3289 case 0x00001809: /* (Loc,"en_IE") */
3293 case DATE_SHORTDATE:
3294 if(!(*lpDateFmtEnumProc)("dd/MM/yy")) return TRUE;
3295 if(!(*lpDateFmtEnumProc)("d/M/yy")) return TRUE;
3296 if(!(*lpDateFmtEnumProc)("d.M.yy")) return TRUE;
3299 if(!(*lpDateFmtEnumProc)("dd MMMM yyyy")) return TRUE;
3300 if(!(*lpDateFmtEnumProc)("d MMMM yyyy")) return TRUE;
3303 FIXME("Unknown date format (%ld)\n", dwFlags);
3304 SetLastError(ERROR_INVALID_PARAMETER);
3309 case 0x00001c09: /* (Loc,"en_ZA") */
3313 case DATE_SHORTDATE:
3314 if(!(*lpDateFmtEnumProc)("yy/MM/dd")) return TRUE;
3317 if(!(*lpDateFmtEnumProc)("dd MMMM yyyy")) return TRUE;
3320 FIXME("Unknown date format (%ld)\n", dwFlags);
3321 SetLastError(ERROR_INVALID_PARAMETER);
3326 case 0x00002009: /* (Loc,"en_JM") */
3330 case DATE_SHORTDATE:
3331 if(!(*lpDateFmtEnumProc)("dd/MM/yyyy")) return TRUE;
3334 if(!(*lpDateFmtEnumProc)("dddd,MMMM dd,yyyy")) return TRUE;
3335 if(!(*lpDateFmtEnumProc)("MMMM dd,yyyy")) return TRUE;
3336 if(!(*lpDateFmtEnumProc)("dddd,dd MMMM,yyyy")) return TRUE;
3337 if(!(*lpDateFmtEnumProc)("dd MMMM,yyyy")) return TRUE;
3340 FIXME("Unknown date format (%ld)\n", dwFlags);
3341 SetLastError(ERROR_INVALID_PARAMETER);
3346 case 0x00002809: /* (Loc,"en_BZ") */
3347 case 0x00002c09: /* (Loc,"en_TT") */
3351 case DATE_SHORTDATE:
3352 if(!(*lpDateFmtEnumProc)("dd/MM/yyyy")) return TRUE;
3355 if(!(*lpDateFmtEnumProc)("dddd,dd MMMM yyyy")) return TRUE;
3358 FIXME("Unknown date format (%ld)\n", dwFlags);
3359 SetLastError(ERROR_INVALID_PARAMETER);
3364 default: /* default to US English "en_US" */
3368 case DATE_SHORTDATE:
3369 if(!(*lpDateFmtEnumProc)("M/d/yy")) return TRUE;
3370 if(!(*lpDateFmtEnumProc)("M/d/yyyy")) return TRUE;
3371 if(!(*lpDateFmtEnumProc)("MM/dd/yy")) return TRUE;
3372 if(!(*lpDateFmtEnumProc)("MM/dd/yyyy")) return TRUE;
3373 if(!(*lpDateFmtEnumProc)("yy/MM/dd")) return TRUE;
3374 if(!(*lpDateFmtEnumProc)("dd-MMM-yy")) return TRUE;
3377 if(!(*lpDateFmtEnumProc)("dddd, MMMM dd, yyyy")) return TRUE;
3378 if(!(*lpDateFmtEnumProc)("MMMM dd, yyyy")) return TRUE;
3379 if(!(*lpDateFmtEnumProc)("dddd, dd MMMM, yyyy")) return TRUE;
3380 if(!(*lpDateFmtEnumProc)("dd MMMM, yyyy")) return TRUE;
3383 FIXME("Unknown date format (%ld)\n", dwFlags);
3384 SetLastError(ERROR_INVALID_PARAMETER);
3391 /**************************************************************************
3392 * EnumDateFormatsW (KERNEL32.199)
3394 BOOL WINAPI EnumDateFormatsW(
3395 DATEFMT_ENUMPROCW lpDateFmtEnumProc, LCID Locale, DWORD dwFlags)
3397 FIXME("(%p, %ld, %ld): stub\n", lpDateFmtEnumProc, Locale, dwFlags);
3398 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
3402 /**************************************************************************
3403 * EnumTimeFormatsA (KERNEL32.210)
3405 BOOL WINAPI EnumTimeFormatsA(
3406 TIMEFMT_ENUMPROCA lpTimeFmtEnumProc, LCID Locale, DWORD dwFlags)
3408 LCID Loc = GetUserDefaultLCID();
3409 if(!lpTimeFmtEnumProc)
3411 SetLastError(ERROR_INVALID_PARAMETER);
3416 FIXME("Unknown time format (%ld)\n", dwFlags);
3421 case 0x00000407: /* (Loc,"de_DE") */
3423 if(!(*lpTimeFmtEnumProc)("HH.mm")) return TRUE;
3424 if(!(*lpTimeFmtEnumProc)("HH:mm:ss")) return TRUE;
3425 if(!(*lpTimeFmtEnumProc)("H:mm:ss")) return TRUE;
3426 if(!(*lpTimeFmtEnumProc)("H.mm")) return TRUE;
3427 if(!(*lpTimeFmtEnumProc)("H.mm'Uhr'")) return TRUE;
3431 case 0x0000040c: /* (Loc,"fr_FR") */
3432 case 0x00000c0c: /* (Loc,"fr_CA") */
3434 if(!(*lpTimeFmtEnumProc)("H:mm")) return TRUE;
3435 if(!(*lpTimeFmtEnumProc)("HH:mm:ss")) return TRUE;
3436 if(!(*lpTimeFmtEnumProc)("H:mm:ss")) return TRUE;
3437 if(!(*lpTimeFmtEnumProc)("HH.mm")) return TRUE;
3438 if(!(*lpTimeFmtEnumProc)("HH'h'mm")) return TRUE;
3442 case 0x00000809: /* (Loc,"en_UK") */
3443 case 0x00000c09: /* (Loc,"en_AU") */
3444 case 0x00001409: /* (Loc,"en_NZ") */
3445 case 0x00001809: /* (Loc,"en_IE") */
3447 if(!(*lpTimeFmtEnumProc)("h:mm:ss tt")) return TRUE;
3448 if(!(*lpTimeFmtEnumProc)("HH:mm:ss")) return TRUE;
3449 if(!(*lpTimeFmtEnumProc)("H:mm:ss")) return TRUE;
3453 case 0x00001c09: /* (Loc,"en_ZA") */
3454 case 0x00002809: /* (Loc,"en_BZ") */
3455 case 0x00002c09: /* (Loc,"en_TT") */
3457 if(!(*lpTimeFmtEnumProc)("h:mm:ss tt")) return TRUE;
3458 if(!(*lpTimeFmtEnumProc)("hh:mm:ss tt")) return TRUE;
3462 default: /* default to US style "en_US" */
3464 if(!(*lpTimeFmtEnumProc)("h:mm:ss tt")) return TRUE;
3465 if(!(*lpTimeFmtEnumProc)("hh:mm:ss tt")) return TRUE;
3466 if(!(*lpTimeFmtEnumProc)("H:mm:ss")) return TRUE;
3467 if(!(*lpTimeFmtEnumProc)("HH:mm:ss")) return TRUE;
3473 /**************************************************************************
3474 * EnumTimeFormatsW (KERNEL32.211)
3476 BOOL WINAPI EnumTimeFormatsW(
3477 TIMEFMT_ENUMPROCW lpTimeFmtEnumProc, LCID Locale, DWORD dwFlags)
3479 FIXME("(%p,%ld,%ld): stub\n", lpTimeFmtEnumProc, Locale, dwFlags);
3480 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
3484 /**************************************************************************
3485 * This function is used just locally !
3486 * Description: Inverts a string.
3488 static void OLE_InvertString(char* string)
3490 char sTmpArray[128];
3493 for (counter = strlen(string); counter > 0; counter--)
3495 memcpy(sTmpArray + i, string + counter-1, 1);
3498 memcpy(sTmpArray + i, "\0", 1);
3499 strcpy(string, sTmpArray);
3502 /***************************************************************************************
3503 * This function is used just locally !
3504 * Description: Test if the given string (psNumber) is valid or not.
3505 * The valid characters are the following:
3506 * - Characters '0' through '9'.
3507 * - One decimal point (dot) if the number is a floating-point value.
3508 * - A minus sign in the first character position if the number is
3510 * If the function succeeds, psBefore/psAfter will point to the string
3511 * on the right/left of the decimal symbol. pbNegative indicates if the
3512 * number is negative.
3514 static INT OLE_GetNumberComponents(char* pInput, char* psBefore, char* psAfter, BOOL* pbNegative)
3516 char sNumberSet[] = "0123456789";
3517 BOOL bInDecimal = FALSE;
3519 /* Test if we do have a minus sign */
3520 if ( *pInput == '-' )
3523 pInput++; /* Jump to the next character. */
3526 while(*pInput != '\0')
3528 /* Do we have a valid numeric character */
3529 if ( strchr(sNumberSet, *pInput) != NULL )
3531 if (bInDecimal == TRUE)
3532 *psAfter++ = *pInput;
3534 *psBefore++ = *pInput;
3538 /* Is this a decimal point (dot) */
3539 if ( *pInput == '.' )
3541 /* Is it the first time we find it */
3542 if ((bInDecimal == FALSE))
3545 return -1; /* ERROR: Invalid parameter */
3549 /* It's neither a numeric character, nor a decimal point.
3550 * Thus, return an error.
3558 /* Add an End of Line character to the output buffers */
3565 /**************************************************************************
3566 * This function is used just locally !
3567 * Description: A number could be formatted using different numbers
3568 * of "digits in group" (example: 4;3;2;0).
3569 * The first parameter of this function is an array
3570 * containing the rule to be used. It's format is the following:
3571 * |NDG|DG1|DG2|...|0|
3572 * where NDG is the number of used "digits in group" and DG1, DG2,
3573 * are the corresponding "digits in group".
3574 * Thus, this function returns the grouping value in the array
3575 * pointed by the second parameter.
3577 static INT OLE_GetGrouping(char* sRule, INT index)
3579 char sData[2], sRuleSize[2];
3580 INT nData, nRuleSize;
3582 memcpy(sRuleSize, sRule, 1);
3583 memcpy(sRuleSize+1, "\0", 1);
3584 nRuleSize = atoi(sRuleSize);
3586 if (index > 0 && index < nRuleSize)
3588 memcpy(sData, sRule+index, 1);
3589 memcpy(sData+1, "\0", 1);
3590 nData = atoi(sData);
3595 memcpy(sData, sRule+nRuleSize-1, 1);
3596 memcpy(sData+1, "\0", 1);
3597 nData = atoi(sData);
3603 /**************************************************************************
3604 * GetNumberFormatA (KERNEL32.355)
3606 INT WINAPI GetNumberFormatA(LCID locale, DWORD dwflags,
3607 LPCSTR lpvalue, const NUMBERFMTA * lpFormat,
3608 LPSTR lpNumberStr, int cchNumber)
3610 char sNumberDigits[3], sDecimalSymbol[5], sDigitsInGroup[11], sDigitGroupSymbol[5], sILZero[2];
3611 INT nNumberDigits, nNumberDecimal, i, j, nCounter, nStep, nRuleIndex, nGrouping, nDigits, retVal, nLZ;
3612 char sNumber[128], sDestination[128], sDigitsAfterDecimal[10], sDigitsBeforeDecimal[128];
3613 char sRule[10], sSemiColumn[]=";", sBuffer[5], sNegNumber[2];
3614 char *pStr = NULL, *pTmpStr = NULL;
3615 LCID systemDefaultLCID;
3616 BOOL bNegative = FALSE;
3625 strncpy(sNumber, lpvalue, 128);
3626 sNumber[127] = '\0';
3628 /* Make sure we have a valid input string, get the number
3629 * of digits before and after the decimal symbol, and check
3630 * if this is a negative number.
3632 if ( OLE_GetNumberComponents(sNumber, sDigitsBeforeDecimal, sDigitsAfterDecimal, &bNegative) != -1)
3634 nNumberDecimal = strlen(sDigitsBeforeDecimal);
3635 nDigits = strlen(sDigitsAfterDecimal);
3639 SetLastError(ERROR_INVALID_PARAMETER);
3643 /* Which source will we use to format the string */
3644 used_operation = RETURN_ERROR;
3645 if (lpFormat != NULL)
3648 used_operation = USE_PARAMETER;
3652 if (dwflags & LOCALE_NOUSEROVERRIDE)
3653 used_operation = USE_LOCALEINFO;
3655 used_operation = USE_SYSTEMDEFAULT;
3658 /* Load the fields we need */
3659 switch(used_operation)
3661 case USE_LOCALEINFO:
3662 GetLocaleInfoA(locale, LOCALE_IDIGITS, sNumberDigits, sizeof(sNumberDigits));
3663 GetLocaleInfoA(locale, LOCALE_SDECIMAL, sDecimalSymbol, sizeof(sDecimalSymbol));
3664 GetLocaleInfoA(locale, LOCALE_SGROUPING, sDigitsInGroup, sizeof(sDigitsInGroup));
3665 GetLocaleInfoA(locale, LOCALE_STHOUSAND, sDigitGroupSymbol, sizeof(sDigitGroupSymbol));
3666 GetLocaleInfoA(locale, LOCALE_ILZERO, sILZero, sizeof(sILZero));
3667 GetLocaleInfoA(locale, LOCALE_INEGNUMBER, sNegNumber, sizeof(sNegNumber));
3670 sprintf(sNumberDigits, "%d",lpFormat->NumDigits);
3671 strcpy(sDecimalSymbol, lpFormat->lpDecimalSep);
3672 sprintf(sDigitsInGroup, "%d;0",lpFormat->Grouping);
3673 strcpy(sDigitGroupSymbol, lpFormat->lpThousandSep);
3674 sprintf(sILZero, "%d",lpFormat->LeadingZero);
3675 sprintf(sNegNumber, "%d",lpFormat->NegativeOrder);
3677 case USE_SYSTEMDEFAULT:
3678 systemDefaultLCID = GetSystemDefaultLCID();
3679 GetLocaleInfoA(systemDefaultLCID, LOCALE_IDIGITS, sNumberDigits, sizeof(sNumberDigits));
3680 GetLocaleInfoA(systemDefaultLCID, LOCALE_SDECIMAL, sDecimalSymbol, sizeof(sDecimalSymbol));
3681 GetLocaleInfoA(systemDefaultLCID, LOCALE_SGROUPING, sDigitsInGroup, sizeof(sDigitsInGroup));
3682 GetLocaleInfoA(systemDefaultLCID, LOCALE_STHOUSAND, sDigitGroupSymbol, sizeof(sDigitGroupSymbol));
3683 GetLocaleInfoA(systemDefaultLCID, LOCALE_ILZERO, sILZero, sizeof(sILZero));
3684 GetLocaleInfoA(systemDefaultLCID, LOCALE_INEGNUMBER, sNegNumber, sizeof(sNegNumber));
3687 SetLastError(ERROR_INVALID_PARAMETER);
3691 nNumberDigits = atoi(sNumberDigits);
3693 /* Remove the ";" */
3696 for (nCounter=0; nCounter<strlen(sDigitsInGroup); nCounter++)
3698 if ( memcmp(sDigitsInGroup + nCounter, sSemiColumn, 1) != 0 )
3700 memcpy(sRule + j, sDigitsInGroup + nCounter, 1);
3705 sprintf(sBuffer, "%d", i);
3706 memcpy(sRule, sBuffer, 1); /* Number of digits in the groups ( used by OLE_GetGrouping() ) */
3707 memcpy(sRule + j, "\0", 1);
3709 /* First, format the digits before the decimal. */
3710 if ((nNumberDecimal>0) && (atoi(sDigitsBeforeDecimal) != 0))
3712 /* Working on an inverted string is easier ! */
3713 OLE_InvertString(sDigitsBeforeDecimal);
3715 nStep = nCounter = i = j = 0;
3717 nGrouping = OLE_GetGrouping(sRule, nRuleIndex);
3719 /* Here, we will loop until we reach the end of the string.
3720 * An internal counter (j) is used in order to know when to
3721 * insert the "digit group symbol".
3723 while (nNumberDecimal > 0)
3725 i = nCounter + nStep;
3726 memcpy(sDestination + i, sDigitsBeforeDecimal + nCounter, 1);
3732 if (nRuleIndex < sRule[0])
3734 nGrouping = OLE_GetGrouping(sRule, nRuleIndex);
3735 memcpy(sDestination + i+1, sDigitGroupSymbol, strlen(sDigitGroupSymbol));
3736 nStep+= strlen(sDigitGroupSymbol);
3742 memcpy(sDestination + i+1, "\0", 1);
3743 /* Get the string in the right order ! */
3744 OLE_InvertString(sDestination);
3748 nLZ = atoi(sILZero);
3751 /* Use 0.xxx instead of .xxx */
3752 memcpy(sDestination, "0", 1);
3753 memcpy(sDestination+1, "\0", 1);
3756 memcpy(sDestination, "\0", 1);
3760 /* Second, format the digits after the decimal. */
3762 nCounter = nNumberDigits;
3763 if ( (nDigits>0) && (pStr = strstr (sNumber, ".")) )
3765 i = strlen(sNumber) - strlen(pStr) + 1;
3766 strncpy ( sDigitsAfterDecimal, sNumber + i, nNumberDigits);
3767 j = strlen(sDigitsAfterDecimal);
3768 if (j < nNumberDigits)
3769 nCounter = nNumberDigits-j;
3771 for (i=0;i<nCounter;i++)
3772 memcpy(sDigitsAfterDecimal+i+j, "0", 1);
3773 memcpy(sDigitsAfterDecimal + nNumberDigits, "\0", 1);
3775 i = strlen(sDestination);
3776 j = strlen(sDigitsAfterDecimal);
3777 /* Finally, construct the resulting formatted string. */
3779 for (nCounter=0; nCounter<i; nCounter++)
3780 memcpy(sNumber + nCounter, sDestination + nCounter, 1);
3782 memcpy(sNumber + nCounter, sDecimalSymbol, strlen(sDecimalSymbol));
3785 memcpy(sNumber + nCounter+i+strlen(sDecimalSymbol), sDigitsAfterDecimal + i, 1);
3786 memcpy(sNumber + nCounter+i+strlen(sDecimalSymbol), "\0", 1);
3788 /* Is it a negative number */
3789 if (bNegative == TRUE)
3791 i = atoi(sNegNumber);
3792 pStr = sDestination;
3798 while (*sNumber != '\0')
3799 *pStr++ = *pTmpStr++;
3804 while (*pTmpStr != '\0')
3805 *pStr++ = *pTmpStr++;
3810 while (*pTmpStr != '\0')
3811 *pStr++ = *pTmpStr++;
3814 while (*pTmpStr != '\0')
3815 *pStr++ = *pTmpStr++;
3819 while (*pTmpStr != '\0')
3820 *pStr++ = *pTmpStr++;
3825 while (*pTmpStr != '\0')
3826 *pStr++ = *pTmpStr++;
3831 strcpy(sDestination, sNumber);
3833 /* If cchNumber is zero, then returns the number of bytes or characters
3834 * required to hold the formatted number string
3837 retVal = strlen(sDestination) + 1;
3840 strncpy (lpNumberStr, sDestination, cchNumber-1);
3841 *(lpNumberStr+cchNumber-1) = '\0'; /* ensure we got a NULL at the end */
3842 retVal = strlen(lpNumberStr);
3848 /**************************************************************************
3849 * GetNumberFormatW (KERNEL32.xxx)
3851 INT WINAPI GetNumberFormatW(LCID locale, DWORD dwflags,
3852 LPCWSTR lpvalue, const NUMBERFMTW * lpFormat,
3853 LPWSTR lpNumberStr, int cchNumber)
3855 FIXME("%s: stub, no reformating done\n",debugstr_w(lpvalue));
3857 lstrcpynW( lpNumberStr, lpvalue, cchNumber );
3858 return cchNumber? strlenW( lpNumberStr ) : 0;
3861 /**************************************************************************
3862 * GetCurrencyFormatA (KERNEL32.302)
3864 INT WINAPI GetCurrencyFormatA(LCID locale, DWORD dwflags,
3865 LPCSTR lpvalue, const CURRENCYFMTA * lpFormat,
3866 LPSTR lpCurrencyStr, int cchCurrency)
3868 UINT nPosOrder, nNegOrder;
3870 char sDestination[128], sNegOrder[8], sPosOrder[8], sCurrencySymbol[8];
3871 char *pDestination = sDestination;
3872 char sNumberFormated[128];
3873 char *pNumberFormated = sNumberFormated;
3874 LCID systemDefaultLCID;
3875 BOOL bIsPositive = FALSE, bValidFormat = FALSE;
3884 NUMBERFMTA numberFmt;
3886 /* Which source will we use to format the string */
3887 used_operation = RETURN_ERROR;
3888 if (lpFormat != NULL)
3891 used_operation = USE_PARAMETER;
3895 if (dwflags & LOCALE_NOUSEROVERRIDE)
3896 used_operation = USE_LOCALEINFO;
3898 used_operation = USE_SYSTEMDEFAULT;
3901 /* Load the fields we need */
3902 switch(used_operation)
3904 case USE_LOCALEINFO:
3905 /* Specific to CURRENCYFMTA*/
3906 GetLocaleInfoA(locale, LOCALE_INEGCURR, sNegOrder, sizeof(sNegOrder));
3907 GetLocaleInfoA(locale, LOCALE_ICURRENCY, sPosOrder, sizeof(sPosOrder));
3908 GetLocaleInfoA(locale, LOCALE_SCURRENCY, sCurrencySymbol, sizeof(sCurrencySymbol));
3910 nPosOrder = atoi(sPosOrder);
3911 nNegOrder = atoi(sNegOrder);
3914 /* Specific to CURRENCYFMTA*/
3915 nNegOrder = lpFormat->NegativeOrder;
3916 nPosOrder = lpFormat->PositiveOrder;
3917 strcpy(sCurrencySymbol, lpFormat->lpCurrencySymbol);
3919 case USE_SYSTEMDEFAULT:
3920 systemDefaultLCID = GetSystemDefaultLCID();
3921 /* Specific to CURRENCYFMTA*/
3922 GetLocaleInfoA(systemDefaultLCID, LOCALE_INEGCURR, sNegOrder, sizeof(sNegOrder));
3923 GetLocaleInfoA(systemDefaultLCID, LOCALE_ICURRENCY, sPosOrder, sizeof(sPosOrder));
3924 GetLocaleInfoA(systemDefaultLCID, LOCALE_SCURRENCY, sCurrencySymbol, sizeof(sCurrencySymbol));
3926 nPosOrder = atoi(sPosOrder);
3927 nNegOrder = atoi(sNegOrder);
3930 SetLastError(ERROR_INVALID_PARAMETER);
3934 /* Construct a temporary number format structure */
3935 if (lpFormat != NULL)
3937 numberFmt.NumDigits = lpFormat->NumDigits;
3938 numberFmt.LeadingZero = lpFormat->LeadingZero;
3939 numberFmt.Grouping = lpFormat->Grouping;
3940 numberFmt.NegativeOrder = 0;
3941 numberFmt.lpDecimalSep = lpFormat->lpDecimalSep;
3942 numberFmt.lpThousandSep = lpFormat->lpThousandSep;
3943 bValidFormat = TRUE;
3946 /* Make a call to GetNumberFormatA() */
3947 if (*lpvalue == '-')
3949 bIsPositive = FALSE;
3950 retVal = GetNumberFormatA(locale,0,lpvalue+1,(bValidFormat)?&numberFmt:NULL,pNumberFormated,128);
3955 retVal = GetNumberFormatA(locale,0,lpvalue,(bValidFormat)?&numberFmt:NULL,pNumberFormated,128);
3961 /* construct the formatted string */
3966 case 0: /* Prefix, no separation */
3967 strcpy (pDestination, sCurrencySymbol);
3968 strcat (pDestination, pNumberFormated);
3970 case 1: /* Suffix, no separation */
3971 strcpy (pDestination, pNumberFormated);
3972 strcat (pDestination, sCurrencySymbol);
3974 case 2: /* Prefix, 1 char separation */
3975 strcpy (pDestination, sCurrencySymbol);
3976 strcat (pDestination, " ");
3977 strcat (pDestination, pNumberFormated);
3979 case 3: /* Suffix, 1 char separation */
3980 strcpy (pDestination, pNumberFormated);
3981 strcat (pDestination, " ");
3982 strcat (pDestination, sCurrencySymbol);
3985 SetLastError(ERROR_INVALID_PARAMETER);
3989 else /* negative number */
3993 case 0: /* format: ($1.1) */
3994 strcpy (pDestination, "(");
3995 strcat (pDestination, sCurrencySymbol);
3996 strcat (pDestination, pNumberFormated);
3997 strcat (pDestination, ")");
3999 case 1: /* format: -$1.1 */
4000 strcpy (pDestination, "-");
4001 strcat (pDestination, sCurrencySymbol);
4002 strcat (pDestination, pNumberFormated);
4004 case 2: /* format: $-1.1 */
4005 strcpy (pDestination, sCurrencySymbol);
4006 strcat (pDestination, "-");
4007 strcat (pDestination, pNumberFormated);
4009 case 3: /* format: $1.1- */
4010 strcpy (pDestination, sCurrencySymbol);
4011 strcat (pDestination, pNumberFormated);
4012 strcat (pDestination, "-");
4014 case 4: /* format: (1.1$) */
4015 strcpy (pDestination, "(");
4016 strcat (pDestination, pNumberFormated);
4017 strcat (pDestination, sCurrencySymbol);
4018 strcat (pDestination, ")");
4020 case 5: /* format: -1.1$ */
4021 strcpy (pDestination, "-");
4022 strcat (pDestination, pNumberFormated);
4023 strcat (pDestination, sCurrencySymbol);
4025 case 6: /* format: 1.1-$ */
4026 strcpy (pDestination, pNumberFormated);
4027 strcat (pDestination, "-");
4028 strcat (pDestination, sCurrencySymbol);
4030 case 7: /* format: 1.1$- */
4031 strcpy (pDestination, pNumberFormated);
4032 strcat (pDestination, sCurrencySymbol);
4033 strcat (pDestination, "-");
4035 case 8: /* format: -1.1 $ */
4036 strcpy (pDestination, "-");
4037 strcat (pDestination, pNumberFormated);
4038 strcat (pDestination, " ");
4039 strcat (pDestination, sCurrencySymbol);
4041 case 9: /* format: -$ 1.1 */
4042 strcpy (pDestination, "-");
4043 strcat (pDestination, sCurrencySymbol);
4044 strcat (pDestination, " ");
4045 strcat (pDestination, pNumberFormated);
4047 case 10: /* format: 1.1 $- */
4048 strcpy (pDestination, pNumberFormated);
4049 strcat (pDestination, " ");
4050 strcat (pDestination, sCurrencySymbol);
4051 strcat (pDestination, "-");
4053 case 11: /* format: $ 1.1- */
4054 strcpy (pDestination, sCurrencySymbol);
4055 strcat (pDestination, " ");
4056 strcat (pDestination, pNumberFormated);
4057 strcat (pDestination, "-");
4059 case 12: /* format: $ -1.1 */
4060 strcpy (pDestination, sCurrencySymbol);
4061 strcat (pDestination, " ");
4062 strcat (pDestination, "-");
4063 strcat (pDestination, pNumberFormated);
4065 case 13: /* format: 1.1- $ */
4066 strcpy (pDestination, pNumberFormated);
4067 strcat (pDestination, "-");
4068 strcat (pDestination, " ");
4069 strcat (pDestination, sCurrencySymbol);
4071 case 14: /* format: ($ 1.1) */
4072 strcpy (pDestination, "(");
4073 strcat (pDestination, sCurrencySymbol);
4074 strcat (pDestination, " ");
4075 strcat (pDestination, pNumberFormated);
4076 strcat (pDestination, ")");
4078 case 15: /* format: (1.1 $) */
4079 strcpy (pDestination, "(");
4080 strcat (pDestination, pNumberFormated);
4081 strcat (pDestination, " ");
4082 strcat (pDestination, sCurrencySymbol);
4083 strcat (pDestination, ")");
4086 SetLastError(ERROR_INVALID_PARAMETER);
4091 if (cchCurrency == 0)
4092 return strlen(pDestination) + 1;
4096 strncpy (lpCurrencyStr, pDestination, cchCurrency-1);
4097 *(lpCurrencyStr+cchCurrency-1) = '\0'; /* ensure we got a NULL at the end */
4098 return strlen(lpCurrencyStr);
4102 /**************************************************************************
4103 * GetCurrencyFormatW (KERNEL32.303)
4105 INT WINAPI GetCurrencyFormatW(LCID locale, DWORD dwflags,
4106 LPCWSTR lpvalue, const CURRENCYFMTW * lpFormat,
4107 LPWSTR lpCurrencyStr, int cchCurrency)
4109 FIXME("This API function is NOT implemented !\n");
4113 /******************************************************************************
4114 * OLE2NLS_CheckLocale [intern]
4116 static LCID OLE2NLS_CheckLocale (LCID locale)
4119 { locale = LOCALE_SYSTEM_DEFAULT;
4122 if (locale == LOCALE_SYSTEM_DEFAULT)
4123 { return GetSystemDefaultLCID();
4125 else if (locale == LOCALE_USER_DEFAULT)
4126 { return GetUserDefaultLCID();
4132 /******************************************************************************
4133 * GetTimeFormatA [KERNEL32.422]
4134 * Makes an ASCII string of the time
4136 * Formats date according to format, or locale default if format is
4137 * NULL. The format consists of literal characters and fields as follows:
4139 * h hours with no leading zero (12-hour)
4140 * hh hours with full two digits
4141 * H hours with no leading zero (24-hour)
4142 * HH hours with full two digits
4143 * m minutes with no leading zero
4144 * mm minutes with full two digits
4145 * s seconds with no leading zero
4146 * ss seconds with full two digits
4147 * t time marker (A or P)
4148 * tt time marker (AM, PM)
4152 GetTimeFormatA(LCID locale, /* [in] */
4153 DWORD flags, /* [in] */
4154 LPSYSTEMTIME xtime, /* [in] */
4155 LPCSTR format, /* [in] */
4156 LPSTR timestr, /* [out] */
4157 INT timelen /* [in] */)
4158 { char format_buf[40];
4161 LPSYSTEMTIME thistime;
4163 DWORD thisflags=LOCALE_STIMEFORMAT; /* standart timeformat */
4166 TRACE("GetTimeFormat(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",locale,flags,xtime,format,timestr,timelen);
4168 thislocale = OLE2NLS_CheckLocale ( locale );
4170 if ( flags & (TIME_NOTIMEMARKER | TIME_FORCE24HOURFORMAT ))
4171 { FIXME("TIME_NOTIMEMARKER or TIME_FORCE24HOURFORMAT not implemented\n");
4174 flags &= (TIME_NOSECONDS | TIME_NOMINUTESORSECONDS); /* mask for OLE_GetFormatA*/
4177 { if (flags & LOCALE_NOUSEROVERRIDE) /*use system default*/
4178 { thislocale = GetSystemDefaultLCID();
4180 GetLocaleInfoA(thislocale, thisflags, format_buf, sizeof(format_buf));
4181 thisformat = format_buf;
4184 { thisformat = format;
4187 if (xtime == NULL) /* NULL means use the current local time*/
4193 /* Check that hour,min and sec is in range */
4195 ret = OLE_GetFormatA(thislocale, thisflags, flags, thistime, thisformat,
4201 /******************************************************************************
4202 * GetTimeFormatW [KERNEL32.423]
4203 * Makes a Unicode string of the time
4206 GetTimeFormatW(LCID locale, /* [in] */
4207 DWORD flags, /* [in] */
4208 LPSYSTEMTIME xtime, /* [in] */
4209 LPCWSTR format, /* [in] */
4210 LPWSTR timestr, /* [out] */
4211 INT timelen /* [in] */)
4212 { WCHAR format_buf[40];
4215 LPSYSTEMTIME thistime;
4217 DWORD thisflags=LOCALE_STIMEFORMAT; /* standart timeformat */
4220 TRACE("GetTimeFormat(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",locale,flags,
4221 xtime,debugstr_w(format),timestr,timelen);
4223 thislocale = OLE2NLS_CheckLocale ( locale );
4225 if ( flags & (TIME_NOTIMEMARKER | TIME_FORCE24HOURFORMAT ))
4226 { FIXME("TIME_NOTIMEMARKER or TIME_FORCE24HOURFORMAT not implemented\n");
4229 flags &= (TIME_NOSECONDS | TIME_NOMINUTESORSECONDS); /* mask for OLE_GetFormatA*/
4232 { if (flags & LOCALE_NOUSEROVERRIDE) /*use system default*/
4233 { thislocale = GetSystemDefaultLCID();
4235 GetLocaleInfoW(thislocale, thisflags, format_buf, 40);
4236 thisformat = format_buf;
4239 { thisformat = format;
4242 if (xtime == NULL) /* NULL means use the current local time*/
4250 ret = OLE_GetFormatW(thislocale, thisflags, flags, thistime, thisformat,
4255 /******************************************************************************
4256 * EnumCalendarInfoA [KERNEL32.196]
4258 BOOL WINAPI EnumCalendarInfoA(
4259 CALINFO_ENUMPROCA calinfoproc,LCID locale,CALID calendar,CALTYPE caltype
4261 FIXME("(%p,0x%04lx,0x%08lx,0x%08lx),stub!\n",calinfoproc,locale,calendar,caltype);