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
19 #include "wine/unicode.h"
26 #include "debugtools.h"
28 DEFAULT_DEBUG_CHANNEL(string);
30 /* Locale name to id map. used by EnumSystemLocales, GetLocaleInfoA
31 * MUST contain all #defines from winnls.h
32 * last entry has NULL name, 0 id.
34 #define LOCALE_ENTRY(x) {#x,LOCALE_##x}
35 static const struct tagLOCALE_NAME2ID {
39 LOCALE_ENTRY(ILANGUAGE),
40 LOCALE_ENTRY(SLANGUAGE),
41 LOCALE_ENTRY(SENGLANGUAGE),
42 LOCALE_ENTRY(SABBREVLANGNAME),
43 LOCALE_ENTRY(SNATIVELANGNAME),
44 LOCALE_ENTRY(ICOUNTRY),
45 LOCALE_ENTRY(SCOUNTRY),
46 LOCALE_ENTRY(SENGCOUNTRY),
47 LOCALE_ENTRY(SABBREVCTRYNAME),
48 LOCALE_ENTRY(SNATIVECTRYNAME),
49 LOCALE_ENTRY(IDEFAULTLANGUAGE),
50 LOCALE_ENTRY(IDEFAULTCOUNTRY),
51 LOCALE_ENTRY(IDEFAULTCODEPAGE),
52 LOCALE_ENTRY(IDEFAULTANSICODEPAGE),
53 LOCALE_ENTRY(IDEFAULTMACCODEPAGE),
55 LOCALE_ENTRY(IMEASURE),
56 LOCALE_ENTRY(SDECIMAL),
57 LOCALE_ENTRY(STHOUSAND),
58 LOCALE_ENTRY(SGROUPING),
59 LOCALE_ENTRY(IDIGITS),
61 LOCALE_ENTRY(INEGNUMBER),
62 LOCALE_ENTRY(SNATIVEDIGITS),
63 LOCALE_ENTRY(SCURRENCY),
64 LOCALE_ENTRY(SINTLSYMBOL),
65 LOCALE_ENTRY(SMONDECIMALSEP),
66 LOCALE_ENTRY(SMONTHOUSANDSEP),
67 LOCALE_ENTRY(SMONGROUPING),
68 LOCALE_ENTRY(ICURRDIGITS),
69 LOCALE_ENTRY(IINTLCURRDIGITS),
70 LOCALE_ENTRY(ICURRENCY),
71 LOCALE_ENTRY(INEGCURR),
74 LOCALE_ENTRY(SSHORTDATE),
75 LOCALE_ENTRY(SLONGDATE),
76 LOCALE_ENTRY(STIMEFORMAT),
80 LOCALE_ENTRY(ITIMEMARKPOSN),
81 LOCALE_ENTRY(ICENTURY),
82 LOCALE_ENTRY(ITLZERO),
83 LOCALE_ENTRY(IDAYLZERO),
84 LOCALE_ENTRY(IMONLZERO),
87 LOCALE_ENTRY(ICALENDARTYPE),
88 LOCALE_ENTRY(IOPTIONALCALENDAR),
89 LOCALE_ENTRY(IFIRSTDAYOFWEEK),
90 LOCALE_ENTRY(IFIRSTWEEKOFYEAR),
91 LOCALE_ENTRY(SDAYNAME1),
92 LOCALE_ENTRY(SDAYNAME2),
93 LOCALE_ENTRY(SDAYNAME3),
94 LOCALE_ENTRY(SDAYNAME4),
95 LOCALE_ENTRY(SDAYNAME5),
96 LOCALE_ENTRY(SDAYNAME6),
97 LOCALE_ENTRY(SDAYNAME7),
98 LOCALE_ENTRY(SABBREVDAYNAME1),
99 LOCALE_ENTRY(SABBREVDAYNAME2),
100 LOCALE_ENTRY(SABBREVDAYNAME3),
101 LOCALE_ENTRY(SABBREVDAYNAME4),
102 LOCALE_ENTRY(SABBREVDAYNAME5),
103 LOCALE_ENTRY(SABBREVDAYNAME6),
104 LOCALE_ENTRY(SABBREVDAYNAME7),
105 LOCALE_ENTRY(SMONTHNAME1),
106 LOCALE_ENTRY(SMONTHNAME2),
107 LOCALE_ENTRY(SMONTHNAME3),
108 LOCALE_ENTRY(SMONTHNAME4),
109 LOCALE_ENTRY(SMONTHNAME5),
110 LOCALE_ENTRY(SMONTHNAME6),
111 LOCALE_ENTRY(SMONTHNAME7),
112 LOCALE_ENTRY(SMONTHNAME8),
113 LOCALE_ENTRY(SMONTHNAME9),
114 LOCALE_ENTRY(SMONTHNAME10),
115 LOCALE_ENTRY(SMONTHNAME11),
116 LOCALE_ENTRY(SMONTHNAME12),
117 LOCALE_ENTRY(SMONTHNAME13),
118 LOCALE_ENTRY(SABBREVMONTHNAME1),
119 LOCALE_ENTRY(SABBREVMONTHNAME2),
120 LOCALE_ENTRY(SABBREVMONTHNAME3),
121 LOCALE_ENTRY(SABBREVMONTHNAME4),
122 LOCALE_ENTRY(SABBREVMONTHNAME5),
123 LOCALE_ENTRY(SABBREVMONTHNAME6),
124 LOCALE_ENTRY(SABBREVMONTHNAME7),
125 LOCALE_ENTRY(SABBREVMONTHNAME8),
126 LOCALE_ENTRY(SABBREVMONTHNAME9),
127 LOCALE_ENTRY(SABBREVMONTHNAME10),
128 LOCALE_ENTRY(SABBREVMONTHNAME11),
129 LOCALE_ENTRY(SABBREVMONTHNAME12),
130 LOCALE_ENTRY(SABBREVMONTHNAME13),
131 LOCALE_ENTRY(SPOSITIVESIGN),
132 LOCALE_ENTRY(SNEGATIVESIGN),
133 LOCALE_ENTRY(IPOSSIGNPOSN),
134 LOCALE_ENTRY(INEGSIGNPOSN),
135 LOCALE_ENTRY(IPOSSYMPRECEDES),
136 LOCALE_ENTRY(IPOSSEPBYSPACE),
137 LOCALE_ENTRY(INEGSYMPRECEDES),
138 LOCALE_ENTRY(INEGSEPBYSPACE),
139 LOCALE_ENTRY(FONTSIGNATURE),
140 LOCALE_ENTRY(SISO639LANGNAME),
141 LOCALE_ENTRY(SISO3166CTRYNAME),
145 static char *GetLocaleSubkeyName( DWORD lctype );
147 /***********************************************************************
148 * GetUserDefaultLCID (KERNEL32.@)
149 * GetUserDefaultLCID (OLE2NLS.1)
151 LCID WINAPI GetUserDefaultLCID(void)
153 return MAKELCID( GetUserDefaultLangID() , SORT_DEFAULT );
156 /***********************************************************************
157 * GetSystemDefaultLCID (KERNEL32.@)
158 * GetSystemDefaultLCID (OLE2NLS.2)
160 LCID WINAPI GetSystemDefaultLCID(void)
162 return GetUserDefaultLCID();
165 #define NLS_MAX_LANGUAGES 20
169 LANGID found_lang_id[NLS_MAX_LANGUAGES];
170 char found_language[NLS_MAX_LANGUAGES][3];
171 char found_country[NLS_MAX_LANGUAGES][3];
175 static BOOL CALLBACK NLS_FindLanguageID_ProcA(HMODULE hModule, LPCSTR type,
176 LPCSTR name, WORD LangID, LONG lParam)
178 LANG_FIND_DATA *l_data = (LANG_FIND_DATA *)lParam;
179 LCID lcid = MAKELCID(LangID, SORT_DEFAULT);
180 char buf_language[128];
181 char buf_country[128];
182 char buf_en_language[128];
184 TRACE("%04X\n", (UINT)LangID);
185 if(PRIMARYLANGID(LangID) == LANG_NEUTRAL)
186 return TRUE; /* continue search */
191 GetLocaleInfoA(lcid, LOCALE_SISO639LANGNAME|LOCALE_NOUSEROVERRIDE,
192 buf_language, sizeof(buf_language));
193 TRACE("LOCALE_SISO639LANGNAME: %s\n", buf_language);
195 GetLocaleInfoA(lcid, LOCALE_SISO3166CTRYNAME|LOCALE_NOUSEROVERRIDE,
196 buf_country, sizeof(buf_country));
197 TRACE("LOCALE_SISO3166CTRYNAME: %s\n", buf_country);
199 if(l_data->lang && strlen(l_data->lang) > 0 && !strcasecmp(l_data->lang, buf_language))
201 if(l_data->country && strlen(l_data->country) > 0)
203 if(!strcasecmp(l_data->country, buf_country))
205 l_data->found_lang_id[0] = LangID;
207 TRACE("Found lang_id %04X for %s_%s\n", LangID, l_data->lang, l_data->country);
208 return FALSE; /* stop enumeration */
211 else /* l_data->country not specified */
213 if(l_data->n_found < NLS_MAX_LANGUAGES)
215 l_data->found_lang_id[l_data->n_found] = LangID;
216 strncpy(l_data->found_country[l_data->n_found], buf_country, 3);
217 strncpy(l_data->found_language[l_data->n_found], buf_language, 3);
219 TRACE("Found lang_id %04X for %s\n", LangID, l_data->lang);
220 return TRUE; /* continue search */
225 /* Just in case, check LOCALE_SENGLANGUAGE too,
226 * in hope that possible alias name might have that value.
228 buf_en_language[0] = 0;
229 GetLocaleInfoA(lcid, LOCALE_SENGLANGUAGE|LOCALE_NOUSEROVERRIDE,
230 buf_en_language, sizeof(buf_en_language));
231 TRACE("LOCALE_SENGLANGUAGE: %s\n", buf_en_language);
233 if(l_data->lang && strlen(l_data->lang) > 0 && !strcasecmp(l_data->lang, buf_en_language))
235 l_data->found_lang_id[l_data->n_found] = LangID;
236 strncpy(l_data->found_country[l_data->n_found], buf_country, 3);
237 strncpy(l_data->found_language[l_data->n_found], buf_language, 3);
239 TRACE("Found lang_id %04X for %s\n", LangID, l_data->lang);
242 return TRUE; /* continue search */
245 /***********************************************************************
249 * Lang: a string whose two first chars are the iso name of a language.
250 * Country: a string whose two first chars are the iso name of country
251 * Charset: a string defining the chossen charset encoding
252 * Dialect: a string defining a variation of the locale
254 * all those values are from the standardized format of locale
255 * name in unix which is: Lang[_Country][.Charset][@Dialect]
258 * the numeric code of the language used by Windows
260 * FIXME: Charset and Dialect are not handled
262 static LANGID NLS_GetLanguageID(LPCSTR Lang, LPCSTR Country, LPCSTR Charset, LPCSTR Dialect)
264 LANG_FIND_DATA l_data;
265 char lang_string[256];
269 l_data.found_lang_id[0] = MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT);
273 memset(&l_data, 0, sizeof(LANG_FIND_DATA));
274 strncpy(l_data.lang, Lang, sizeof(l_data.lang));
276 if(Country && strlen(Country) > 0)
277 strncpy(l_data.country, Country, sizeof(l_data.country));
279 EnumResourceLanguagesA(GetModuleHandleA("KERNEL32"), RT_STRINGA,
280 (LPCSTR)LOCALE_ILANGUAGE, NLS_FindLanguageID_ProcA, (LONG)&l_data);
282 strcpy(lang_string, l_data.lang);
283 if(l_data.country && strlen(l_data.country) > 0)
285 strcat(lang_string, "_");
286 strcat(lang_string, l_data.country);
291 if(l_data.country && strlen(l_data.country) > 0)
293 MESSAGE("Warning: Language '%s' was not found, retrying without country name...\n", lang_string);
294 l_data.country[0] = 0;
295 EnumResourceLanguagesA(GetModuleHandleA("KERNEL32"), RT_STRINGA,
296 (LPCSTR)LOCALE_ILANGUAGE, NLS_FindLanguageID_ProcA, (LONG)&l_data);
300 /* Re-evaluate lang_string */
301 strcpy(lang_string, l_data.lang);
302 if(l_data.country && strlen(l_data.country) > 0)
304 strcat(lang_string, "_");
305 strcat(lang_string, l_data.country);
310 MESSAGE("Warning: Language '%s' was not recognized, defaulting to English\n", lang_string);
311 l_data.found_lang_id[0] = MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT);
315 if(l_data.n_found == 1)
316 TRACE("For language '%s' lang_id %04X was found\n", lang_string, l_data.found_lang_id[0]);
317 else /* l_data->n_found > 1 */
320 MESSAGE("For language '%s' several language ids were found:\n", lang_string);
321 for(i = 0; i < l_data.n_found; i++)
322 MESSAGE("%s_%s - %04X; ", l_data.found_language[i], l_data.found_country[i], l_data.found_lang_id[i]);
324 MESSAGE("\nInstead of using first in the list, suggest to define\n"
325 "your LANG environment variable like this: LANG=%s_%s\n",
326 l_data.found_language[0], l_data.found_country[0]);
330 TRACE("Returning %04X\n", l_data.found_lang_id[0]);
331 return l_data.found_lang_id[0];
334 /***********************************************************************
335 * GetUserDefaultLangID (KERNEL32.@)
336 * GetUserDefaultLangID (OLE2NLS.3)
338 LANGID WINAPI GetUserDefaultLangID(void)
340 /* caching result, if defined from environment, which should (?) not change during a WINE session */
341 static LANGID userLCID = 0;
346 char *lang,*country,*charset,*dialect,*next;
348 if (GetEnvironmentVariableA( "LANGUAGE", buf, sizeof(buf) )) goto ok;
349 if (GetEnvironmentVariableA( "LANG", buf, sizeof(buf) )) goto ok;
350 if (GetEnvironmentVariableA( "LC_ALL", buf, sizeof(buf) )) goto ok;
351 if (GetEnvironmentVariableA( "LC_MESSAGES", buf, sizeof(buf) )) goto ok;
352 if (GetEnvironmentVariableA( "LC_CTYPE", buf, sizeof(buf) )) goto ok;
354 return userLCID = MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT );
357 if (!strcmp(buf,"POSIX") || !strcmp(buf,"C"))
358 return userLCID = MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT );
363 next=strchr(lang,':'); if (next) *next++='\0';
364 dialect=strchr(lang,'@'); if (dialect) *dialect++='\0';
365 charset=strchr(lang,'.'); if (charset) *charset++='\0';
366 country=strchr(lang,'_'); if (country) *country++='\0';
368 userLCID = NLS_GetLanguageID(lang, country, charset, dialect);
371 } while (lang && !userLCID);
375 MESSAGE( "Warning: language '%s' not recognized, defaulting to English\n",
377 userLCID = MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT );
383 /***********************************************************************
384 * GetSystemDefaultLangID (KERNEL32.@)
385 * GetSystemDefaultLangID (OLE2NLS.4)
387 LANGID WINAPI GetSystemDefaultLangID(void)
389 return GetUserDefaultLangID();
392 /******************************************************************************
393 * ConvertDefaultLocale (KERNEL32.@)
395 LCID WINAPI ConvertDefaultLocale (LCID lcid)
397 { case LOCALE_SYSTEM_DEFAULT:
398 return GetSystemDefaultLCID();
399 case LOCALE_USER_DEFAULT:
400 return GetUserDefaultLCID();
402 return MAKELCID (LANG_NEUTRAL, SUBLANG_NEUTRAL);
404 return MAKELANGID( PRIMARYLANGID(lcid), SUBLANG_NEUTRAL);
407 /* Enhanced version of LoadStringW.
408 * It takes LanguageId to find and load language dependant resources.
409 * Resource is copied as is: "binary" strings are not truncated.
410 * Return: length of resource + 1 to distinguish absent resources
411 * from the resources with zero length.
413 static INT NLS_LoadStringExW(HMODULE hModule, LANGID lang_id, UINT res_id, LPWSTR buffer, INT buflen)
421 /* Replace SUBLANG_NEUTRAL by SUBLANG_DEFAULT */
422 if(SUBLANGID(lang_id) == SUBLANG_NEUTRAL)
423 lang_id = MAKELANGID(PRIMARYLANGID(lang_id), SUBLANG_DEFAULT);
425 hrsrc = FindResourceExW(hModule, RT_STRINGW, (LPCWSTR)((res_id >> 4) + 1), lang_id);
428 hmem = LoadResource(hModule, hrsrc);
431 p = LockResource(hmem);
432 string_num = res_id & 0x000f;
433 for(i = 0; i < string_num; i++)
436 TRACE("strlen = %d\n", (int)*p );
438 if (buffer == NULL) return *p;
439 i = min(buflen - 1, *p);
441 memcpy(buffer, p + 1, i * sizeof (WCHAR));
442 buffer[i] = (WCHAR) 0;
445 buffer[0] = (WCHAR) 0;
449 TRACE("%s loaded!\n", debugstr_w(buffer));
453 /******************************************************************************
454 * GetLocaleInfoA (KERNEL32.@)
457 * LANG_NEUTRAL is equal to LOCALE_SYSTEM_DEFAULT
459 * MS online documentation states that the string returned is NULL terminated
460 * except for LOCALE_FONTSIGNATURE which "will return a non-NULL
461 * terminated string".
463 INT WINAPI GetLocaleInfoA(LCID lcid,LCTYPE LCType,LPSTR buf,INT len)
465 LPCSTR retString = NULL;
469 DWORD dwBufferSize=128;
472 TRACE("(lcid=0x%lx,lctype=0x%lx,%p,%x)\n",lcid,LCType,buf,len);
474 if (len && (! buf) ) {
475 SetLastError(ERROR_INSUFFICIENT_BUFFER);
479 if (lcid == LOCALE_NEUTRAL || lcid == LANG_SYSTEM_DEFAULT)
481 lcid = GetSystemDefaultLCID();
483 else if (lcid == LANG_USER_DEFAULT) /*0x800*/
485 lcid = GetUserDefaultLCID();
488 /* LOCALE_NOUSEROVERRIDE means: do not get user redefined settings
489 from the registry. Instead, use system default values. */
490 NoUserOverride = (LCType & LOCALE_NOUSEROVERRIDE) != 0;
492 LCType &= ~(LOCALE_NOUSEROVERRIDE|LOCALE_USE_CP_ACP);
494 /* First, check if it's in the registry. */
495 /* All user customized values are stored in the registry by SetLocaleInfo */
496 if ( !NoUserOverride && (pacKey = GetLocaleSubkeyName(LCType)) )
501 sprintf( acRealKey, "Control Panel\\International\\%s", pacKey );
503 if ( RegOpenKeyExA( HKEY_CURRENT_USER, acRealKey,
504 0, KEY_READ, &hKey) == ERROR_SUCCESS )
506 if ( RegQueryValueExA( hKey, NULL, NULL, NULL, (LPBYTE)acBuffer,
507 &dwBufferSize ) == ERROR_SUCCESS )
509 retString = acBuffer;
516 /* If not in the registry, get it from the NLS entries. */
521 /* check if language is registered in the kernel32 resources */
522 if((res_size = NLS_LoadStringExW(GetModuleHandleA("KERNEL32"), LANGIDFROMLCID(lcid),
523 LCType, wcBuffer, sizeof(wcBuffer)/sizeof(wcBuffer[0])))) {
524 WideCharToMultiByte(CP_ACP, 0, wcBuffer, res_size, acBuffer, dwBufferSize, NULL, NULL);
525 retString = acBuffer;
530 /* if not found report a most descriptive error */
533 /* If we are through all of this, retLen should not be zero anymore.
534 If it is, the value is not supported */
536 while (locale_name2id[i].name!=NULL) {
537 if (LCType == locale_name2id[i].id) {
538 retString = locale_name2id[i].name;
544 FIXME("Unkown LC type %lX\n", LCType);
546 FIXME("'%s' is not defined for your language (%04X).\n"
547 "Please define it in dlls/kernel/nls/YourLanguage.nls\n"
548 "and submit patch for inclusion into the next Wine release.\n",
549 retString, LOWORD(lcid));
550 SetLastError(ERROR_INVALID_PARAMETER);
554 /* a FONTSIGNATURE is not a string, just 6 DWORDs */
555 if (LCType == LOCALE_FONTSIGNATURE) {
557 len = (len < sizeof(FONTSIGNATURE)) ? len : sizeof(FONTSIGNATURE);
558 memcpy(buf, retString, len);
561 return sizeof(FONTSIGNATURE);
563 /* if len=0 return only the length, don't touch the buffer*/
565 lstrcpynA(buf,retString,len);
566 return strlen(buf) + 1;
568 return strlen(retString)+1;
571 /******************************************************************************
572 * GetLocaleInfoW (KERNEL32.@)
575 * MS documentation states that len "specifies the size, in bytes (ANSI version)
576 * or characters (Unicode version), of" wbuf. Thus the number returned is
577 * the same between GetLocaleInfoW and GetLocaleInfoA.
579 INT WINAPI GetLocaleInfoW(LCID lcid,LCTYPE LCType,LPWSTR wbuf,INT len)
583 if (len && (! wbuf) )
584 { SetLastError(ERROR_INSUFFICIENT_BUFFER);
588 abuf = (LPSTR)HeapAlloc(GetProcessHeap(),0,len);
589 wlen = GetLocaleInfoA(lcid, LCType, abuf, len);
591 if (wlen && len) /* if len=0 return only the length*/
592 MultiByteToWideChar( CP_ACP, 0, abuf, -1, wbuf, len );
594 HeapFree(GetProcessHeap(),0,abuf);
598 /******************************************************************************
600 * GetLocaleSubkeyName [helper function]
602 * - For use with the registry.
603 * - Gets the registry subkey name for a given lctype.
605 static char *GetLocaleSubkeyName( DWORD lctype )
611 /* These values are used by SetLocaleInfo and GetLocaleInfo, and
612 * the values are stored in the registry, confirmed under Windows,
613 * for the ones that actually assign pacKey. Cases that aren't finished
614 * have not been confirmed, so that must be done before they can be
617 case LOCALE_SDATE : /* The date separator. */
620 case LOCALE_ICURRDIGITS:
621 pacKey = "iCurrDigits";
623 case LOCALE_SDECIMAL :
626 case LOCALE_ICURRENCY:
627 pacKey = "iCurrency";
629 case LOCALE_SGROUPING :
630 pacKey = "sGrouping";
638 /* case LOCALE_ICALENDARTYPE: */
639 /* case LOCALE_IFIRSTDAYOFWEEK: */
640 /* case LOCALE_IFIRSTWEEKOFYEAR: */
641 /* case LOCALE_SYEARMONTH : */
642 /* case LOCALE_SPOSITIVESIGN : */
643 /* case LOCALE_IPAPERSIZE: */
645 case LOCALE_SLONGDATE :
646 pacKey = "sLongDate";
648 case LOCALE_SMONDECIMALSEP :
649 pacKey = "sMonDecimalSep";
651 case LOCALE_SMONGROUPING:
652 pacKey = "sMonGrouping";
654 case LOCALE_IMEASURE:
657 case LOCALE_SMONTHOUSANDSEP :
658 pacKey = "sMonThousandSep";
660 case LOCALE_INEGCURR:
663 case LOCALE_SNEGATIVESIGN :
664 pacKey = "sNegativeSign";
666 case LOCALE_INEGNUMBER:
667 pacKey = "iNegNumber";
669 case LOCALE_SSHORTDATE :
670 pacKey = "sShortDate";
672 case LOCALE_ILDATE: /* Long Date format ordering specifier. */
681 case LOCALE_ITIME: /* Time format specifier. */
684 case LOCALE_STHOUSAND :
685 pacKey = "sThousand";
687 case LOCALE_S1159: /* AM */
693 case LOCALE_S2359: /* PM */
696 case LOCALE_STIMEFORMAT :
697 pacKey = "sTimeFormat";
699 case LOCALE_SCURRENCY:
700 pacKey = "sCurrency";
703 /* The following are not listed under MSDN as supported,
704 * but seem to be used and also stored in the registry.
710 case LOCALE_SCOUNTRY:
713 case LOCALE_ICOUNTRY:
716 case LOCALE_SLANGUAGE:
717 pacKey = "sLanguage";
727 /******************************************************************************
728 * SetLocaleInfoA [KERNEL32.@]
730 BOOL WINAPI SetLocaleInfoA(DWORD lcid, DWORD lctype, LPCSTR data)
736 if ( (pacKey = GetLocaleSubkeyName(lctype)) )
738 sprintf( acRealKey, "Control Panel\\International\\%s", pacKey );
739 if ( RegCreateKeyA( HKEY_CURRENT_USER, acRealKey,
740 &hKey ) == ERROR_SUCCESS )
742 if ( RegSetValueExA( hKey, NULL, 0, REG_SZ,
743 data, strlen(data)+1 ) != ERROR_SUCCESS )
745 ERR("SetLocaleInfoA: %s did not work\n", pacKey );
752 FIXME("(%ld,%ld,%s): stub\n",lcid,lctype,data);
757 /******************************************************************************
758 * IsValidLocale [KERNEL32.@]
760 BOOL WINAPI IsValidLocale(LCID lcid,DWORD flags)
762 /* check if language is registered in the kernel32 resources */
763 if(!FindResourceExW(GetModuleHandleA("KERNEL32"), RT_STRINGW, (LPCWSTR)LOCALE_ILANGUAGE, LOWORD(lcid)))
769 static BOOL CALLBACK EnumResourceLanguagesProcW(HMODULE hModule, LPCWSTR type,
770 LPCWSTR name, WORD LangID, LONG lParam)
774 LOCALE_ENUMPROCW lpfnLocaleEnum = (LOCALE_ENUMPROCW)lParam;
775 sprintf(bufA, "%08X", (UINT)LangID);
776 MultiByteToWideChar(CP_ACP, 0, bufA, -1, bufW, sizeof(bufW)/sizeof(bufW[0]));
777 return lpfnLocaleEnum(bufW);
780 /******************************************************************************
781 * EnumSystemLocalesW [KERNEL32.@]
783 BOOL WINAPI EnumSystemLocalesW( LOCALE_ENUMPROCW lpfnLocaleEnum,
786 TRACE("(%p,%08lx)\n", lpfnLocaleEnum,flags);
788 EnumResourceLanguagesW(GetModuleHandleA("KERNEL32"), RT_STRINGW,
789 (LPCWSTR)LOCALE_ILANGUAGE, EnumResourceLanguagesProcW,
790 (LONG)lpfnLocaleEnum);
795 static BOOL CALLBACK EnumResourceLanguagesProcA(HMODULE hModule, LPCSTR type,
796 LPCSTR name, WORD LangID, LONG lParam)
799 LOCALE_ENUMPROCA lpfnLocaleEnum = (LOCALE_ENUMPROCA)lParam;
800 sprintf(bufA, "%08X", (UINT)LangID);
801 return lpfnLocaleEnum(bufA);
804 /******************************************************************************
805 * EnumSystemLocalesA [KERNEL32.@]
807 BOOL WINAPI EnumSystemLocalesA(LOCALE_ENUMPROCA lpfnLocaleEnum,
810 TRACE("(%p,%08lx)\n", lpfnLocaleEnum,flags);
812 EnumResourceLanguagesA(GetModuleHandleA("KERNEL32"), RT_STRINGA,
813 (LPCSTR)LOCALE_ILANGUAGE, EnumResourceLanguagesProcA,
814 (LONG)lpfnLocaleEnum);
819 static const unsigned char CT_CType2_LUT[] = {
820 C2_NOTAPPLICABLE, /* - 0 */
821 C2_NOTAPPLICABLE, /* - 1 */
822 C2_NOTAPPLICABLE, /* - 2 */
823 C2_NOTAPPLICABLE, /* - 3 */
824 C2_NOTAPPLICABLE, /* - 4 */
825 C2_NOTAPPLICABLE, /* - 5 */
826 C2_NOTAPPLICABLE, /* - 6 */
827 C2_NOTAPPLICABLE, /* - 7 */
828 C2_NOTAPPLICABLE, /* - 8 */
829 C2_SEGMENTSEPARATOR, /* - 9 */
830 C2_NOTAPPLICABLE, /* - 10 */
831 C2_NOTAPPLICABLE, /* - 11 */
832 C2_NOTAPPLICABLE, /* - 12 */
833 C2_NOTAPPLICABLE, /* - 13 */
834 C2_NOTAPPLICABLE, /* - 14 */
835 C2_NOTAPPLICABLE, /* - 15 */
836 C2_NOTAPPLICABLE, /* - 16 */
837 C2_NOTAPPLICABLE, /* - 17 */
838 C2_NOTAPPLICABLE, /* - 18 */
839 C2_NOTAPPLICABLE, /* - 19 */
840 C2_NOTAPPLICABLE, /* - 20 */
841 C2_NOTAPPLICABLE, /* - 21 */
842 C2_NOTAPPLICABLE, /* - 22 */
843 C2_NOTAPPLICABLE, /* - 23 */
844 C2_NOTAPPLICABLE, /* - 24 */
845 C2_NOTAPPLICABLE, /* - 25 */
846 C2_NOTAPPLICABLE, /* - 26 */
847 C2_NOTAPPLICABLE, /* - 27 */
848 C2_NOTAPPLICABLE, /* - 28 */
849 C2_NOTAPPLICABLE, /* - 29 */
850 C2_NOTAPPLICABLE, /* - 30 */
851 C2_NOTAPPLICABLE, /* - 31 */
852 C2_WHITESPACE, /* - 32 */
853 C2_OTHERNEUTRAL, /* ! - 33 */
854 C2_OTHERNEUTRAL, /* " - 34 */ /* " */
855 C2_EUROPETERMINATOR, /* # - 35 */
856 C2_EUROPETERMINATOR, /* $ - 36 */
857 C2_EUROPETERMINATOR, /* % - 37 */
858 C2_LEFTTORIGHT, /* & - 38 */
859 C2_OTHERNEUTRAL, /* ' - 39 */
860 C2_OTHERNEUTRAL, /* ( - 40 */
861 C2_OTHERNEUTRAL, /* ) - 41 */
862 C2_OTHERNEUTRAL, /* * - 42 */
863 C2_EUROPETERMINATOR, /* + - 43 */
864 C2_COMMONSEPARATOR, /* , - 44 */
865 C2_EUROPETERMINATOR, /* - - 45 */
866 C2_EUROPESEPARATOR, /* . - 46 */
867 C2_EUROPESEPARATOR, /* / - 47 */
868 C2_EUROPENUMBER, /* 0 - 48 */
869 C2_EUROPENUMBER, /* 1 - 49 */
870 C2_EUROPENUMBER, /* 2 - 50 */
871 C2_EUROPENUMBER, /* 3 - 51 */
872 C2_EUROPENUMBER, /* 4 - 52 */
873 C2_EUROPENUMBER, /* 5 - 53 */
874 C2_EUROPENUMBER, /* 6 - 54 */
875 C2_EUROPENUMBER, /* 7 - 55 */
876 C2_EUROPENUMBER, /* 8 - 56 */
877 C2_EUROPENUMBER, /* 9 - 57 */
878 C2_COMMONSEPARATOR, /* : - 58 */
879 C2_OTHERNEUTRAL, /* ; - 59 */
880 C2_OTHERNEUTRAL, /* < - 60 */
881 C2_OTHERNEUTRAL, /* = - 61 */
882 C2_OTHERNEUTRAL, /* > - 62 */
883 C2_OTHERNEUTRAL, /* ? - 63 */
884 C2_LEFTTORIGHT, /* @ - 64 */
885 C2_LEFTTORIGHT, /* A - 65 */
886 C2_LEFTTORIGHT, /* B - 66 */
887 C2_LEFTTORIGHT, /* C - 67 */
888 C2_LEFTTORIGHT, /* D - 68 */
889 C2_LEFTTORIGHT, /* E - 69 */
890 C2_LEFTTORIGHT, /* F - 70 */
891 C2_LEFTTORIGHT, /* G - 71 */
892 C2_LEFTTORIGHT, /* H - 72 */
893 C2_LEFTTORIGHT, /* I - 73 */
894 C2_LEFTTORIGHT, /* J - 74 */
895 C2_LEFTTORIGHT, /* K - 75 */
896 C2_LEFTTORIGHT, /* L - 76 */
897 C2_LEFTTORIGHT, /* M - 77 */
898 C2_LEFTTORIGHT, /* N - 78 */
899 C2_LEFTTORIGHT, /* O - 79 */
900 C2_LEFTTORIGHT, /* P - 80 */
901 C2_LEFTTORIGHT, /* Q - 81 */
902 C2_LEFTTORIGHT, /* R - 82 */
903 C2_LEFTTORIGHT, /* S - 83 */
904 C2_LEFTTORIGHT, /* T - 84 */
905 C2_LEFTTORIGHT, /* U - 85 */
906 C2_LEFTTORIGHT, /* V - 86 */
907 C2_LEFTTORIGHT, /* W - 87 */
908 C2_LEFTTORIGHT, /* X - 88 */
909 C2_LEFTTORIGHT, /* Y - 89 */
910 C2_LEFTTORIGHT, /* Z - 90 */
911 C2_OTHERNEUTRAL, /* [ - 91 */
912 C2_OTHERNEUTRAL, /* \ - 92 */
913 C2_OTHERNEUTRAL, /* ] - 93 */
914 C2_OTHERNEUTRAL, /* ^ - 94 */
915 C2_OTHERNEUTRAL, /* _ - 95 */
916 C2_OTHERNEUTRAL, /* ` - 96 */
917 C2_LEFTTORIGHT, /* a - 97 */
918 C2_LEFTTORIGHT, /* b - 98 */
919 C2_LEFTTORIGHT, /* c - 99 */
920 C2_LEFTTORIGHT, /* d - 100 */
921 C2_LEFTTORIGHT, /* e - 101 */
922 C2_LEFTTORIGHT, /* f - 102 */
923 C2_LEFTTORIGHT, /* g - 103 */
924 C2_LEFTTORIGHT, /* h - 104 */
925 C2_LEFTTORIGHT, /* i - 105 */
926 C2_LEFTTORIGHT, /* j - 106 */
927 C2_LEFTTORIGHT, /* k - 107 */
928 C2_LEFTTORIGHT, /* l - 108 */
929 C2_LEFTTORIGHT, /* m - 109 */
930 C2_LEFTTORIGHT, /* n - 110 */
931 C2_LEFTTORIGHT, /* o - 111 */
932 C2_LEFTTORIGHT, /* p - 112 */
933 C2_LEFTTORIGHT, /* q - 113 */
934 C2_LEFTTORIGHT, /* r - 114 */
935 C2_LEFTTORIGHT, /* s - 115 */
936 C2_LEFTTORIGHT, /* t - 116 */
937 C2_LEFTTORIGHT, /* u - 117 */
938 C2_LEFTTORIGHT, /* v - 118 */
939 C2_LEFTTORIGHT, /* w - 119 */
940 C2_LEFTTORIGHT, /* x - 120 */
941 C2_LEFTTORIGHT, /* y - 121 */
942 C2_LEFTTORIGHT, /* z - 122 */
943 C2_OTHERNEUTRAL, /* { - 123 */
944 C2_OTHERNEUTRAL, /* | - 124 */
945 C2_OTHERNEUTRAL, /* } - 125 */
946 C2_OTHERNEUTRAL, /* ~ - 126 */
947 C2_NOTAPPLICABLE, /*
\7f - 127 */
948 C2_NOTAPPLICABLE, /*
\80 - 128 */
949 C2_NOTAPPLICABLE, /*
\81 - 129 */
950 C2_OTHERNEUTRAL, /*
\82 - 130 */
951 C2_LEFTTORIGHT, /*
\83 - 131 */
952 C2_OTHERNEUTRAL, /*
\84 - 132 */
953 C2_OTHERNEUTRAL, /*
\85 - 133 */
954 C2_OTHERNEUTRAL, /*
\86 - 134 */
955 C2_OTHERNEUTRAL, /*
\87 - 135 */
956 C2_LEFTTORIGHT, /*
\88 - 136 */
957 C2_EUROPETERMINATOR, /*
\89 - 137 */
958 C2_LEFTTORIGHT, /*
\8a - 138 */
959 C2_OTHERNEUTRAL, /*
\8b - 139 */
960 C2_LEFTTORIGHT, /*
\8c - 140 */
961 C2_NOTAPPLICABLE, /*
\8d - 141 */
962 C2_NOTAPPLICABLE, /*
\8e - 142 */
963 C2_NOTAPPLICABLE, /*
\8f - 143 */
964 C2_NOTAPPLICABLE, /*
\90 - 144 */
965 C2_OTHERNEUTRAL, /*
\91 - 145 */
966 C2_OTHERNEUTRAL, /*
\92 - 146 */
967 C2_OTHERNEUTRAL, /*
\93 - 147 */
968 C2_OTHERNEUTRAL, /*
\94 - 148 */
969 C2_OTHERNEUTRAL, /*
\95 - 149 */
970 C2_OTHERNEUTRAL, /*
\96 - 150 */
971 C2_OTHERNEUTRAL, /*
\97 - 151 */
972 C2_LEFTTORIGHT, /*
\98 - 152 */
973 C2_OTHERNEUTRAL, /*
\99 - 153 */
974 C2_LEFTTORIGHT, /*
\9a - 154 */
975 C2_OTHERNEUTRAL, /*
\9b - 155 */
976 C2_LEFTTORIGHT, /*
\9c - 156 */
977 C2_NOTAPPLICABLE, /*
\9d - 157 */
978 C2_NOTAPPLICABLE, /*
\9e - 158 */
979 C2_LEFTTORIGHT, /*
\9f - 159 */
980 C2_WHITESPACE, /* - 160 */
981 C2_OTHERNEUTRAL, /* ¡ - 161 */
982 C2_EUROPETERMINATOR, /* ¢ - 162 */
983 C2_EUROPETERMINATOR, /* £ - 163 */
984 C2_EUROPETERMINATOR, /* ¤ - 164 */
985 C2_EUROPETERMINATOR, /* ¥ - 165 */
986 C2_OTHERNEUTRAL, /* ¦ - 166 */
987 C2_OTHERNEUTRAL, /* § - 167 */
988 C2_OTHERNEUTRAL, /* ¨ - 168 */
989 C2_OTHERNEUTRAL, /* © - 169 */
990 C2_OTHERNEUTRAL, /* ª - 170 */
991 C2_OTHERNEUTRAL, /* « - 171 */
992 C2_OTHERNEUTRAL, /* ¬ - 172 */
993 C2_OTHERNEUTRAL, /* - 173 */
994 C2_OTHERNEUTRAL, /* ® - 174 */
995 C2_OTHERNEUTRAL, /* ¯ - 175 */
996 C2_EUROPETERMINATOR, /* ° - 176 */
997 C2_EUROPETERMINATOR, /* ± - 177 */
998 C2_EUROPENUMBER, /* ² - 178 */
999 C2_EUROPENUMBER, /* ³ - 179 */
1000 C2_OTHERNEUTRAL, /* ´ - 180 */
1001 C2_OTHERNEUTRAL, /* µ - 181 */
1002 C2_OTHERNEUTRAL, /* ¶ - 182 */
1003 C2_OTHERNEUTRAL, /* · - 183 */
1004 C2_OTHERNEUTRAL, /* ¸ - 184 */
1005 C2_EUROPENUMBER, /* ¹ - 185 */
1006 C2_OTHERNEUTRAL, /* º - 186 */
1007 C2_OTHERNEUTRAL, /* » - 187 */
1008 C2_OTHERNEUTRAL, /* ¼ - 188 */
1009 C2_OTHERNEUTRAL, /* ½ - 189 */
1010 C2_OTHERNEUTRAL, /* ¾ - 190 */
1011 C2_OTHERNEUTRAL, /* ¿ - 191 */
1012 C2_LEFTTORIGHT, /* À - 192 */
1013 C2_LEFTTORIGHT, /* Á - 193 */
1014 C2_LEFTTORIGHT, /* Â - 194 */
1015 C2_LEFTTORIGHT, /* Ã - 195 */
1016 C2_LEFTTORIGHT, /* Ä - 196 */
1017 C2_LEFTTORIGHT, /* Å - 197 */
1018 C2_LEFTTORIGHT, /* Æ - 198 */
1019 C2_LEFTTORIGHT, /* Ç - 199 */
1020 C2_LEFTTORIGHT, /* È - 200 */
1021 C2_LEFTTORIGHT, /* É - 201 */
1022 C2_LEFTTORIGHT, /* Ê - 202 */
1023 C2_LEFTTORIGHT, /* Ë - 203 */
1024 C2_LEFTTORIGHT, /* Ì - 204 */
1025 C2_LEFTTORIGHT, /* Í - 205 */
1026 C2_LEFTTORIGHT, /* Î - 206 */
1027 C2_LEFTTORIGHT, /* Ï - 207 */
1028 C2_LEFTTORIGHT, /* Ð - 208 */
1029 C2_LEFTTORIGHT, /* Ñ - 209 */
1030 C2_LEFTTORIGHT, /* Ò - 210 */
1031 C2_LEFTTORIGHT, /* Ó - 211 */
1032 C2_LEFTTORIGHT, /* Ô - 212 */
1033 C2_LEFTTORIGHT, /* Õ - 213 */
1034 C2_LEFTTORIGHT, /* Ö - 214 */
1035 C2_OTHERNEUTRAL, /* × - 215 */
1036 C2_LEFTTORIGHT, /* Ø - 216 */
1037 C2_LEFTTORIGHT, /* Ù - 217 */
1038 C2_LEFTTORIGHT, /* Ú - 218 */
1039 C2_LEFTTORIGHT, /* Û - 219 */
1040 C2_LEFTTORIGHT, /* Ü - 220 */
1041 C2_LEFTTORIGHT, /* Ý - 221 */
1042 C2_LEFTTORIGHT, /* Þ - 222 */
1043 C2_LEFTTORIGHT, /* ß - 223 */
1044 C2_LEFTTORIGHT, /* à - 224 */
1045 C2_LEFTTORIGHT, /* á - 225 */
1046 C2_LEFTTORIGHT, /* â - 226 */
1047 C2_LEFTTORIGHT, /* ã - 227 */
1048 C2_LEFTTORIGHT, /* ä - 228 */
1049 C2_LEFTTORIGHT, /* å - 229 */
1050 C2_LEFTTORIGHT, /* æ - 230 */
1051 C2_LEFTTORIGHT, /* ç - 231 */
1052 C2_LEFTTORIGHT, /* è - 232 */
1053 C2_LEFTTORIGHT, /* é - 233 */
1054 C2_LEFTTORIGHT, /* ê - 234 */
1055 C2_LEFTTORIGHT, /* ë - 235 */
1056 C2_LEFTTORIGHT, /* ì - 236 */
1057 C2_LEFTTORIGHT, /* í - 237 */
1058 C2_LEFTTORIGHT, /* î - 238 */
1059 C2_LEFTTORIGHT, /* ï - 239 */
1060 C2_LEFTTORIGHT, /* ð - 240 */
1061 C2_LEFTTORIGHT, /* ñ - 241 */
1062 C2_LEFTTORIGHT, /* ò - 242 */
1063 C2_LEFTTORIGHT, /* ó - 243 */
1064 C2_LEFTTORIGHT, /* ô - 244 */
1065 C2_LEFTTORIGHT, /* õ - 245 */
1066 C2_LEFTTORIGHT, /* ö - 246 */
1067 C2_OTHERNEUTRAL, /* ÷ - 247 */
1068 C2_LEFTTORIGHT, /* ø - 248 */
1069 C2_LEFTTORIGHT, /* ù - 249 */
1070 C2_LEFTTORIGHT, /* ú - 250 */
1071 C2_LEFTTORIGHT, /* û - 251 */
1072 C2_LEFTTORIGHT, /* ü - 252 */
1073 C2_LEFTTORIGHT, /* ý - 253 */
1074 C2_LEFTTORIGHT, /* þ - 254 */
1075 C2_LEFTTORIGHT /* ÿ - 255 */
1078 const WORD OLE2NLS_CT_CType3_LUT[] = {
1112 0x0048, /* ! - 33 */
1113 0x0448, /* " - 34 */ /* " */
1114 0x0048, /* # - 35 */
1115 0x0448, /* $ - 36 */
1116 0x0048, /* % - 37 */
1117 0x0048, /* & - 38 */
1118 0x0440, /* ' - 39 */
1119 0x0048, /* ( - 40 */
1120 0x0048, /* ) - 41 */
1121 0x0048, /* * - 42 */
1122 0x0048, /* + - 43 */
1123 0x0048, /* , - 44 */
1124 0x0440, /* - - 45 */
1125 0x0048, /* . - 46 */
1126 0x0448, /* / - 47 */
1127 0x0040, /* 0 - 48 */
1128 0x0040, /* 1 - 49 */
1129 0x0040, /* 2 - 50 */
1130 0x0040, /* 3 - 51 */
1131 0x0040, /* 4 - 52 */
1132 0x0040, /* 5 - 53 */
1133 0x0040, /* 6 - 54 */
1134 0x0040, /* 7 - 55 */
1135 0x0040, /* 8 - 56 */
1136 0x0040, /* 9 - 57 */
1137 0x0048, /* : - 58 */
1138 0x0048, /* ; - 59 */
1139 0x0048, /* < - 60 */
1140 0x0448, /* = - 61 */
1141 0x0048, /* > - 62 */
1142 0x0048, /* ? - 63 */
1143 0x0448, /* @ - 64 */
1144 0x8040, /* A - 65 */
1145 0x8040, /* B - 66 */
1146 0x8040, /* C - 67 */
1147 0x8040, /* D - 68 */
1148 0x8040, /* E - 69 */
1149 0x8040, /* F - 70 */
1150 0x8040, /* G - 71 */
1151 0x8040, /* H - 72 */
1152 0x8040, /* I - 73 */
1153 0x8040, /* J - 74 */
1154 0x8040, /* K - 75 */
1155 0x8040, /* L - 76 */
1156 0x8040, /* M - 77 */
1157 0x8040, /* N - 78 */
1158 0x8040, /* O - 79 */
1159 0x8040, /* P - 80 */
1160 0x8040, /* Q - 81 */
1161 0x8040, /* R - 82 */
1162 0x8040, /* S - 83 */
1163 0x8040, /* T - 84 */
1164 0x8040, /* U - 85 */
1165 0x8040, /* V - 86 */
1166 0x8040, /* W - 87 */
1167 0x8040, /* X - 88 */
1168 0x8040, /* Y - 89 */
1169 0x8040, /* Z - 90 */
1170 0x0048, /* [ - 91 */
1171 0x0448, /* \ - 92 */
1172 0x0048, /* ] - 93 */
1173 0x0448, /* ^ - 94 */
1174 0x0448, /* _ - 95 */
1175 0x0448, /* ` - 96 */
1176 0x8040, /* a - 97 */
1177 0x8040, /* b - 98 */
1178 0x8040, /* c - 99 */
1179 0x8040, /* d - 100 */
1180 0x8040, /* e - 101 */
1181 0x8040, /* f - 102 */
1182 0x8040, /* g - 103 */
1183 0x8040, /* h - 104 */
1184 0x8040, /* i - 105 */
1185 0x8040, /* j - 106 */
1186 0x8040, /* k - 107 */
1187 0x8040, /* l - 108 */
1188 0x8040, /* m - 109 */
1189 0x8040, /* n - 110 */
1190 0x8040, /* o - 111 */
1191 0x8040, /* p - 112 */
1192 0x8040, /* q - 113 */
1193 0x8040, /* r - 114 */
1194 0x8040, /* s - 115 */
1195 0x8040, /* t - 116 */
1196 0x8040, /* u - 117 */
1197 0x8040, /* v - 118 */
1198 0x8040, /* w - 119 */
1199 0x8040, /* x - 120 */
1200 0x8040, /* y - 121 */
1201 0x8040, /* z - 122 */
1202 0x0048, /* { - 123 */
1203 0x0048, /* | - 124 */
1204 0x0048, /* } - 125 */
1205 0x0448, /* ~ - 126 */
1206 0x0000, /*
\7f - 127 */
1207 0x0000, /*
\80 - 128 */
1208 0x0000, /*
\81 - 129 */
1209 0x0008, /*
\82 - 130 */
1210 0x8000, /*
\83 - 131 */
1211 0x0008, /*
\84 - 132 */
1212 0x0008, /*
\85 - 133 */
1213 0x0008, /*
\86 - 134 */
1214 0x0008, /*
\87 - 135 */
1215 0x0001, /*
\88 - 136 */
1216 0x0008, /*
\89 - 137 */
1217 0x8003, /*
\8a - 138 */
1218 0x0008, /*
\8b - 139 */
1219 0x8000, /*
\8c - 140 */
1220 0x0000, /*
\8d - 141 */
1221 0x0000, /*
\8e - 142 */
1222 0x0000, /*
\8f - 143 */
1223 0x0000, /*
\90 - 144 */
1224 0x0088, /*
\91 - 145 */
1225 0x0088, /*
\92 - 146 */
1226 0x0088, /*
\93 - 147 */
1227 0x0088, /*
\94 - 148 */
1228 0x0008, /*
\95 - 149 */
1229 0x0400, /*
\96 - 150 */
1230 0x0400, /*
\97 - 151 */
1231 0x0408, /*
\98 - 152 */
1232 0x0000, /*
\99 - 153 */
1233 0x8003, /*
\9a - 154 */
1234 0x0008, /*
\9b - 155 */
1235 0x8000, /*
\9c - 156 */
1236 0x0000, /*
\9d - 157 */
1237 0x0000, /*
\9e - 158 */
1238 0x8003, /*
\9f - 159 */
1240 0x0008, /* ¡ - 161 */
1241 0x0048, /* ¢ - 162 */
1242 0x0048, /* £ - 163 */
1243 0x0008, /* ¤ - 164 */
1244 0x0048, /* ¥ - 165 */
1245 0x0048, /* ¦ - 166 */
1246 0x0008, /* § - 167 */
1247 0x0408, /* ¨ - 168 */
1248 0x0008, /* © - 169 */
1249 0x0400, /* ª - 170 */
1250 0x0008, /* « - 171 */
1251 0x0048, /* ¬ - 172 */
1252 0x0408, /* - 173 */
1253 0x0008, /* ® - 174 */
1254 0x0448, /* ¯ - 175 */
1255 0x0008, /* ° - 176 */
1256 0x0008, /* ± - 177 */
1257 0x0000, /* ² - 178 */
1258 0x0000, /* ³ - 179 */
1259 0x0408, /* ´ - 180 */
1260 0x0008, /* µ - 181 */
1261 0x0008, /* ¶ - 182 */
1262 0x0008, /* · - 183 */
1263 0x0408, /* ¸ - 184 */
1264 0x0000, /* ¹ - 185 */
1265 0x0400, /* º - 186 */
1266 0x0008, /* » - 187 */
1267 0x0000, /* ¼ - 188 */
1268 0x0000, /* ½ - 189 */
1269 0x0000, /* ¾ - 190 */
1270 0x0008, /* ¿ - 191 */
1271 0x8003, /* À - 192 */
1272 0x8003, /* Á - 193 */
1273 0x8003, /* Â - 194 */
1274 0x8003, /* Ã - 195 */
1275 0x8003, /* Ä - 196 */
1276 0x8003, /* Å - 197 */
1277 0x8000, /* Æ - 198 */
1278 0x8003, /* Ç - 199 */
1279 0x8003, /* È - 200 */
1280 0x8003, /* É - 201 */
1281 0x8003, /* Ê - 202 */
1282 0x8003, /* Ë - 203 */
1283 0x8003, /* Ì - 204 */
1284 0x8003, /* Í - 205 */
1285 0x8003, /* Î - 206 */
1286 0x8003, /* Ï - 207 */
1287 0x8000, /* Ð - 208 */
1288 0x8003, /* Ñ - 209 */
1289 0x8003, /* Ò - 210 */
1290 0x8003, /* Ó - 211 */
1291 0x8003, /* Ô - 212 */
1292 0x8003, /* Õ - 213 */
1293 0x8003, /* Ö - 214 */
1294 0x0008, /* × - 215 */
1295 0x8003, /* Ø - 216 */
1296 0x8003, /* Ù - 217 */
1297 0x8003, /* Ú - 218 */
1298 0x8003, /* Û - 219 */
1299 0x8003, /* Ü - 220 */
1300 0x8003, /* Ý - 221 */
1301 0x8000, /* Þ - 222 */
1302 0x8000, /* ß - 223 */
1303 0x8003, /* à - 224 */
1304 0x8003, /* á - 225 */
1305 0x8003, /* â - 226 */
1306 0x8003, /* ã - 227 */
1307 0x8003, /* ä - 228 */
1308 0x8003, /* å - 229 */
1309 0x8000, /* æ - 230 */
1310 0x8003, /* ç - 231 */
1311 0x8003, /* è - 232 */
1312 0x8003, /* é - 233 */
1313 0x8003, /* ê - 234 */
1314 0x8003, /* ë - 235 */
1315 0x8003, /* ì - 236 */
1316 0x8003, /* í - 237 */
1317 0x8003, /* î - 238 */
1318 0x8003, /* ï - 239 */
1319 0x8000, /* ð - 240 */
1320 0x8003, /* ñ - 241 */
1321 0x8003, /* ò - 242 */
1322 0x8003, /* ó - 243 */
1323 0x8003, /* ô - 244 */
1324 0x8003, /* õ - 245 */
1325 0x8003, /* ö - 246 */
1326 0x0008, /* ÷ - 247 */
1327 0x8003, /* ø - 248 */
1328 0x8003, /* ù - 249 */
1329 0x8003, /* ú - 250 */
1330 0x8003, /* û - 251 */
1331 0x8003, /* ü - 252 */
1332 0x8003, /* ý - 253 */
1333 0x8000, /* þ - 254 */
1334 0x8003 /* ÿ - 255 */
1337 /******************************************************************************
1338 * GetStringTypeA [KERNEL32.@]
1340 BOOL WINAPI GetStringTypeA(LCID locale,DWORD dwInfoType,LPCSTR src,
1341 INT cchSrc,LPWORD chartype)
1343 return GetStringTypeExA(locale,dwInfoType,src,cchSrc,chartype);
1346 /******************************************************************************
1347 * GetStringTypeExA [KERNEL32.@]
1349 * FIXME: Ignores the locale.
1351 BOOL WINAPI GetStringTypeExA(LCID locale,DWORD dwInfoType,LPCSTR src,
1352 INT cchSrc,LPWORD chartype)
1356 if ((src==NULL) || (chartype==NULL) || (src==(LPSTR)chartype))
1358 SetLastError(ERROR_INVALID_PARAMETER);
1363 cchSrc=strlen(src)+1;
1365 switch (dwInfoType) {
1367 for (i=0;i<cchSrc;i++)
1370 if (isdigit(src[i])) chartype[i]|=C1_DIGIT;
1371 if (isalpha(src[i])) chartype[i]|=C1_ALPHA;
1372 if (islower(src[i])) chartype[i]|=C1_LOWER;
1373 if (isupper(src[i])) chartype[i]|=C1_UPPER;
1374 if (isspace(src[i])) chartype[i]|=C1_SPACE;
1375 if (ispunct(src[i])) chartype[i]|=C1_PUNCT;
1376 if (iscntrl(src[i])) chartype[i]|=C1_CNTRL;
1377 /* FIXME: isblank() is a GNU extension */
1378 /* if (isblank(src[i])) chartype[i]|=C1_BLANK; */
1379 if ((src[i] == ' ') || (src[i] == '\t')) chartype[i]|=C1_BLANK;
1385 for (i=0;i<cchSrc;i++)
1387 chartype[i]=(WORD)CT_CType2_LUT[i];
1392 for (i=0;i<cchSrc;i++)
1394 chartype[i]=OLE2NLS_CT_CType3_LUT[i];
1399 ERR("Unknown dwInfoType:%ld\n",dwInfoType);
1404 /***********************************************************************
1405 * VerLanguageNameA [KERNEL32.@]
1406 * VerLanguageNameA [VERSION.9]
1408 DWORD WINAPI VerLanguageNameA( UINT wLang, LPSTR szLang, UINT nSize )
1413 return GetLocaleInfoA(MAKELCID(wLang, SORT_DEFAULT), LOCALE_SENGLANGUAGE, szLang, nSize);
1416 /***********************************************************************
1417 * VerLanguageNameW [KERNEL32.@]
1418 * VerLanguageNameW [VERSION.10]
1420 DWORD WINAPI VerLanguageNameW( UINT wLang, LPWSTR szLang, UINT nSize )
1425 return GetLocaleInfoW(MAKELCID(wLang, SORT_DEFAULT), LOCALE_SENGLANGUAGE, szLang, nSize);
1429 static const unsigned char LCM_Unicode_LUT[] = {
1462 7 , 28, /* ! - 33 */
1463 7 , 29, /* " - 34 */ /* " */
1464 7 , 31, /* # - 35 */
1465 7 , 33, /* $ - 36 */
1466 7 , 35, /* % - 37 */
1467 7 , 37, /* & - 38 */
1468 6 , 128, /* ' - 39 */
1469 7 , 39, /* ( - 40 */
1470 7 , 42, /* ) - 41 */
1471 7 , 45, /* * - 42 */
1473 7 , 47, /* , - 44 */
1474 6 , 130, /* - - 45 */
1475 7 , 51, /* . - 46 */
1476 7 , 53, /* / - 47 */
1477 12 , 3, /* 0 - 48 */
1478 12 , 33, /* 1 - 49 */
1479 12 , 51, /* 2 - 50 */
1480 12 , 70, /* 3 - 51 */
1481 12 , 88, /* 4 - 52 */
1482 12 , 106, /* 5 - 53 */
1483 12 , 125, /* 6 - 54 */
1484 12 , 144, /* 7 - 55 */
1485 12 , 162, /* 8 - 56 */
1486 12 , 180, /* 9 - 57 */
1487 7 , 55, /* : - 58 */
1488 7 , 58, /* ; - 59 */
1489 8 , 14, /* < - 60 */
1490 8 , 18, /* = - 61 */
1491 8 , 20, /* > - 62 */
1492 7 , 60, /* ? - 63 */
1493 7 , 62, /* @ - 64 */
1494 14 , 2, /* A - 65 */
1495 14 , 9, /* B - 66 */
1496 14 , 10, /* C - 67 */
1497 14 , 26, /* D - 68 */
1498 14 , 33, /* E - 69 */
1499 14 , 35, /* F - 70 */
1500 14 , 37, /* G - 71 */
1501 14 , 44, /* H - 72 */
1502 14 , 50, /* I - 73 */
1503 14 , 53, /* J - 74 */
1504 14 , 54, /* K - 75 */
1505 14 , 72, /* L - 76 */
1506 14 , 81, /* M - 77 */
1507 14 , 112, /* N - 78 */
1508 14 , 124, /* O - 79 */
1509 14 , 126, /* P - 80 */
1510 14 , 137, /* Q - 81 */
1511 14 , 138, /* R - 82 */
1512 14 , 145, /* S - 83 */
1513 14 , 153, /* T - 84 */
1514 14 , 159, /* U - 85 */
1515 14 , 162, /* V - 86 */
1516 14 , 164, /* W - 87 */
1517 14 , 166, /* X - 88 */
1518 14 , 167, /* Y - 89 */
1519 14 , 169, /* Z - 90 */
1520 7 , 63, /* [ - 91 */
1521 7 , 65, /* \ - 92 */
1522 7 , 66, /* ] - 93 */
1523 7 , 67, /* ^ - 94 */
1524 7 , 68, /* _ - 95 */
1525 7 , 72, /* ` - 96 */
1526 14 , 2, /* a - 97 */
1527 14 , 9, /* b - 98 */
1528 14 , 10, /* c - 99 */
1529 14 , 26, /* d - 100 */
1530 14 , 33, /* e - 101 */
1531 14 , 35, /* f - 102 */
1532 14 , 37, /* g - 103 */
1533 14 , 44, /* h - 104 */
1534 14 , 50, /* i - 105 */
1535 14 , 53, /* j - 106 */
1536 14 , 54, /* k - 107 */
1537 14 , 72, /* l - 108 */
1538 14 , 81, /* m - 109 */
1539 14 , 112, /* n - 110 */
1540 14 , 124, /* o - 111 */
1541 14 , 126, /* p - 112 */
1542 14 , 137, /* q - 113 */
1543 14 , 138, /* r - 114 */
1544 14 , 145, /* s - 115 */
1545 14 , 153, /* t - 116 */
1546 14 , 159, /* u - 117 */
1547 14 , 162, /* v - 118 */
1548 14 , 164, /* w - 119 */
1549 14 , 166, /* x - 120 */
1550 14 , 167, /* y - 121 */
1551 14 , 169, /* z - 122 */
1552 7 , 74, /* { - 123 */
1553 7 , 76, /* | - 124 */
1554 7 , 78, /* } - 125 */
1555 7 , 80, /* ~ - 126 */
1556 6 , 29, /*
\7f - 127 */
1557 6 , 30, /*
\80 - 128 */
1558 6 , 31, /*
\81 - 129 */
1559 7 , 123, /*
\82 - 130 */
1560 14 , 35, /*
\83 - 131 */
1561 7 , 127, /*
\84 - 132 */
1562 10 , 21, /*
\85 - 133 */
1563 10 , 15, /*
\86 - 134 */
1564 10 , 16, /*
\87 - 135 */
1565 7 , 67, /*
\88 - 136 */
1566 10 , 22, /*
\89 - 137 */
1567 14 , 145, /*
\8a - 138 */
1568 7 , 136, /*
\8b - 139 */
1569 14 + 16 , 124, /*
\8c - 140 */
1570 6 , 43, /*
\8d - 141 */
1571 6 , 44, /*
\8e - 142 */
1572 6 , 45, /*
\8f - 143 */
1573 6 , 46, /*
\90 - 144 */
1574 7 , 121, /*
\91 - 145 */
1575 7 , 122, /*
\92 - 146 */
1576 7 , 125, /*
\93 - 147 */
1577 7 , 126, /*
\94 - 148 */
1578 10 , 17, /*
\95 - 149 */
1579 6 , 137, /*
\96 - 150 */
1580 6 , 139, /*
\97 - 151 */
1581 7 , 93, /*
\98 - 152 */
1582 14 , 156, /*
\99 - 153 */
1583 14 , 145, /*
\9a - 154 */
1584 7 , 137, /*
\9b - 155 */
1585 14 + 16 , 124, /*
\9c - 156 */
1586 6 , 59, /*
\9d - 157 */
1587 6 , 60, /*
\9e - 158 */
1588 14 , 167, /*
\9f - 159 */
1590 7 , 81, /* ¡ - 161 */
1591 10 , 2, /* ¢ - 162 */
1592 10 , 3, /* £ - 163 */
1593 10 , 4, /* ¤ - 164 */
1594 10 , 5, /* ¥ - 165 */
1595 7 , 82, /* ¦ - 166 */
1596 10 , 6, /* § - 167 */
1597 7 , 83, /* ¨ - 168 */
1598 10 , 7, /* © - 169 */
1599 14 , 2, /* ª - 170 */
1600 8 , 24, /* « - 171 */
1601 10 , 8, /* ¬ - 172 */
1602 6 , 131, /* - 173 */
1603 10 , 9, /* ® - 174 */
1604 7 , 84, /* ¯ - 175 */
1605 10 , 10, /* ° - 176 */
1606 8 , 23, /* ± - 177 */
1607 12 , 51, /* ² - 178 */
1608 12 , 70, /* ³ - 179 */
1609 7 , 85, /* ´ - 180 */
1610 10 , 11, /* µ - 181 */
1611 10 , 12, /* ¶ - 182 */
1612 10 , 13, /* · - 183 */
1613 7 , 86, /* ¸ - 184 */
1614 12 , 33, /* ¹ - 185 */
1615 14 , 124, /* º - 186 */
1616 8 , 26, /* » - 187 */
1617 12 , 21, /* ¼ - 188 */
1618 12 , 25, /* ½ - 189 */
1619 12 , 29, /* ¾ - 190 */
1620 7 , 87, /* ¿ - 191 */
1621 14 , 2, /* À - 192 */
1622 14 , 2, /* Á - 193 */
1623 14 , 2, /* Â - 194 */
1624 14 , 2, /* Ã - 195 */
1625 14 , 2, /* Ä - 196 */
1626 14 , 2, /* Å - 197 */
1627 14 + 16 , 2, /* Æ - 198 */
1628 14 , 10, /* Ç - 199 */
1629 14 , 33, /* È - 200 */
1630 14 , 33, /* É - 201 */
1631 14 , 33, /* Ê - 202 */
1632 14 , 33, /* Ë - 203 */
1633 14 , 50, /* Ì - 204 */
1634 14 , 50, /* Í - 205 */
1635 14 , 50, /* Î - 206 */
1636 14 , 50, /* Ï - 207 */
1637 14 , 26, /* Ð - 208 */
1638 14 , 112, /* Ñ - 209 */
1639 14 , 124, /* Ò - 210 */
1640 14 , 124, /* Ó - 211 */
1641 14 , 124, /* Ô - 212 */
1642 14 , 124, /* Õ - 213 */
1643 14 , 124, /* Ö - 214 */
1644 8 , 28, /* × - 215 */
1645 14 , 124, /* Ø - 216 */
1646 14 , 159, /* Ù - 217 */
1647 14 , 159, /* Ú - 218 */
1648 14 , 159, /* Û - 219 */
1649 14 , 159, /* Ü - 220 */
1650 14 , 167, /* Ý - 221 */
1651 14 + 32 , 153, /* Þ - 222 */
1652 14 + 48 , 145, /* ß - 223 */
1653 14 , 2, /* à - 224 */
1654 14 , 2, /* á - 225 */
1655 14 , 2, /* â - 226 */
1656 14 , 2, /* ã - 227 */
1657 14 , 2, /* ä - 228 */
1658 14 , 2, /* å - 229 */
1659 14 + 16 , 2, /* æ - 230 */
1660 14 , 10, /* ç - 231 */
1661 14 , 33, /* è - 232 */
1662 14 , 33, /* é - 233 */
1663 14 , 33, /* ê - 234 */
1664 14 , 33, /* ë - 235 */
1665 14 , 50, /* ì - 236 */
1666 14 , 50, /* í - 237 */
1667 14 , 50, /* î - 238 */
1668 14 , 50, /* ï - 239 */
1669 14 , 26, /* ð - 240 */
1670 14 , 112, /* ñ - 241 */
1671 14 , 124, /* ò - 242 */
1672 14 , 124, /* ó - 243 */
1673 14 , 124, /* ô - 244 */
1674 14 , 124, /* õ - 245 */
1675 14 , 124, /* ö - 246 */
1676 8 , 29, /* ÷ - 247 */
1677 14 , 124, /* ø - 248 */
1678 14 , 159, /* ù - 249 */
1679 14 , 159, /* ú - 250 */
1680 14 , 159, /* û - 251 */
1681 14 , 159, /* ü - 252 */
1682 14 , 167, /* ý - 253 */
1683 14 + 32 , 153, /* þ - 254 */
1684 14 , 167 /* ÿ - 255 */ };
1686 static const unsigned char LCM_Unicode_LUT_2[] = { 33, 44, 145 };
1688 #define LCM_Diacritic_Start 131
1690 static const unsigned char LCM_Diacritic_LUT[] = {
1691 123, /*
\83 - 131 */
1818 /******************************************************************************
1819 * OLE2NLS_isPunctuation [INTERNAL]
1821 static int OLE2NLS_isPunctuation(unsigned char c)
1823 /* "punctuation character" in this context is a character which is
1824 considered "less important" during word sort comparison.
1825 See LCMapString implementation for the precise definition
1826 of "less important". */
1828 return (LCM_Unicode_LUT[-2+2*c]==6);
1831 /******************************************************************************
1832 * OLE2NLS_isNonSpacing [INTERNAL]
1834 static int OLE2NLS_isNonSpacing(unsigned char c)
1836 /* This function is used by LCMapStringA. Characters
1837 for which it returns true are ignored when mapping a
1838 string with NORM_IGNORENONSPACE */
1839 return ((c==136) || (c==170) || (c==186));
1842 /******************************************************************************
1843 * OLE2NLS_isSymbol [INTERNAL]
1845 static int OLE2NLS_isSymbol(unsigned char c)
1847 /* This function is used by LCMapStringA. Characters
1848 for which it returns true are ignored when mapping a
1849 string with NORM_IGNORESYMBOLS */
1850 return ( (c!=0) && !IsCharAlphaNumericA(c) );
1853 /******************************************************************************
1854 * identity [Internal]
1856 static int identity(int c)
1861 /*************************************************************************
1862 * LCMapStringA [KERNEL32.@]
1864 * Convert a string, or generate a sort key from it.
1866 * If (mapflags & LCMAP_SORTKEY), the function will generate
1867 * a sort key for the source string. Else, it will convert it
1868 * accordingly to the flags LCMAP_UPPERCASE, LCMAP_LOWERCASE,...
1872 * Success : length of the result string.
1875 * If called with scrlen = -1, the function will compute the length
1876 * of the 0-terminated string strsrc by itself.
1878 * If called with dstlen = 0, returns the buffer length that
1879 * would be required.
1881 * NORM_IGNOREWIDTH means to compare ASCII and wide characters
1882 * as if they are equal.
1883 * In the only code page implemented so far, there may not be
1884 * wide characters in strings passed to LCMapStringA,
1885 * so there is nothing to be done for this flag.
1887 INT WINAPI LCMapStringA(
1888 LCID lcid, /* [in] locale identifier created with MAKELCID;
1889 LOCALE_SYSTEM_DEFAULT and LOCALE_USER_DEFAULT are
1890 predefined values. */
1891 DWORD mapflags, /* [in] flags */
1892 LPCSTR srcstr, /* [in] source buffer */
1893 INT srclen, /* [in] source length */
1894 LPSTR dststr, /* [out] destination buffer */
1895 INT dstlen) /* [in] destination buffer length */
1899 TRACE("(0x%04lx,0x%08lx,%s,%d,%p,%d)\n",
1900 lcid,mapflags,srcstr,srclen,dststr,dstlen);
1902 if ( ((dstlen!=0) && (dststr==NULL)) || (srcstr==NULL) )
1904 ERR("(src=%s,dest=%s): Invalid NULL string\n", srcstr, dststr);
1905 SetLastError(ERROR_INVALID_PARAMETER);
1909 srclen = strlen(srcstr) + 1 ; /* (include final '\0') */
1911 #define LCMAPSTRINGA_SUPPORTED_FLAGS (LCMAP_UPPERCASE | \
1915 NORM_IGNORENONSPACE | \
1917 NORM_IGNOREWIDTH | \
1918 NORM_IGNOREKANATYPE)
1919 /* FIXME: as long as we don't support Katakana nor Hiragana
1920 * characters, we can support NORM_IGNOREKANATYPE
1922 if (mapflags & ~LCMAPSTRINGA_SUPPORTED_FLAGS)
1924 FIXME("(0x%04lx,0x%08lx,%p,%d,%p,%d): "
1925 "unimplemented flags: 0x%08lx\n",
1932 mapflags & ~LCMAPSTRINGA_SUPPORTED_FLAGS
1936 if ( !(mapflags & LCMAP_SORTKEY) )
1939 int (*f)(int) = identity;
1940 int flag_ignorenonspace = mapflags & NORM_IGNORENONSPACE;
1941 int flag_ignoresymbols = mapflags & NORM_IGNORESYMBOLS;
1943 if (flag_ignorenonspace || flag_ignoresymbols)
1945 /* For some values of mapflags, the length of the resulting
1946 string is not known at this point. Windows does map the string
1947 and does not SetLastError ERROR_INSUFFICIENT_BUFFER in
1951 /* Compute required length */
1952 for (i=j=0; i < srclen; i++)
1954 if ( !(flag_ignorenonspace && OLE2NLS_isNonSpacing(srcstr[i]))
1955 && !(flag_ignoresymbols && OLE2NLS_isSymbol(srcstr[i])) )
1967 SetLastError(ERROR_INSUFFICIENT_BUFFER);
1971 if (mapflags & LCMAP_UPPERCASE)
1973 else if (mapflags & LCMAP_LOWERCASE)
1975 /* FIXME: NORM_IGNORENONSPACE requires another conversion */
1976 for (i=j=0; (i<srclen) && (j<dstlen) ; i++)
1978 if ( !(flag_ignorenonspace && OLE2NLS_isNonSpacing(srcstr[i]))
1979 && !(flag_ignoresymbols && OLE2NLS_isSymbol(srcstr[i])) )
1981 dststr[j] = (CHAR) f(srcstr[i]);
1988 /* FIXME: This function completely ignores the "lcid" parameter. */
1989 /* else ... (mapflags & LCMAP_SORTKEY) */
1993 int diacritic_len=0;
1994 int delayed_punctuation_len=0;
1995 char *case_component;
1996 char *diacritic_component;
1997 char *delayed_punctuation_component;
1999 int flag_stringsort = mapflags & SORT_STRINGSORT;
2001 /* compute how much room we will need */
2002 for (i=0;i<srclen;i++)
2005 unsigned char source_char = srcstr[i];
2006 if (source_char!='\0')
2008 if (flag_stringsort || !OLE2NLS_isPunctuation(source_char))
2011 if ( LCM_Unicode_LUT[-2+2*source_char] & ~15 )
2012 unicode_len++; /* double letter */
2016 delayed_punctuation_len++;
2020 if (isupper(source_char))
2021 case_len=unicode_len;
2023 ofs = source_char - LCM_Diacritic_Start;
2024 if ((ofs>=0) && (LCM_Diacritic_LUT[ofs]!=2))
2025 diacritic_len=unicode_len;
2028 if (mapflags & NORM_IGNORECASE)
2030 if (mapflags & NORM_IGNORENONSPACE)
2033 room = 2 * unicode_len /* "unicode" component */
2034 + diacritic_len /* "diacritic" component */
2035 + case_len /* "case" component */
2036 + 4 * delayed_punctuation_len /* punctuation in word sort mode */
2037 + 4 /* four '\1' separators */
2038 + 1 ; /* terminal '\0' */
2041 else if (dstlen<room)
2043 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2047 /*FIXME the Pointercheck should not be nessesary */
2048 if (IsBadWritePtr (dststr,room))
2049 { ERR("bad destination buffer (dststr) : %p,%d\n",dststr,dstlen);
2050 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2054 /* locate each component, write separators */
2055 diacritic_component = dststr + 2*unicode_len ;
2056 *diacritic_component++ = '\1';
2057 case_component = diacritic_component + diacritic_len ;
2058 *case_component++ = '\1';
2059 delayed_punctuation_component = case_component + case_len ;
2060 *delayed_punctuation_component++ = '\1';
2061 *delayed_punctuation_component++ = '\1';
2063 /* read source string char by char, write
2064 corresponding weight in each component. */
2065 for (i=0,count=0;i<srclen;i++)
2067 unsigned char source_char=srcstr[i];
2068 if (source_char!='\0')
2071 type = LCM_Unicode_LUT[-2+2*source_char];
2072 longcode = type >> 4;
2074 if (!flag_stringsort && OLE2NLS_isPunctuation(source_char))
2076 WORD encrypted_location = (1<<15) + 7 + 4*count;
2077 *delayed_punctuation_component++ = (unsigned char) (encrypted_location>>8);
2078 *delayed_punctuation_component++ = (unsigned char) (encrypted_location&255);
2079 /* big-endian is used here because it lets string comparison be
2080 compatible with numerical comparison */
2082 *delayed_punctuation_component++ = type;
2083 *delayed_punctuation_component++ = LCM_Unicode_LUT[-1+2*source_char];
2084 /* assumption : a punctuation character is never a
2085 double or accented letter */
2089 dststr[2*count] = type;
2090 dststr[2*count+1] = LCM_Unicode_LUT[-1+2*source_char];
2094 case_component[count] = ( isupper(source_char) ? 18 : 2 ) ;
2095 if (count<diacritic_len)
2096 diacritic_component[count] = 2; /* assumption: a double letter
2097 is never accented */
2100 dststr[2*count] = type;
2101 dststr[2*count+1] = *(LCM_Unicode_LUT_2 - 1 + longcode);
2102 /* 16 in the first column of LCM_Unicode_LUT --> longcode = 1
2103 32 in the first column of LCM_Unicode_LUT --> longcode = 2
2104 48 in the first column of LCM_Unicode_LUT --> longcode = 3 */
2108 case_component[count] = ( isupper(source_char) ? 18 : 2 ) ;
2109 if (count<diacritic_len)
2111 int ofs = source_char - LCM_Diacritic_Start;
2112 diacritic_component[count] = (ofs>=0 ? LCM_Diacritic_LUT[ofs] : 2);
2118 dststr[room-1] = '\0';
2123 /*************************************************************************
2124 * LCMapStringW [KERNEL32.@]
2126 * Convert a string, or generate a sort key from it.
2130 * See LCMapStringA for documentation
2132 INT WINAPI LCMapStringW(
2133 LCID lcid,DWORD mapflags,LPCWSTR srcstr,INT srclen,LPWSTR dststr,
2138 TRACE("(0x%04lx,0x%08lx,%p,%d,%p,%d)\n",
2139 lcid, mapflags, srcstr, srclen, dststr, dstlen);
2141 if ( ((dstlen!=0) && (dststr==NULL)) || (srcstr==NULL) )
2143 ERR("(src=%p,dst=%p): Invalid NULL string\n", srcstr, dststr);
2144 SetLastError(ERROR_INVALID_PARAMETER);
2148 srclen = strlenW(srcstr)+1;
2150 /* FIXME: Both this function and it's companion LCMapStringA()
2151 * completely ignore the "lcid" parameter. In place of the "lcid"
2152 * parameter the application must set the "LC_COLLATE" or "LC_ALL"
2153 * environment variable prior to invoking this function. */
2154 if (mapflags & LCMAP_SORTKEY)
2156 /* Possible values of LC_COLLATE. */
2157 char *lc_collate_default = 0; /* value prior to this function */
2158 char *lc_collate_env = 0; /* value retrieved from the environment */
2160 /* General purpose index into strings of any type. */
2163 /* Lengths of various strings where the length is measured in
2164 * wide characters for wide character strings and in bytes for
2165 * native strings. The lengths include the NULL terminator. */
2166 size_t returned_len = 0;
2167 size_t src_native_len = 0;
2168 size_t dst_native_len = 0;
2169 size_t dststr_libc_len = 0;
2171 /* Native (character set determined by locale) versions of the
2172 * strings source and destination strings. */
2173 LPSTR src_native = 0;
2174 LPSTR dst_native = 0;
2176 /* Version of the source and destination strings using the
2177 * "wchar_t" Unicode data type needed by various libc functions. */
2178 wchar_t *srcstr_libc = 0;
2179 wchar_t *dststr_libc = 0;
2181 if(!(srcstr_libc = (wchar_t *)HeapAlloc(GetProcessHeap(), 0,
2182 srclen * sizeof(wchar_t))))
2184 ERR("Unable to allocate %d bytes for srcstr_libc\n",
2185 srclen * sizeof(wchar_t));
2186 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
2190 /* Convert source string to a libc Unicode string. */
2191 for(str_idx = 0; str_idx < srclen; str_idx++)
2193 srcstr_libc[str_idx] = srcstr[str_idx];
2196 /* src_native should contain at most 3 bytes for each
2197 * multibyte characters in the original srcstr string. */
2198 src_native_len = 3 * srclen;
2199 if(!(src_native = (LPSTR)HeapAlloc(GetProcessHeap(), 0,
2202 ERR("Unable to allocate %d bytes for src_native\n", src_native_len);
2203 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
2204 if(srcstr_libc) HeapFree(GetProcessHeap(), 0, srcstr_libc);
2208 /* FIXME: Prior to to setting the LC_COLLATE locale category the
2209 * current value is backed up so it can be restored after the
2210 * last LC_COLLATE sensitive function returns.
2212 * Even though the locale is adjusted for a minimum amount of
2213 * time a race condition exists where other threads may be
2214 * affected if they invoke LC_COLLATE sensitive functions. One
2215 * possible solution is to wrap all LC_COLLATE sensitive Wine
2216 * functions, like LCMapStringW(), in a mutex.
2218 * Another enhancement to the following would be to set the
2219 * LC_COLLATE locale category as a function of the "lcid"
2220 * parameter instead of the "LC_COLLATE" environment variable. */
2221 if(!(lc_collate_default = setlocale(LC_COLLATE, NULL)))
2223 ERR("Unable to query the LC_COLLATE catagory\n");
2224 SetLastError(ERROR_INVALID_PARAMETER);
2225 if(srcstr_libc) HeapFree(GetProcessHeap(), 0, srcstr_libc);
2226 if(src_native) HeapFree(GetProcessHeap(), 0, src_native);
2230 if(!(lc_collate_env = setlocale(LC_COLLATE, "")))
2232 ERR("Unable to inherit the LC_COLLATE locale category from the "
2233 "environment. The \"LC_COLLATE\" environment variable is "
2234 "\"%s\".\n", getenv("LC_COLLATE") ?
2235 getenv("LC_COLLATE") : "<unset>");
2236 SetLastError(ERROR_INVALID_PARAMETER);
2237 if(srcstr_libc) HeapFree(GetProcessHeap(), 0, srcstr_libc);
2238 if(src_native) HeapFree(GetProcessHeap(), 0, src_native);
2242 TRACE("lc_collate_default = %s\n", lc_collate_default);
2243 TRACE("lc_collate_env = %s\n", lc_collate_env);
2245 /* Convert the libc Unicode string to a native multibyte character
2247 returned_len = wcstombs(src_native, srcstr_libc, src_native_len) + 1;
2248 if(returned_len == 0)
2250 LPSTR srcstr_ascii = (LPSTR)HEAP_strdupWtoA(GetProcessHeap(),
2252 ERR("wcstombs failed. The string specified (%s) may contains an "
2253 "invalid character.\n", srcstr_ascii);
2254 SetLastError(ERROR_INVALID_PARAMETER);
2255 if(srcstr_ascii) HeapFree(GetProcessHeap(), 0, srcstr_ascii);
2256 if(srcstr_libc) HeapFree(GetProcessHeap(), 0, srcstr_libc);
2257 if(src_native) HeapFree(GetProcessHeap(), 0, src_native);
2258 setlocale(LC_COLLATE, lc_collate_default);
2261 else if(returned_len > src_native_len)
2263 src_native[src_native_len - 1] = 0;
2264 ERR("wcstombs returned a string (%s) that was longer (%d bytes) "
2265 "than expected (%d bytes).\n", src_native, returned_len,
2268 /* Since this is an internal error I'm not sure what the correct
2270 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
2272 if(srcstr_libc) HeapFree(GetProcessHeap(), 0, srcstr_libc);
2273 if(src_native) HeapFree(GetProcessHeap(), 0, src_native);
2274 setlocale(LC_COLLATE, lc_collate_default);
2277 src_native_len = returned_len;
2279 TRACE("src_native = %s src_native_len = %d\n",
2280 src_native, src_native_len);
2282 /* dst_native seems to contain at most 4 bytes for each byte in
2283 * the original src_native string. Change if need be since this
2284 * isn't documented by the strxfrm() man page. */
2285 dst_native_len = 4 * src_native_len;
2286 if(!(dst_native = (LPSTR)HeapAlloc(GetProcessHeap(), 0, dst_native_len)))
2288 ERR("Unable to allocate %d bytes for dst_native\n", dst_native_len);
2289 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
2290 if(srcstr_libc) HeapFree(GetProcessHeap(), 0, srcstr_libc);
2291 if(src_native) HeapFree(GetProcessHeap(), 0, src_native);
2292 setlocale(LC_COLLATE, lc_collate_default);
2296 /* The actual translation is done by the following call to
2297 * strxfrm(). The surrounding code could have been simplified
2298 * by calling wcsxfrm() instead except that wcsxfrm() is not
2299 * available on older Linux systems (RedHat 4.1 with
2302 * Also, it is possible that the translation could be done by
2303 * various tables as it is done in LCMapStringA(). However, I'm
2304 * not sure what those tables are. */
2305 returned_len = strxfrm(dst_native, src_native, dst_native_len) + 1;
2307 if(returned_len > dst_native_len)
2309 dst_native[dst_native_len - 1] = 0;
2310 ERR("strxfrm returned a string (%s) that was longer (%d bytes) "
2311 "than expected (%d bytes).\n", dst_native, returned_len,
2314 /* Since this is an internal error I'm not sure what the correct
2316 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
2318 if(srcstr_libc) HeapFree(GetProcessHeap(), 0, srcstr_libc);
2319 if(src_native) HeapFree(GetProcessHeap(), 0, src_native);
2320 if(dst_native) HeapFree(GetProcessHeap(), 0, dst_native);
2321 setlocale(LC_COLLATE, lc_collate_default);
2324 dst_native_len = returned_len;
2326 TRACE("dst_native = %s dst_native_len = %d\n",
2327 dst_native, dst_native_len);
2329 dststr_libc_len = dst_native_len;
2330 if(!(dststr_libc = (wchar_t *)HeapAlloc(GetProcessHeap(), 0,
2331 dststr_libc_len * sizeof(wchar_t))))
2333 ERR("Unable to allocate %d bytes for dststr_libc\n",
2334 dststr_libc_len * sizeof(wchar_t));
2335 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
2336 if(srcstr_libc) HeapFree(GetProcessHeap(), 0, srcstr_libc);
2337 if(src_native) HeapFree(GetProcessHeap(), 0, src_native);
2338 if(dst_native) HeapFree(GetProcessHeap(), 0, dst_native);
2339 setlocale(LC_COLLATE, lc_collate_default);
2343 /* Convert the native multibyte string to a libc Unicode string. */
2344 returned_len = mbstowcs(dststr_libc, dst_native, dst_native_len) + 1;
2346 /* Restore LC_COLLATE now that the last LC_COLLATE sensitive
2347 * function has returned. */
2348 setlocale(LC_COLLATE, lc_collate_default);
2350 if(returned_len == 0)
2352 ERR("mbstowcs failed. The native version of the translated string "
2353 "(%s) may contain an invalid character.\n", dst_native);
2354 SetLastError(ERROR_INVALID_PARAMETER);
2355 if(srcstr_libc) HeapFree(GetProcessHeap(), 0, srcstr_libc);
2356 if(src_native) HeapFree(GetProcessHeap(), 0, src_native);
2357 if(dst_native) HeapFree(GetProcessHeap(), 0, dst_native);
2358 if(dststr_libc) HeapFree(GetProcessHeap(), 0, dststr_libc);
2363 if(returned_len > dstlen)
2365 ERR("mbstowcs returned a string that was longer (%d chars) "
2366 "than the buffer provided (%d chars).\n", returned_len,
2368 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2369 if(srcstr_libc) HeapFree(GetProcessHeap(), 0, srcstr_libc);
2370 if(src_native) HeapFree(GetProcessHeap(), 0, src_native);
2371 if(dst_native) HeapFree(GetProcessHeap(), 0, dst_native);
2372 if(dststr_libc) HeapFree(GetProcessHeap(), 0, dststr_libc);
2375 dstlen = returned_len;
2377 /* Convert a libc Unicode string to the destination string. */
2378 for(str_idx = 0; str_idx < dstlen; str_idx++)
2380 dststr[str_idx] = dststr_libc[str_idx];
2382 TRACE("1st 4 int sized chunks of dststr = %x %x %x %x\n",
2383 *(((int *)dststr) + 0),
2384 *(((int *)dststr) + 1),
2385 *(((int *)dststr) + 2),
2386 *(((int *)dststr) + 3));
2390 dstlen = returned_len;
2392 TRACE("dstlen (return) = %d\n", dstlen);
2393 if(srcstr_libc) HeapFree(GetProcessHeap(), 0, srcstr_libc);
2394 if(src_native) HeapFree(GetProcessHeap(), 0, src_native);
2395 if(dst_native) HeapFree(GetProcessHeap(), 0, dst_native);
2396 if(dststr_libc) HeapFree(GetProcessHeap(), 0, dststr_libc);
2401 int (*f)(int)=identity;
2407 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2411 if (mapflags & LCMAP_UPPERCASE)
2413 else if (mapflags & LCMAP_LOWERCASE)
2415 for (i=0; i < srclen; i++)
2416 dststr[i] = (WCHAR) f(srcstr[i]);
2422 /***********************************************************************
2423 * OLE2NLS_EstimateMappingLength
2425 * Estimates the number of characters required to hold the string
2426 * computed by LCMapStringA.
2428 * The size is always over-estimated, with a fixed limit on the
2429 * amount of estimation error.
2431 * Note that len == -1 is not permitted.
2433 static inline int OLE2NLS_EstimateMappingLength(LCID lcid, DWORD dwMapFlags,
2434 LPCSTR str, DWORD len)
2436 /* Estimate only for small strings to keep the estimation error from
2437 * becoming too large. */
2438 if (len < 128) return len * 8 + 5;
2439 else return LCMapStringA(lcid, dwMapFlags, str, len, NULL, 0);
2442 /******************************************************************************
2443 * CompareStringA [KERNEL32.@]
2444 * Compares two strings using locale
2448 * success: CSTR_LESS_THAN, CSTR_EQUAL, CSTR_GREATER_THAN
2453 * Defaults to a word sort, but uses a string sort if
2454 * SORT_STRINGSORT is set.
2455 * Calls SetLastError for ERROR_INVALID_FLAGS, ERROR_INVALID_PARAMETER.
2459 * This implementation ignores the locale
2463 * Quite inefficient.
2465 UINT WINAPI CompareStringA(
2466 DWORD lcid, /* [in] locale ID */
2467 DWORD fdwStyle, /* [in] comparison-style options */
2468 LPCSTR s1, /* [in] first string */
2469 DWORD l1, /* [in] length of first string */
2470 LPCSTR s2, /* [in] second string */
2471 DWORD l2) /* [in] length of second string */
2473 int mapstring_flags;
2477 TRACE("%s and %s\n",
2478 debugstr_a (s1), debugstr_a (s2));
2480 if ( (s1==NULL) || (s2==NULL) )
2482 ERR("(s1=%s,s2=%s): Invalid NULL string\n", s1, s2);
2483 SetLastError(ERROR_INVALID_PARAMETER);
2487 if(fdwStyle & NORM_IGNORESYMBOLS)
2488 FIXME("IGNORESYMBOLS not supported\n");
2490 if (l1 == -1) l1 = strlen(s1);
2491 if (l2 == -1) l2 = strlen(s2);
2493 mapstring_flags = LCMAP_SORTKEY | fdwStyle ;
2494 len1 = OLE2NLS_EstimateMappingLength(lcid, mapstring_flags, s1, l1);
2495 len2 = OLE2NLS_EstimateMappingLength(lcid, mapstring_flags, s2, l2);
2497 if ((len1==0)||(len2==0))
2498 return 0; /* something wrong happened */
2500 sk1 = (LPSTR)HeapAlloc(GetProcessHeap(), 0, len1 + len2);
2502 if ( (!LCMapStringA(lcid,mapstring_flags,s1,l1,sk1,len1))
2503 || (!LCMapStringA(lcid,mapstring_flags,s2,l2,sk2,len2)) )
2505 ERR("Bug in LCmapStringA.\n");
2510 /* strcmp doesn't necessarily return -1, 0, or 1 */
2511 result = strcmp(sk1,sk2);
2513 HeapFree(GetProcessHeap(),0,sk1);
2520 /* must be greater, if we reach this point */
2524 /******************************************************************************
2525 * CompareStringW [KERNEL32.@]
2526 * This implementation ignores the locale
2527 * FIXME : Does only string sort. Should
2528 * be reimplemented the same way as CompareStringA.
2530 UINT WINAPI CompareStringW(DWORD lcid, DWORD fdwStyle,
2531 LPCWSTR s1, DWORD l1, LPCWSTR s2,DWORD l2)
2534 if(fdwStyle & NORM_IGNORENONSPACE)
2535 FIXME("IGNORENONSPACE not supprted\n");
2536 if(fdwStyle & NORM_IGNORESYMBOLS)
2537 FIXME("IGNORESYMBOLS not supported\n");
2539 /* Is strcmp defaulting to string sort or to word sort?? */
2540 /* FIXME: Handle NORM_STRINGSORT */
2541 l1 = (l1==-1)?strlenW(s1):l1;
2542 l2 = (l2==-1)?strlenW(s2):l2;
2543 len = l1<l2 ? l1:l2;
2544 ret = (fdwStyle & NORM_IGNORECASE) ? strncmpiW(s1,s2,len) : strncmpW(s1,s2,len);
2545 /* not equal, return 1 or 3 */
2547 /* need to translate result */
2548 return ((int)ret < 0) ? 1 : 3;
2550 /* same len, return 2 */
2551 if(l1==l2) return 2;
2552 /* the longer one is lexically greater */
2553 return (l1<l2)? 1 : 3;
2556 /******************************************************************************
2557 * OLE_GetFormatA [Internal]
2560 * If datelen == 0, it should return the reguired string length.
2562 This function implements stuff for GetDateFormat() and
2565 d single-digit (no leading zero) day (of month)
2566 dd two-digit day (of month)
2567 ddd short day-of-week name
2568 dddd long day-of-week name
2569 M single-digit month
2571 MMM short month name
2572 MMMM full month name
2573 y two-digit year, no leading 0
2575 yyyy four-digit year
2577 h hours with no leading zero (12-hour)
2578 hh hours with full two digits
2579 H hours with no leading zero (24-hour)
2580 HH hours with full two digits
2581 m minutes with no leading zero
2582 mm minutes with full two digits
2583 s seconds with no leading zero
2584 ss seconds with full two digits
2585 t time marker (A or P)
2586 tt time marker (AM, PM)
2587 '' used to quote literal characters
2588 '' (within a quoted string) indicates a literal '
2590 These functions REQUIRE valid locale, date, and format.
2592 static INT OLE_GetFormatA(LCID locale,
2596 LPCSTR _format, /*in*/
2601 int count, type, inquote, Overflow;
2607 const char * _dgfmt[] = { "%d", "%02d" };
2608 const char ** dgfmt = _dgfmt - 1;
2610 /* report, for debugging */
2611 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",
2612 locale, flags, tflags,
2613 xtime->wYear,xtime->wMonth,xtime->wDayOfWeek,xtime->wDay, xtime->wHour, xtime->wMinute, xtime->wSecond,
2614 _format, _format, date, datelen);
2617 FIXME("datelen = 0, returning 255\n");
2621 /* initalize state variables and output buffer */
2623 count = 0; inquote = 0; Overflow = 0;
2625 date[0] = buf[0] = '\0';
2627 strcpy(format,_format);
2629 /* alter the formatstring, while it works for all languages now in wine
2630 its possible that it fails when the time looks like ss:mm:hh as example*/
2631 if (tflags & (TIME_NOMINUTESORSECONDS))
2632 { if ((pos = strstr ( format, ":mm")))
2633 { memcpy ( pos, pos+3, strlen(format)-(pos-format)-2 );
2636 if (tflags & (TIME_NOSECONDS))
2637 { if ((pos = strstr ( format, ":ss")))
2638 { memcpy ( pos, pos+3, strlen(format)-(pos-format)-2 );
2642 for (inpos = 0;; inpos++) {
2643 /* 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]); */
2645 if (format[inpos] == '\'') {
2646 if (format[inpos+1] == '\'') {
2648 date[outpos++] = '\'';
2651 continue; /* we did nothing to the output */
2653 } else if (format[inpos] == '\0') {
2654 date[outpos++] = '\0';
2655 if (outpos > datelen) Overflow = 1;
2658 date[outpos++] = format[inpos];
2659 if (outpos > datelen) {
2661 date[outpos-1] = '\0'; /* this is the last place where
2662 it's safe to write */
2666 } else if ( (count && (format[inpos] != type))
2668 || (count == 2 && strchr("ghHmst", type)) ) {
2669 if (type == 'h' && (tflags & TIME_FORCE24HOURFORMAT)) type= 'H';
2672 GetLocaleInfoA(locale,
2674 + (xtime->wDayOfWeek+6)%7,
2676 } else if (count == 3) {
2677 GetLocaleInfoA(locale,
2678 LOCALE_SABBREVDAYNAME1
2679 + (xtime->wDayOfWeek+6)%7,
2682 sprintf(buf, dgfmt[count], xtime->wDay);
2684 } else if (type == 'M') {
2686 GetLocaleInfoA(locale,
2687 LOCALE_SABBREVMONTHNAME1
2688 + xtime->wMonth - 1,
2690 } else if (count == 4) {
2691 GetLocaleInfoA(locale,
2693 + xtime->wMonth - 1,
2696 sprintf(buf, dgfmt[count], xtime->wMonth);
2698 } else if (type == 'y') {
2700 sprintf(buf, "%d", xtime->wYear);
2701 } else if (count == 3) {
2703 WARN("unknown format, c=%c, n=%d\n", type, count);
2705 sprintf(buf, dgfmt[count], xtime->wYear % 100);
2707 } else if (type == 'g') {
2709 FIXME("LOCALE_ICALENDARTYPE unimp.\n");
2713 WARN("unknown format, c=%c, n=%d\n", type, count);
2715 } else if (type == 'h') {
2716 /* gives us hours 1:00 -- 12:00 */
2717 sprintf(buf, dgfmt[count], (xtime->wHour-1)%12 +1);
2718 } else if (type == 'H') {
2720 sprintf(buf, dgfmt[count], xtime->wHour);
2721 } else if ( type == 'm') {
2722 sprintf(buf, dgfmt[count], xtime->wMinute);
2723 } else if ( type == 's') {
2724 sprintf(buf, dgfmt[count], xtime->wSecond);
2725 } else if (type == 't') {
2726 if ((tflags & TIME_NOTIMEMARKER))
2728 else if (count == 1) {
2729 sprintf(buf, "%c", (xtime->wHour < 12) ? 'A' : 'P');
2730 } else if (count == 2) {
2731 /* sprintf(buf, "%s", (xtime->wHour < 12) ? "AM" : "PM"); */
2732 GetLocaleInfoA(locale,
2734 ? LOCALE_S1159 : LOCALE_S2359,
2739 /* we need to check the next char in the format string
2740 again, no matter what happened */
2743 /* add the contents of buf to the output */
2744 buflen = strlen(buf);
2745 if (outpos + buflen < datelen) {
2746 date[outpos] = '\0'; /* for strcat to hook onto */
2750 date[outpos] = '\0';
2751 strncat(date, buf, datelen - outpos);
2752 date[datelen - 1] = '\0';
2753 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2754 WARN("insufficient buffer\n");
2758 /* reset the variables we used to keep track of this item */
2761 } else if (format[inpos] == '\0') {
2762 /* we can't check for this at the loop-head, because
2763 that breaks the printing of the last format-item */
2764 date[outpos] = '\0';
2767 /* continuing a code for an item */
2770 } else if (strchr("hHmstyMdg", format[inpos])) {
2771 type = format[inpos];
2774 } else if (format[inpos] == '\'') {
2778 date[outpos++] = format[inpos];
2780 /* now deal with a possible buffer overflow */
2781 if (outpos >= datelen) {
2782 date[datelen - 1] = '\0';
2783 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2789 SetLastError(ERROR_INSUFFICIENT_BUFFER);
2792 /* finish it off with a string terminator */
2795 if (outpos > datelen-1) outpos = datelen-1;
2796 date[outpos] = '\0';
2798 TRACE("returns string '%s', len %d\n", date, outpos);
2802 /******************************************************************************
2803 * OLE_GetFormatW [INTERNAL]
2805 static INT OLE_GetFormatW(LCID locale, DWORD flags, DWORD tflags,
2808 LPWSTR output, INT outlen)
2811 int count, type=0, inquote;
2812 int Overflow; /* loop check */
2816 WCHAR arg0[] = {0}, arg1[] = {'%','d',0};
2817 WCHAR arg2[] = {'%','0','2','d',0};
2819 int datevars=0, timevars=0;
2825 /* make a debug report */
2826 TRACE("args: 0x%lx, 0x%lx, 0x%lx, time(d=%d,h=%d,m=%d,s=%d), fmt:%s (at %p), "
2827 "%p with max len %d\n",
2828 locale, flags, tflags,
2829 xtime->wDay, xtime->wHour, xtime->wMinute, xtime->wSecond,
2830 debugstr_w(format), format, output, outlen);
2833 FIXME("outlen = 0, returning 255\n");
2837 /* initialize state variables */
2840 inquote = Overflow = 0;
2841 /* this is really just a sanity check */
2842 output[0] = buf[0] = 0;
2844 /* this loop is the core of the function */
2845 for (inpos = 0; /* we have several break points */ ; inpos++) {
2847 if (format[inpos] == (WCHAR) '\'') {
2848 if (format[inpos+1] == '\'') {
2850 output[outpos++] = '\'';
2855 } else if (format[inpos] == 0) {
2856 output[outpos++] = 0;
2857 if (outpos > outlen) Overflow = 1;
2858 break; /* normal exit (within a quote) */
2860 output[outpos++] = format[inpos]; /* copy input */
2861 if (outpos > outlen) {
2863 output[outpos-1] = 0;
2867 } else if ( (count && (format[inpos] != type))
2868 || ( (count==4 && type =='y') ||
2869 (count==4 && type =='M') ||
2870 (count==4 && type =='d') ||
2871 (count==2 && type =='g') ||
2872 (count==2 && type =='h') ||
2873 (count==2 && type =='H') ||
2874 (count==2 && type =='m') ||
2875 (count==2 && type =='s') ||
2876 (count==2 && type =='t') ) ) {
2881 GetLocaleInfoW(locale,
2882 LOCALE_SDAYNAME1 + (xtime->wDayOfWeek +6)%7,
2883 buf, sizeof(buf)/sizeof(WCHAR) );
2884 } else if (count == 3) {
2885 GetLocaleInfoW(locale,
2886 LOCALE_SABBREVDAYNAME1 +
2887 (xtime->wDayOfWeek +6)%7,
2888 buf, sizeof(buf)/sizeof(WCHAR) );
2890 sprintf( tmp, "%.*d", count, xtime->wDay );
2891 MultiByteToWideChar( CP_ACP, 0, tmp, -1, buf, sizeof(buf)/sizeof(WCHAR) );
2897 GetLocaleInfoW(locale, LOCALE_SMONTHNAME1 +
2898 xtime->wMonth -1, buf,
2899 sizeof(buf)/sizeof(WCHAR) );
2900 } else if (count == 3) {
2901 GetLocaleInfoW(locale, LOCALE_SABBREVMONTHNAME1 +
2902 xtime->wMonth -1, buf,
2903 sizeof(buf)/sizeof(WCHAR) );
2905 sprintf( tmp, "%.*d", count, xtime->wMonth );
2906 MultiByteToWideChar( CP_ACP, 0, tmp, -1, buf, sizeof(buf)/sizeof(WCHAR) );
2911 sprintf( tmp, "%d", xtime->wYear );
2912 } else if (count == 3) {
2913 strcpy( tmp, "yyy" );
2915 sprintf( tmp, "%.*d", count, xtime->wYear % 100 );
2917 MultiByteToWideChar( CP_ACP, 0, tmp, -1, buf, sizeof(buf)/sizeof(WCHAR) );
2922 FIXME("LOCALE_ICALENDARTYPE unimplemented\n");
2923 strcpy( tmp, "AD" );
2925 /* Win API sez we copy it verbatim */
2928 MultiByteToWideChar( CP_ACP, 0, tmp, -1, buf, sizeof(buf)/sizeof(WCHAR) );
2932 /* hours 1:00-12:00 --- is this right? */
2933 sprintf( tmp, "%.*d", count, (xtime->wHour-1)%12 +1);
2934 MultiByteToWideChar( CP_ACP, 0, tmp, -1, buf, sizeof(buf)/sizeof(WCHAR) );
2938 sprintf( tmp, "%.*d", count, xtime->wHour );
2939 MultiByteToWideChar( CP_ACP, 0, tmp, -1, buf, sizeof(buf)/sizeof(WCHAR) );
2943 sprintf( tmp, "%.*d", count, xtime->wMinute );
2944 MultiByteToWideChar( CP_ACP, 0, tmp, -1, buf, sizeof(buf)/sizeof(WCHAR) );
2948 sprintf( tmp, "%.*d", count, xtime->wSecond );
2949 MultiByteToWideChar( CP_ACP, 0, tmp, -1, buf, sizeof(buf)/sizeof(WCHAR) );
2953 GetLocaleInfoW(locale, (xtime->wHour < 12) ?
2954 LOCALE_S1159 : LOCALE_S2359,
2962 /* no matter what happened, we need to check this next
2963 character the next time we loop through */
2966 /* cat buf onto the output */
2967 outlen = strlenW(buf);
2968 if (outpos + buflen < outlen) {
2969 strcpyW( output + outpos, buf );
2972 lstrcpynW( output + outpos, buf, outlen - outpos );
2974 break; /* Abnormal exit */
2977 /* reset the variables we used this time */
2980 } else if (format[inpos] == 0) {
2981 /* we can't check for this at the beginning, because that
2982 would keep us from printing a format spec that ended the
2985 break; /* NORMAL EXIT */
2987 /* how we keep track of the middle of a format spec */
2990 } else if ( (datevars && (format[inpos]=='d' ||
2991 format[inpos]=='M' ||
2992 format[inpos]=='y' ||
2993 format[inpos]=='g') ) ||
2994 (timevars && (format[inpos]=='H' ||
2995 format[inpos]=='h' ||
2996 format[inpos]=='m' ||
2997 format[inpos]=='s' ||
2998 format[inpos]=='t') ) ) {
2999 type = format[inpos];
3002 } else if (format[inpos] == '\'') {
3006 /* unquoted literals */
3007 output[outpos++] = format[inpos];
3012 SetLastError(ERROR_INSUFFICIENT_BUFFER);
3013 WARN(" buffer overflow\n");
3016 /* final string terminator and sanity check */
3018 if (outpos > outlen-1) outpos = outlen-1;
3019 output[outpos] = '0';
3021 TRACE(" returning %s\n", debugstr_w(output));
3023 return (!Overflow) ? outlen : 0;
3028 /******************************************************************************
3029 * GetDateFormatA [KERNEL32.@]
3030 * Makes an ASCII string of the date
3032 * This function uses format to format the date, or, if format
3033 * is NULL, uses the default for the locale. format is a string
3034 * of literal fields and characters as follows:
3036 * - d single-digit (no leading zero) day (of month)
3037 * - dd two-digit day (of month)
3038 * - ddd short day-of-week name
3039 * - dddd long day-of-week name
3040 * - M single-digit month
3041 * - MM two-digit month
3042 * - MMM short month name
3043 * - MMMM full month name
3044 * - y two-digit year, no leading 0
3045 * - yy two-digit year
3046 * - yyyy four-digit year
3050 INT WINAPI GetDateFormatA(LCID locale,DWORD flags,
3052 LPCSTR format, LPSTR date,INT datelen)
3055 char format_buf[40];
3058 LPSYSTEMTIME thistime;
3064 TRACE("(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",
3065 locale,flags,xtime,format,date,datelen);
3068 locale = LOCALE_SYSTEM_DEFAULT;
3071 if (locale == LOCALE_SYSTEM_DEFAULT) {
3072 thislocale = GetSystemDefaultLCID();
3073 } else if (locale == LOCALE_USER_DEFAULT) {
3074 thislocale = GetUserDefaultLCID();
3076 thislocale = locale;
3079 if (xtime == NULL) {
3082 /* Silently correct wDayOfWeek by tranforming to FileTime and back again*/
3083 res=SystemTimeToFileTime(xtime,&ft);
3084 /* Check year(?)/month and date for range and set ERROR_INVALID_PARAMETER on error*/
3085 /*FIXME: SystemTimeToFileTime doesn't yet do that ckeck*/
3088 SetLastError(ERROR_INVALID_PARAMETER);
3091 FileTimeToSystemTime(&ft,&t);
3096 if (format == NULL) {
3097 GetLocaleInfoA(thislocale, ((flags&DATE_LONGDATE)
3099 : LOCALE_SSHORTDATE),
3100 format_buf, sizeof(format_buf));
3101 thisformat = format_buf;
3103 thisformat = format;
3107 ret = OLE_GetFormatA(thislocale, flags, 0, thistime, thisformat,
3112 "GetDateFormatA() returning %d, with data=%s\n",
3117 /******************************************************************************
3118 * GetDateFormatW [KERNEL32.@]
3119 * Makes a Unicode string of the date
3121 * Acts the same as GetDateFormatA(), except that it's Unicode.
3122 * Accepts & returns sizes as counts of Unicode characters.
3125 INT WINAPI GetDateFormatW(LCID locale,DWORD flags,
3128 LPWSTR date, INT datelen)
3130 unsigned short datearr[] = {'1','9','9','4','-','1','-','1',0};
3132 FIXME("STUB (should call OLE_GetFormatW)\n");
3133 lstrcpynW(date, datearr, datelen);
3134 return ( datelen < 9) ? datelen : 9;
3139 /**************************************************************************
3140 * EnumDateFormatsA (KERNEL32.@)
3142 BOOL WINAPI EnumDateFormatsA(
3143 DATEFMT_ENUMPROCA lpDateFmtEnumProc, LCID Locale, DWORD dwFlags)
3145 LCID Loc = GetUserDefaultLCID();
3146 if(!lpDateFmtEnumProc)
3148 SetLastError(ERROR_INVALID_PARAMETER);
3155 case 0x00000407: /* (Loc,"de_DE") */
3159 case DATE_SHORTDATE:
3160 if(!(*lpDateFmtEnumProc)("dd.MM.yy")) return TRUE;
3161 if(!(*lpDateFmtEnumProc)("d.M.yyyy")) return TRUE;
3162 if(!(*lpDateFmtEnumProc)("d.MM.yy")) return TRUE;
3163 if(!(*lpDateFmtEnumProc)("d.M.yy")) return TRUE;
3166 if(!(*lpDateFmtEnumProc)("dddd,d. MMMM yyyy")) return TRUE;
3167 if(!(*lpDateFmtEnumProc)("d. MMMM yyyy")) return TRUE;
3168 if(!(*lpDateFmtEnumProc)("d. MMM yyyy")) return TRUE;
3171 FIXME("Unknown date format (%ld)\n", dwFlags);
3172 SetLastError(ERROR_INVALID_PARAMETER);
3177 case 0x0000040c: /* (Loc,"fr_FR") */
3181 case DATE_SHORTDATE:
3182 if(!(*lpDateFmtEnumProc)("dd/MM/yy")) return TRUE;
3183 if(!(*lpDateFmtEnumProc)("dd.MM.yy")) return TRUE;
3184 if(!(*lpDateFmtEnumProc)("dd-MM-yy")) return TRUE;
3185 if(!(*lpDateFmtEnumProc)("dd/MM/yyyy")) return TRUE;
3188 if(!(*lpDateFmtEnumProc)("dddd d MMMM yyyy")) return TRUE;
3189 if(!(*lpDateFmtEnumProc)("d MMM yy")) return TRUE;
3190 if(!(*lpDateFmtEnumProc)("d MMMM yyyy")) return TRUE;
3193 FIXME("Unknown date format (%ld)\n", dwFlags);
3194 SetLastError(ERROR_INVALID_PARAMETER);
3199 case 0x00000c0c: /* (Loc,"fr_CA") */
3203 case DATE_SHORTDATE:
3204 if(!(*lpDateFmtEnumProc)("yy-MM-dd")) return TRUE;
3205 if(!(*lpDateFmtEnumProc)("dd-MM-yy")) return TRUE;
3206 if(!(*lpDateFmtEnumProc)("yy MM dd")) return TRUE;
3207 if(!(*lpDateFmtEnumProc)("dd/MM/yy")) return TRUE;
3210 if(!(*lpDateFmtEnumProc)("d MMMM, yyyy")) return TRUE;
3211 if(!(*lpDateFmtEnumProc)("d MMM yyyy")) return TRUE;
3214 FIXME("Unknown date format (%ld)\n", dwFlags);
3215 SetLastError(ERROR_INVALID_PARAMETER);
3220 case 0x00000809: /* (Loc,"en_UK") */
3224 case DATE_SHORTDATE:
3225 if(!(*lpDateFmtEnumProc)("dd/MM/yy")) return TRUE;
3226 if(!(*lpDateFmtEnumProc)("dd/MM/yyyy")) return TRUE;
3227 if(!(*lpDateFmtEnumProc)("d/M/yy")) return TRUE;
3228 if(!(*lpDateFmtEnumProc)("d.M.yy")) return TRUE;
3231 if(!(*lpDateFmtEnumProc)("dd MMMM yyyy")) return TRUE;
3232 if(!(*lpDateFmtEnumProc)("d MMMM yyyy")) return TRUE;
3235 FIXME("Unknown date format (%ld)\n", dwFlags);
3236 SetLastError(ERROR_INVALID_PARAMETER);
3241 case 0x00000c09: /* (Loc,"en_AU") */
3245 case DATE_SHORTDATE:
3246 if(!(*lpDateFmtEnumProc)("d/MM/yy")) return TRUE;
3247 if(!(*lpDateFmtEnumProc)("d/M/yy")) return TRUE;
3248 if(!(*lpDateFmtEnumProc)("dd/MM/yy")) return TRUE;
3251 if(!(*lpDateFmtEnumProc)("dddd,d MMMM yyyy")) return TRUE;
3252 if(!(*lpDateFmtEnumProc)("d MMMM yyyy")) return TRUE;
3255 FIXME("Unknown date format (%ld)\n", dwFlags);
3256 SetLastError(ERROR_INVALID_PARAMETER);
3261 case 0x00001009: /* (Loc,"en_CA") */
3265 case DATE_SHORTDATE:
3266 if(!(*lpDateFmtEnumProc)("dd/MM/yy")) return TRUE;
3267 if(!(*lpDateFmtEnumProc)("d/M/yy")) return TRUE;
3268 if(!(*lpDateFmtEnumProc)("yy-MM-dd")) return TRUE;
3269 if(!(*lpDateFmtEnumProc)("M/dd/yy")) return TRUE;
3272 if(!(*lpDateFmtEnumProc)("d-MMM-yy")) return TRUE;
3273 if(!(*lpDateFmtEnumProc)("MMMM d, yyyy")) return TRUE;
3276 FIXME("Unknown date format (%ld)\n", dwFlags);
3277 SetLastError(ERROR_INVALID_PARAMETER);
3282 case 0x00001409: /* (Loc,"en_NZ") */
3286 case DATE_SHORTDATE:
3287 if(!(*lpDateFmtEnumProc)("d/MM/yy")) return TRUE;
3288 if(!(*lpDateFmtEnumProc)("dd/MM/yy")) return TRUE;
3289 if(!(*lpDateFmtEnumProc)("d.MM.yy")) return TRUE;
3292 if(!(*lpDateFmtEnumProc)("d MMMM yyyy")) return TRUE;
3293 if(!(*lpDateFmtEnumProc)("dddd, d MMMM yyyy")) return TRUE;
3296 FIXME("Unknown date format (%ld)\n", dwFlags);
3297 SetLastError(ERROR_INVALID_PARAMETER);
3302 case 0x00001809: /* (Loc,"en_IE") */
3306 case DATE_SHORTDATE:
3307 if(!(*lpDateFmtEnumProc)("dd/MM/yy")) return TRUE;
3308 if(!(*lpDateFmtEnumProc)("d/M/yy")) return TRUE;
3309 if(!(*lpDateFmtEnumProc)("d.M.yy")) return TRUE;
3312 if(!(*lpDateFmtEnumProc)("dd MMMM yyyy")) return TRUE;
3313 if(!(*lpDateFmtEnumProc)("d MMMM yyyy")) return TRUE;
3316 FIXME("Unknown date format (%ld)\n", dwFlags);
3317 SetLastError(ERROR_INVALID_PARAMETER);
3322 case 0x00001c09: /* (Loc,"en_ZA") */
3326 case DATE_SHORTDATE:
3327 if(!(*lpDateFmtEnumProc)("yy/MM/dd")) return TRUE;
3330 if(!(*lpDateFmtEnumProc)("dd MMMM yyyy")) return TRUE;
3333 FIXME("Unknown date format (%ld)\n", dwFlags);
3334 SetLastError(ERROR_INVALID_PARAMETER);
3339 case 0x00002009: /* (Loc,"en_JM") */
3343 case DATE_SHORTDATE:
3344 if(!(*lpDateFmtEnumProc)("dd/MM/yyyy")) return TRUE;
3347 if(!(*lpDateFmtEnumProc)("dddd,MMMM dd,yyyy")) return TRUE;
3348 if(!(*lpDateFmtEnumProc)("MMMM dd,yyyy")) return TRUE;
3349 if(!(*lpDateFmtEnumProc)("dddd,dd MMMM,yyyy")) return TRUE;
3350 if(!(*lpDateFmtEnumProc)("dd MMMM,yyyy")) return TRUE;
3353 FIXME("Unknown date format (%ld)\n", dwFlags);
3354 SetLastError(ERROR_INVALID_PARAMETER);
3359 case 0x00002809: /* (Loc,"en_BZ") */
3360 case 0x00002c09: /* (Loc,"en_TT") */
3364 case DATE_SHORTDATE:
3365 if(!(*lpDateFmtEnumProc)("dd/MM/yyyy")) return TRUE;
3368 if(!(*lpDateFmtEnumProc)("dddd,dd MMMM yyyy")) return TRUE;
3371 FIXME("Unknown date format (%ld)\n", dwFlags);
3372 SetLastError(ERROR_INVALID_PARAMETER);
3377 default: /* default to US English "en_US" */
3381 case DATE_SHORTDATE:
3382 if(!(*lpDateFmtEnumProc)("M/d/yy")) return TRUE;
3383 if(!(*lpDateFmtEnumProc)("M/d/yyyy")) return TRUE;
3384 if(!(*lpDateFmtEnumProc)("MM/dd/yy")) return TRUE;
3385 if(!(*lpDateFmtEnumProc)("MM/dd/yyyy")) return TRUE;
3386 if(!(*lpDateFmtEnumProc)("yy/MM/dd")) return TRUE;
3387 if(!(*lpDateFmtEnumProc)("dd-MMM-yy")) return TRUE;
3390 if(!(*lpDateFmtEnumProc)("dddd, MMMM dd, yyyy")) return TRUE;
3391 if(!(*lpDateFmtEnumProc)("MMMM dd, yyyy")) return TRUE;
3392 if(!(*lpDateFmtEnumProc)("dddd, dd MMMM, yyyy")) return TRUE;
3393 if(!(*lpDateFmtEnumProc)("dd MMMM, yyyy")) return TRUE;
3396 FIXME("Unknown date format (%ld)\n", dwFlags);
3397 SetLastError(ERROR_INVALID_PARAMETER);
3404 /**************************************************************************
3405 * EnumDateFormatsW (KERNEL32.@)
3407 BOOL WINAPI EnumDateFormatsW(
3408 DATEFMT_ENUMPROCW lpDateFmtEnumProc, LCID Locale, DWORD dwFlags)
3410 FIXME("(%p, %ld, %ld): stub\n", lpDateFmtEnumProc, Locale, dwFlags);
3411 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
3415 /**************************************************************************
3416 * EnumTimeFormatsA (KERNEL32.@)
3418 BOOL WINAPI EnumTimeFormatsA(
3419 TIMEFMT_ENUMPROCA lpTimeFmtEnumProc, LCID Locale, DWORD dwFlags)
3421 LCID Loc = GetUserDefaultLCID();
3422 if(!lpTimeFmtEnumProc)
3424 SetLastError(ERROR_INVALID_PARAMETER);
3429 FIXME("Unknown time format (%ld)\n", dwFlags);
3434 case 0x00000407: /* (Loc,"de_DE") */
3436 if(!(*lpTimeFmtEnumProc)("HH.mm")) return TRUE;
3437 if(!(*lpTimeFmtEnumProc)("HH:mm:ss")) return TRUE;
3438 if(!(*lpTimeFmtEnumProc)("H:mm:ss")) return TRUE;
3439 if(!(*lpTimeFmtEnumProc)("H.mm")) return TRUE;
3440 if(!(*lpTimeFmtEnumProc)("H.mm'Uhr'")) return TRUE;
3444 case 0x0000040c: /* (Loc,"fr_FR") */
3445 case 0x00000c0c: /* (Loc,"fr_CA") */
3447 if(!(*lpTimeFmtEnumProc)("H:mm")) return TRUE;
3448 if(!(*lpTimeFmtEnumProc)("HH:mm:ss")) return TRUE;
3449 if(!(*lpTimeFmtEnumProc)("H:mm:ss")) return TRUE;
3450 if(!(*lpTimeFmtEnumProc)("HH.mm")) return TRUE;
3451 if(!(*lpTimeFmtEnumProc)("HH'h'mm")) return TRUE;
3455 case 0x00000809: /* (Loc,"en_UK") */
3456 case 0x00000c09: /* (Loc,"en_AU") */
3457 case 0x00001409: /* (Loc,"en_NZ") */
3458 case 0x00001809: /* (Loc,"en_IE") */
3460 if(!(*lpTimeFmtEnumProc)("h:mm:ss tt")) return TRUE;
3461 if(!(*lpTimeFmtEnumProc)("HH:mm:ss")) return TRUE;
3462 if(!(*lpTimeFmtEnumProc)("H:mm:ss")) return TRUE;
3466 case 0x00001c09: /* (Loc,"en_ZA") */
3467 case 0x00002809: /* (Loc,"en_BZ") */
3468 case 0x00002c09: /* (Loc,"en_TT") */
3470 if(!(*lpTimeFmtEnumProc)("h:mm:ss tt")) return TRUE;
3471 if(!(*lpTimeFmtEnumProc)("hh:mm:ss tt")) return TRUE;
3475 default: /* default to US style "en_US" */
3477 if(!(*lpTimeFmtEnumProc)("h:mm:ss tt")) return TRUE;
3478 if(!(*lpTimeFmtEnumProc)("hh:mm:ss tt")) return TRUE;
3479 if(!(*lpTimeFmtEnumProc)("H:mm:ss")) return TRUE;
3480 if(!(*lpTimeFmtEnumProc)("HH:mm:ss")) return TRUE;
3486 /**************************************************************************
3487 * EnumTimeFormatsW (KERNEL32.@)
3489 BOOL WINAPI EnumTimeFormatsW(
3490 TIMEFMT_ENUMPROCW lpTimeFmtEnumProc, LCID Locale, DWORD dwFlags)
3492 FIXME("(%p,%ld,%ld): stub\n", lpTimeFmtEnumProc, Locale, dwFlags);
3493 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
3497 /**************************************************************************
3498 * This function is used just locally !
3499 * Description: Inverts a string.
3501 static void OLE_InvertString(char* string)
3503 char sTmpArray[128];
3506 for (counter = strlen(string); counter > 0; counter--)
3508 memcpy(sTmpArray + i, string + counter-1, 1);
3511 memcpy(sTmpArray + i, "\0", 1);
3512 strcpy(string, sTmpArray);
3515 /***************************************************************************************
3516 * This function is used just locally !
3517 * Description: Test if the given string (psNumber) is valid or not.
3518 * The valid characters are the following:
3519 * - Characters '0' through '9'.
3520 * - One decimal point (dot) if the number is a floating-point value.
3521 * - A minus sign in the first character position if the number is
3523 * If the function succeeds, psBefore/psAfter will point to the string
3524 * on the right/left of the decimal symbol. pbNegative indicates if the
3525 * number is negative.
3527 static INT OLE_GetNumberComponents(char* pInput, char* psBefore, char* psAfter, BOOL* pbNegative)
3529 char sNumberSet[] = "0123456789";
3530 BOOL bInDecimal = FALSE;
3532 /* Test if we do have a minus sign */
3533 if ( *pInput == '-' )
3536 pInput++; /* Jump to the next character. */
3539 while(*pInput != '\0')
3541 /* Do we have a valid numeric character */
3542 if ( strchr(sNumberSet, *pInput) != NULL )
3544 if (bInDecimal == TRUE)
3545 *psAfter++ = *pInput;
3547 *psBefore++ = *pInput;
3551 /* Is this a decimal point (dot) */
3552 if ( *pInput == '.' )
3554 /* Is it the first time we find it */
3555 if ((bInDecimal == FALSE))
3558 return -1; /* ERROR: Invalid parameter */
3562 /* It's neither a numeric character, nor a decimal point.
3563 * Thus, return an error.
3571 /* Add an End of Line character to the output buffers */
3578 /**************************************************************************
3579 * This function is used just locally !
3580 * Description: A number could be formatted using different numbers
3581 * of "digits in group" (example: 4;3;2;0).
3582 * The first parameter of this function is an array
3583 * containing the rule to be used. It's format is the following:
3584 * |NDG|DG1|DG2|...|0|
3585 * where NDG is the number of used "digits in group" and DG1, DG2,
3586 * are the corresponding "digits in group".
3587 * Thus, this function returns the grouping value in the array
3588 * pointed by the second parameter.
3590 static INT OLE_GetGrouping(char* sRule, INT index)
3592 char sData[2], sRuleSize[2];
3593 INT nData, nRuleSize;
3595 memcpy(sRuleSize, sRule, 1);
3596 memcpy(sRuleSize+1, "\0", 1);
3597 nRuleSize = atoi(sRuleSize);
3599 if (index > 0 && index < nRuleSize)
3601 memcpy(sData, sRule+index, 1);
3602 memcpy(sData+1, "\0", 1);
3603 nData = atoi(sData);
3608 memcpy(sData, sRule+nRuleSize-1, 1);
3609 memcpy(sData+1, "\0", 1);
3610 nData = atoi(sData);
3616 /**************************************************************************
3617 * GetNumberFormatA (KERNEL32.@)
3619 INT WINAPI GetNumberFormatA(LCID locale, DWORD dwflags,
3620 LPCSTR lpvalue, const NUMBERFMTA * lpFormat,
3621 LPSTR lpNumberStr, int cchNumber)
3623 char sNumberDigits[3], sDecimalSymbol[5], sDigitsInGroup[11], sDigitGroupSymbol[5], sILZero[2];
3624 INT nNumberDigits, nNumberDecimal, i, j, nCounter, nStep, nRuleIndex, nGrouping, nDigits, retVal, nLZ;
3625 char sNumber[128], sDestination[128], sDigitsAfterDecimal[10], sDigitsBeforeDecimal[128];
3626 char sRule[10], sSemiColumn[]=";", sBuffer[5], sNegNumber[2];
3627 char *pStr = NULL, *pTmpStr = NULL;
3628 LCID systemDefaultLCID;
3629 BOOL bNegative = FALSE;
3638 strncpy(sNumber, lpvalue, 128);
3639 sNumber[127] = '\0';
3641 /* Make sure we have a valid input string, get the number
3642 * of digits before and after the decimal symbol, and check
3643 * if this is a negative number.
3645 if ( OLE_GetNumberComponents(sNumber, sDigitsBeforeDecimal, sDigitsAfterDecimal, &bNegative) != -1)
3647 nNumberDecimal = strlen(sDigitsBeforeDecimal);
3648 nDigits = strlen(sDigitsAfterDecimal);
3652 SetLastError(ERROR_INVALID_PARAMETER);
3656 /* Which source will we use to format the string */
3657 used_operation = RETURN_ERROR;
3658 if (lpFormat != NULL)
3661 used_operation = USE_PARAMETER;
3665 if (dwflags & LOCALE_NOUSEROVERRIDE)
3666 used_operation = USE_LOCALEINFO;
3668 used_operation = USE_SYSTEMDEFAULT;
3671 /* Load the fields we need */
3672 switch(used_operation)
3674 case USE_LOCALEINFO:
3675 GetLocaleInfoA(locale, LOCALE_IDIGITS, sNumberDigits, sizeof(sNumberDigits));
3676 GetLocaleInfoA(locale, LOCALE_SDECIMAL, sDecimalSymbol, sizeof(sDecimalSymbol));
3677 GetLocaleInfoA(locale, LOCALE_SGROUPING, sDigitsInGroup, sizeof(sDigitsInGroup));
3678 GetLocaleInfoA(locale, LOCALE_STHOUSAND, sDigitGroupSymbol, sizeof(sDigitGroupSymbol));
3679 GetLocaleInfoA(locale, LOCALE_ILZERO, sILZero, sizeof(sILZero));
3680 GetLocaleInfoA(locale, LOCALE_INEGNUMBER, sNegNumber, sizeof(sNegNumber));
3683 sprintf(sNumberDigits, "%d",lpFormat->NumDigits);
3684 strcpy(sDecimalSymbol, lpFormat->lpDecimalSep);
3685 sprintf(sDigitsInGroup, "%d;0",lpFormat->Grouping);
3686 strcpy(sDigitGroupSymbol, lpFormat->lpThousandSep);
3687 sprintf(sILZero, "%d",lpFormat->LeadingZero);
3688 sprintf(sNegNumber, "%d",lpFormat->NegativeOrder);
3690 case USE_SYSTEMDEFAULT:
3691 systemDefaultLCID = GetSystemDefaultLCID();
3692 GetLocaleInfoA(systemDefaultLCID, LOCALE_IDIGITS, sNumberDigits, sizeof(sNumberDigits));
3693 GetLocaleInfoA(systemDefaultLCID, LOCALE_SDECIMAL, sDecimalSymbol, sizeof(sDecimalSymbol));
3694 GetLocaleInfoA(systemDefaultLCID, LOCALE_SGROUPING, sDigitsInGroup, sizeof(sDigitsInGroup));
3695 GetLocaleInfoA(systemDefaultLCID, LOCALE_STHOUSAND, sDigitGroupSymbol, sizeof(sDigitGroupSymbol));
3696 GetLocaleInfoA(systemDefaultLCID, LOCALE_ILZERO, sILZero, sizeof(sILZero));
3697 GetLocaleInfoA(systemDefaultLCID, LOCALE_INEGNUMBER, sNegNumber, sizeof(sNegNumber));
3700 SetLastError(ERROR_INVALID_PARAMETER);
3704 nNumberDigits = atoi(sNumberDigits);
3706 /* Remove the ";" */
3709 for (nCounter=0; nCounter<strlen(sDigitsInGroup); nCounter++)
3711 if ( memcmp(sDigitsInGroup + nCounter, sSemiColumn, 1) != 0 )
3713 memcpy(sRule + j, sDigitsInGroup + nCounter, 1);
3718 sprintf(sBuffer, "%d", i);
3719 memcpy(sRule, sBuffer, 1); /* Number of digits in the groups ( used by OLE_GetGrouping() ) */
3720 memcpy(sRule + j, "\0", 1);
3722 /* First, format the digits before the decimal. */
3723 if ((nNumberDecimal>0) && (atoi(sDigitsBeforeDecimal) != 0))
3725 /* Working on an inverted string is easier ! */
3726 OLE_InvertString(sDigitsBeforeDecimal);
3728 nStep = nCounter = i = j = 0;
3730 nGrouping = OLE_GetGrouping(sRule, nRuleIndex);
3732 /* Here, we will loop until we reach the end of the string.
3733 * An internal counter (j) is used in order to know when to
3734 * insert the "digit group symbol".
3736 while (nNumberDecimal > 0)
3738 i = nCounter + nStep;
3739 memcpy(sDestination + i, sDigitsBeforeDecimal + nCounter, 1);
3745 if (nRuleIndex < sRule[0])
3747 nGrouping = OLE_GetGrouping(sRule, nRuleIndex);
3748 memcpy(sDestination + i+1, sDigitGroupSymbol, strlen(sDigitGroupSymbol));
3749 nStep+= strlen(sDigitGroupSymbol);
3755 memcpy(sDestination + i+1, "\0", 1);
3756 /* Get the string in the right order ! */
3757 OLE_InvertString(sDestination);
3761 nLZ = atoi(sILZero);
3764 /* Use 0.xxx instead of .xxx */
3765 memcpy(sDestination, "0", 1);
3766 memcpy(sDestination+1, "\0", 1);
3769 memcpy(sDestination, "\0", 1);
3773 /* Second, format the digits after the decimal. */
3775 nCounter = nNumberDigits;
3776 if ( (nDigits>0) && (pStr = strstr (sNumber, ".")) )
3778 i = strlen(sNumber) - strlen(pStr) + 1;
3779 strncpy ( sDigitsAfterDecimal, sNumber + i, nNumberDigits);
3780 j = strlen(sDigitsAfterDecimal);
3781 if (j < nNumberDigits)
3782 nCounter = nNumberDigits-j;
3784 for (i=0;i<nCounter;i++)
3785 memcpy(sDigitsAfterDecimal+i+j, "0", 1);
3786 memcpy(sDigitsAfterDecimal + nNumberDigits, "\0", 1);
3788 i = strlen(sDestination);
3789 j = strlen(sDigitsAfterDecimal);
3790 /* Finally, construct the resulting formatted string. */
3792 for (nCounter=0; nCounter<i; nCounter++)
3793 memcpy(sNumber + nCounter, sDestination + nCounter, 1);
3795 memcpy(sNumber + nCounter, sDecimalSymbol, strlen(sDecimalSymbol));
3798 memcpy(sNumber + nCounter+i+strlen(sDecimalSymbol), sDigitsAfterDecimal + i, 1);
3799 memcpy(sNumber + nCounter+i+strlen(sDecimalSymbol), "\0", 1);
3801 /* Is it a negative number */
3802 if (bNegative == TRUE)
3804 i = atoi(sNegNumber);
3805 pStr = sDestination;
3811 while (*sNumber != '\0')
3812 *pStr++ = *pTmpStr++;
3817 while (*pTmpStr != '\0')
3818 *pStr++ = *pTmpStr++;
3823 while (*pTmpStr != '\0')
3824 *pStr++ = *pTmpStr++;
3827 while (*pTmpStr != '\0')
3828 *pStr++ = *pTmpStr++;
3832 while (*pTmpStr != '\0')
3833 *pStr++ = *pTmpStr++;
3838 while (*pTmpStr != '\0')
3839 *pStr++ = *pTmpStr++;
3844 strcpy(sDestination, sNumber);
3846 /* If cchNumber is zero, then returns the number of bytes or characters
3847 * required to hold the formatted number string
3850 retVal = strlen(sDestination) + 1;
3853 strncpy (lpNumberStr, sDestination, cchNumber-1);
3854 *(lpNumberStr+cchNumber-1) = '\0'; /* ensure we got a NULL at the end */
3855 retVal = strlen(lpNumberStr);
3861 /**************************************************************************
3862 * GetNumberFormatW (KERNEL32.@)
3864 INT WINAPI GetNumberFormatW(LCID locale, DWORD dwflags,
3865 LPCWSTR lpvalue, const NUMBERFMTW * lpFormat,
3866 LPWSTR lpNumberStr, int cchNumber)
3868 FIXME("%s: stub, no reformating done\n",debugstr_w(lpvalue));
3870 lstrcpynW( lpNumberStr, lpvalue, cchNumber );
3871 return cchNumber? strlenW( lpNumberStr ) : 0;
3874 /**************************************************************************
3875 * GetCurrencyFormatA (KERNEL32.@)
3877 INT WINAPI GetCurrencyFormatA(LCID locale, DWORD dwflags,
3878 LPCSTR lpvalue, const CURRENCYFMTA * lpFormat,
3879 LPSTR lpCurrencyStr, int cchCurrency)
3881 UINT nPosOrder, nNegOrder;
3883 char sDestination[128], sNegOrder[8], sPosOrder[8], sCurrencySymbol[8];
3884 char *pDestination = sDestination;
3885 char sNumberFormated[128];
3886 char *pNumberFormated = sNumberFormated;
3887 LCID systemDefaultLCID;
3888 BOOL bIsPositive = FALSE, bValidFormat = FALSE;
3897 NUMBERFMTA numberFmt;
3899 /* Which source will we use to format the string */
3900 used_operation = RETURN_ERROR;
3901 if (lpFormat != NULL)
3904 used_operation = USE_PARAMETER;
3908 if (dwflags & LOCALE_NOUSEROVERRIDE)
3909 used_operation = USE_LOCALEINFO;
3911 used_operation = USE_SYSTEMDEFAULT;
3914 /* Load the fields we need */
3915 switch(used_operation)
3917 case USE_LOCALEINFO:
3918 /* Specific to CURRENCYFMTA*/
3919 GetLocaleInfoA(locale, LOCALE_INEGCURR, sNegOrder, sizeof(sNegOrder));
3920 GetLocaleInfoA(locale, LOCALE_ICURRENCY, sPosOrder, sizeof(sPosOrder));
3921 GetLocaleInfoA(locale, LOCALE_SCURRENCY, sCurrencySymbol, sizeof(sCurrencySymbol));
3923 nPosOrder = atoi(sPosOrder);
3924 nNegOrder = atoi(sNegOrder);
3927 /* Specific to CURRENCYFMTA*/
3928 nNegOrder = lpFormat->NegativeOrder;
3929 nPosOrder = lpFormat->PositiveOrder;
3930 strcpy(sCurrencySymbol, lpFormat->lpCurrencySymbol);
3932 case USE_SYSTEMDEFAULT:
3933 systemDefaultLCID = GetSystemDefaultLCID();
3934 /* Specific to CURRENCYFMTA*/
3935 GetLocaleInfoA(systemDefaultLCID, LOCALE_INEGCURR, sNegOrder, sizeof(sNegOrder));
3936 GetLocaleInfoA(systemDefaultLCID, LOCALE_ICURRENCY, sPosOrder, sizeof(sPosOrder));
3937 GetLocaleInfoA(systemDefaultLCID, LOCALE_SCURRENCY, sCurrencySymbol, sizeof(sCurrencySymbol));
3939 nPosOrder = atoi(sPosOrder);
3940 nNegOrder = atoi(sNegOrder);
3943 SetLastError(ERROR_INVALID_PARAMETER);
3947 /* Construct a temporary number format structure */
3948 if (lpFormat != NULL)
3950 numberFmt.NumDigits = lpFormat->NumDigits;
3951 numberFmt.LeadingZero = lpFormat->LeadingZero;
3952 numberFmt.Grouping = lpFormat->Grouping;
3953 numberFmt.NegativeOrder = 0;
3954 numberFmt.lpDecimalSep = lpFormat->lpDecimalSep;
3955 numberFmt.lpThousandSep = lpFormat->lpThousandSep;
3956 bValidFormat = TRUE;
3959 /* Make a call to GetNumberFormatA() */
3960 if (*lpvalue == '-')
3962 bIsPositive = FALSE;
3963 retVal = GetNumberFormatA(locale,0,lpvalue+1,(bValidFormat)?&numberFmt:NULL,pNumberFormated,128);
3968 retVal = GetNumberFormatA(locale,0,lpvalue,(bValidFormat)?&numberFmt:NULL,pNumberFormated,128);
3974 /* construct the formatted string */
3979 case 0: /* Prefix, no separation */
3980 strcpy (pDestination, sCurrencySymbol);
3981 strcat (pDestination, pNumberFormated);
3983 case 1: /* Suffix, no separation */
3984 strcpy (pDestination, pNumberFormated);
3985 strcat (pDestination, sCurrencySymbol);
3987 case 2: /* Prefix, 1 char separation */
3988 strcpy (pDestination, sCurrencySymbol);
3989 strcat (pDestination, " ");
3990 strcat (pDestination, pNumberFormated);
3992 case 3: /* Suffix, 1 char separation */
3993 strcpy (pDestination, pNumberFormated);
3994 strcat (pDestination, " ");
3995 strcat (pDestination, sCurrencySymbol);
3998 SetLastError(ERROR_INVALID_PARAMETER);
4002 else /* negative number */
4006 case 0: /* format: ($1.1) */
4007 strcpy (pDestination, "(");
4008 strcat (pDestination, sCurrencySymbol);
4009 strcat (pDestination, pNumberFormated);
4010 strcat (pDestination, ")");
4012 case 1: /* format: -$1.1 */
4013 strcpy (pDestination, "-");
4014 strcat (pDestination, sCurrencySymbol);
4015 strcat (pDestination, pNumberFormated);
4017 case 2: /* format: $-1.1 */
4018 strcpy (pDestination, sCurrencySymbol);
4019 strcat (pDestination, "-");
4020 strcat (pDestination, pNumberFormated);
4022 case 3: /* format: $1.1- */
4023 strcpy (pDestination, sCurrencySymbol);
4024 strcat (pDestination, pNumberFormated);
4025 strcat (pDestination, "-");
4027 case 4: /* format: (1.1$) */
4028 strcpy (pDestination, "(");
4029 strcat (pDestination, pNumberFormated);
4030 strcat (pDestination, sCurrencySymbol);
4031 strcat (pDestination, ")");
4033 case 5: /* format: -1.1$ */
4034 strcpy (pDestination, "-");
4035 strcat (pDestination, pNumberFormated);
4036 strcat (pDestination, sCurrencySymbol);
4038 case 6: /* format: 1.1-$ */
4039 strcpy (pDestination, pNumberFormated);
4040 strcat (pDestination, "-");
4041 strcat (pDestination, sCurrencySymbol);
4043 case 7: /* format: 1.1$- */
4044 strcpy (pDestination, pNumberFormated);
4045 strcat (pDestination, sCurrencySymbol);
4046 strcat (pDestination, "-");
4048 case 8: /* format: -1.1 $ */
4049 strcpy (pDestination, "-");
4050 strcat (pDestination, pNumberFormated);
4051 strcat (pDestination, " ");
4052 strcat (pDestination, sCurrencySymbol);
4054 case 9: /* format: -$ 1.1 */
4055 strcpy (pDestination, "-");
4056 strcat (pDestination, sCurrencySymbol);
4057 strcat (pDestination, " ");
4058 strcat (pDestination, pNumberFormated);
4060 case 10: /* format: 1.1 $- */
4061 strcpy (pDestination, pNumberFormated);
4062 strcat (pDestination, " ");
4063 strcat (pDestination, sCurrencySymbol);
4064 strcat (pDestination, "-");
4066 case 11: /* format: $ 1.1- */
4067 strcpy (pDestination, sCurrencySymbol);
4068 strcat (pDestination, " ");
4069 strcat (pDestination, pNumberFormated);
4070 strcat (pDestination, "-");
4072 case 12: /* format: $ -1.1 */
4073 strcpy (pDestination, sCurrencySymbol);
4074 strcat (pDestination, " ");
4075 strcat (pDestination, "-");
4076 strcat (pDestination, pNumberFormated);
4078 case 13: /* format: 1.1- $ */
4079 strcpy (pDestination, pNumberFormated);
4080 strcat (pDestination, "-");
4081 strcat (pDestination, " ");
4082 strcat (pDestination, sCurrencySymbol);
4084 case 14: /* format: ($ 1.1) */
4085 strcpy (pDestination, "(");
4086 strcat (pDestination, sCurrencySymbol);
4087 strcat (pDestination, " ");
4088 strcat (pDestination, pNumberFormated);
4089 strcat (pDestination, ")");
4091 case 15: /* format: (1.1 $) */
4092 strcpy (pDestination, "(");
4093 strcat (pDestination, pNumberFormated);
4094 strcat (pDestination, " ");
4095 strcat (pDestination, sCurrencySymbol);
4096 strcat (pDestination, ")");
4099 SetLastError(ERROR_INVALID_PARAMETER);
4104 if (cchCurrency == 0)
4105 return strlen(pDestination) + 1;
4109 strncpy (lpCurrencyStr, pDestination, cchCurrency-1);
4110 *(lpCurrencyStr+cchCurrency-1) = '\0'; /* ensure we got a NULL at the end */
4111 return strlen(lpCurrencyStr);
4115 /**************************************************************************
4116 * GetCurrencyFormatW (KERNEL32.@)
4118 INT WINAPI GetCurrencyFormatW(LCID locale, DWORD dwflags,
4119 LPCWSTR lpvalue, const CURRENCYFMTW * lpFormat,
4120 LPWSTR lpCurrencyStr, int cchCurrency)
4122 FIXME("This API function is NOT implemented !\n");
4126 /******************************************************************************
4127 * OLE2NLS_CheckLocale [intern]
4129 static LCID OLE2NLS_CheckLocale (LCID locale)
4132 { locale = LOCALE_SYSTEM_DEFAULT;
4135 if (locale == LOCALE_SYSTEM_DEFAULT)
4136 { return GetSystemDefaultLCID();
4138 else if (locale == LOCALE_USER_DEFAULT)
4139 { return GetUserDefaultLCID();
4145 /******************************************************************************
4146 * GetTimeFormatA [KERNEL32.@]
4147 * Makes an ASCII string of the time
4149 * Formats date according to format, or locale default if format is
4150 * NULL. The format consists of literal characters and fields as follows:
4152 * h hours with no leading zero (12-hour)
4153 * hh hours with full two digits
4154 * H hours with no leading zero (24-hour)
4155 * HH hours with full two digits
4156 * m minutes with no leading zero
4157 * mm minutes with full two digits
4158 * s seconds with no leading zero
4159 * ss seconds with full two digits
4160 * t time marker (A or P)
4161 * tt time marker (AM, PM)
4165 GetTimeFormatA(LCID locale, /* [in] */
4166 DWORD flags, /* [in] */
4167 LPSYSTEMTIME xtime, /* [in] */
4168 LPCSTR format, /* [in] */
4169 LPSTR timestr, /* [out] */
4170 INT timelen /* [in] */)
4171 { char format_buf[40];
4174 LPSYSTEMTIME thistime;
4176 DWORD thisflags=LOCALE_STIMEFORMAT; /* standart timeformat */
4179 TRACE("GetTimeFormat(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",locale,flags,xtime,format,timestr,timelen);
4181 thislocale = OLE2NLS_CheckLocale ( locale );
4184 { if (flags & LOCALE_NOUSEROVERRIDE) /*use system default*/
4185 { thislocale = GetSystemDefaultLCID();
4187 GetLocaleInfoA(thislocale, thisflags, format_buf, sizeof(format_buf));
4188 thisformat = format_buf;
4191 { thisformat = format;
4194 if (xtime == NULL) /* NULL means use the current local time*/
4200 /* Check that hour,min and sec is in range */
4202 ret = OLE_GetFormatA(thislocale, thisflags, flags, thistime, thisformat,
4208 /******************************************************************************
4209 * GetTimeFormatW [KERNEL32.@]
4210 * Makes a Unicode string of the time
4213 GetTimeFormatW(LCID locale, /* [in] */
4214 DWORD flags, /* [in] */
4215 LPSYSTEMTIME xtime, /* [in] */
4216 LPCWSTR format, /* [in] */
4217 LPWSTR timestr, /* [out] */
4218 INT timelen /* [in] */)
4219 { WCHAR format_buf[40];
4222 LPSYSTEMTIME thistime;
4224 DWORD thisflags=LOCALE_STIMEFORMAT; /* standart timeformat */
4227 TRACE("GetTimeFormat(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",locale,flags,
4228 xtime,debugstr_w(format),timestr,timelen);
4230 thislocale = OLE2NLS_CheckLocale ( locale );
4233 { if (flags & LOCALE_NOUSEROVERRIDE) /*use system default*/
4234 { thislocale = GetSystemDefaultLCID();
4236 GetLocaleInfoW(thislocale, thisflags, format_buf, 40);
4237 thisformat = format_buf;
4240 { thisformat = format;
4243 if (xtime == NULL) /* NULL means use the current local time*/
4251 ret = OLE_GetFormatW(thislocale, thisflags, flags, thistime, thisformat,
4256 /******************************************************************************
4257 * EnumCalendarInfoA [KERNEL32.@]
4259 BOOL WINAPI EnumCalendarInfoA(
4260 CALINFO_ENUMPROCA calinfoproc,LCID locale,CALID calendar,CALTYPE caltype
4262 FIXME("(%p,0x%04lx,0x%08lx,0x%08lx),stub!\n",calinfoproc,locale,calendar,caltype);