| 1 | /* $Id: ole2nls.cpp,v 1.14 2001-09-05 12:57:59 bird Exp $
|
|---|
| 2 | *
|
|---|
| 3 | * National Language Support library
|
|---|
| 4 | *
|
|---|
| 5 | * Copyright 1995 Martin von Loewis
|
|---|
| 6 | * Copyright 1998 David Lee Lambert
|
|---|
| 7 | * Copyright 2000 Julio César Gázquez
|
|---|
| 8 | */
|
|---|
| 9 |
|
|---|
| 10 | #ifdef __WIN32OS2__
|
|---|
| 11 | #include <odin.h>
|
|---|
| 12 | #include <odinwrap.h>
|
|---|
| 13 |
|
|---|
| 14 | #include <string.h>
|
|---|
| 15 | #include <stdio.h>
|
|---|
| 16 | #include <heapstring.h>
|
|---|
| 17 | #include <ctype.h>
|
|---|
| 18 | #include <wcstr.h>
|
|---|
| 19 | #endif
|
|---|
| 20 |
|
|---|
| 21 | #include <string.h>
|
|---|
| 22 | #include <stdio.h>
|
|---|
| 23 | #include <ctype.h>
|
|---|
| 24 | #include <stdlib.h>
|
|---|
| 25 | #include <locale.h>
|
|---|
| 26 |
|
|---|
| 27 | #include "windef.h"
|
|---|
| 28 | #include "winbase.h"
|
|---|
| 29 | #include "wingdi.h"
|
|---|
| 30 | #include "winuser.h"
|
|---|
| 31 | #include "wine/unicode.h"
|
|---|
| 32 | #include "heap.h"
|
|---|
| 33 | #include "options.h"
|
|---|
| 34 | #include "winver.h"
|
|---|
| 35 | #include "winnls.h"
|
|---|
| 36 | #include "winreg.h"
|
|---|
| 37 | #include "winerror.h"
|
|---|
| 38 | #include "debugtools.h"
|
|---|
| 39 |
|
|---|
| 40 | #ifdef __WIN32OS2__
|
|---|
| 41 | #include <wctype.h>
|
|---|
| 42 | #include <unicode.h>
|
|---|
| 43 |
|
|---|
| 44 | #define DBG_LOCALLOG DBG_kernel32
|
|---|
| 45 | #include "dbglocal.h"
|
|---|
| 46 |
|
|---|
| 47 | ODINDEBUGCHANNEL(KERNEL32-OLE2NLS)
|
|---|
| 48 | #endif
|
|---|
| 49 |
|
|---|
| 50 | DEFAULT_DEBUG_CHANNEL(string);
|
|---|
| 51 |
|
|---|
| 52 | /* Locale name to id map. used by EnumSystemLocales, GetLocaleInfoA
|
|---|
| 53 | * MUST contain all #defines from winnls.h
|
|---|
| 54 | * last entry has NULL name, 0 id.
|
|---|
| 55 | */
|
|---|
| 56 | #define LOCALE_ENTRY(x) {#x,LOCALE_##x}
|
|---|
| 57 | static const struct tagLOCALE_NAME2ID {
|
|---|
| 58 | const char *name;
|
|---|
| 59 | LCTYPE id;
|
|---|
| 60 | } locale_name2id[]= {
|
|---|
| 61 | LOCALE_ENTRY(ILANGUAGE),
|
|---|
| 62 | LOCALE_ENTRY(SLANGUAGE),
|
|---|
| 63 | LOCALE_ENTRY(SENGLANGUAGE),
|
|---|
| 64 | LOCALE_ENTRY(SABBREVLANGNAME),
|
|---|
| 65 | LOCALE_ENTRY(SNATIVELANGNAME),
|
|---|
| 66 | LOCALE_ENTRY(ICOUNTRY),
|
|---|
| 67 | LOCALE_ENTRY(SCOUNTRY),
|
|---|
| 68 | LOCALE_ENTRY(SENGCOUNTRY),
|
|---|
| 69 | LOCALE_ENTRY(SABBREVCTRYNAME),
|
|---|
| 70 | LOCALE_ENTRY(SNATIVECTRYNAME),
|
|---|
| 71 | LOCALE_ENTRY(IDEFAULTLANGUAGE),
|
|---|
| 72 | LOCALE_ENTRY(IDEFAULTCOUNTRY),
|
|---|
| 73 | LOCALE_ENTRY(IDEFAULTCODEPAGE),
|
|---|
| 74 | LOCALE_ENTRY(IDEFAULTANSICODEPAGE),
|
|---|
| 75 | LOCALE_ENTRY(IDEFAULTMACCODEPAGE),
|
|---|
| 76 | LOCALE_ENTRY(SLIST),
|
|---|
| 77 | LOCALE_ENTRY(IMEASURE),
|
|---|
| 78 | LOCALE_ENTRY(SDECIMAL),
|
|---|
| 79 | LOCALE_ENTRY(STHOUSAND),
|
|---|
| 80 | LOCALE_ENTRY(SGROUPING),
|
|---|
| 81 | LOCALE_ENTRY(IDIGITS),
|
|---|
| 82 | LOCALE_ENTRY(ILZERO),
|
|---|
| 83 | LOCALE_ENTRY(INEGNUMBER),
|
|---|
| 84 | LOCALE_ENTRY(SNATIVEDIGITS),
|
|---|
| 85 | LOCALE_ENTRY(SCURRENCY),
|
|---|
| 86 | LOCALE_ENTRY(SINTLSYMBOL),
|
|---|
| 87 | LOCALE_ENTRY(SMONDECIMALSEP),
|
|---|
| 88 | LOCALE_ENTRY(SMONTHOUSANDSEP),
|
|---|
| 89 | LOCALE_ENTRY(SMONGROUPING),
|
|---|
| 90 | LOCALE_ENTRY(ICURRDIGITS),
|
|---|
| 91 | LOCALE_ENTRY(IINTLCURRDIGITS),
|
|---|
| 92 | LOCALE_ENTRY(ICURRENCY),
|
|---|
| 93 | LOCALE_ENTRY(INEGCURR),
|
|---|
| 94 | LOCALE_ENTRY(SDATE),
|
|---|
| 95 | LOCALE_ENTRY(STIME),
|
|---|
| 96 | LOCALE_ENTRY(SSHORTDATE),
|
|---|
| 97 | LOCALE_ENTRY(SLONGDATE),
|
|---|
| 98 | LOCALE_ENTRY(STIMEFORMAT),
|
|---|
| 99 | LOCALE_ENTRY(IDATE),
|
|---|
| 100 | LOCALE_ENTRY(ILDATE),
|
|---|
| 101 | LOCALE_ENTRY(ITIME),
|
|---|
| 102 | LOCALE_ENTRY(ITIMEMARKPOSN),
|
|---|
| 103 | LOCALE_ENTRY(ICENTURY),
|
|---|
| 104 | LOCALE_ENTRY(ITLZERO),
|
|---|
| 105 | LOCALE_ENTRY(IDAYLZERO),
|
|---|
| 106 | LOCALE_ENTRY(IMONLZERO),
|
|---|
| 107 | LOCALE_ENTRY(S1159),
|
|---|
| 108 | LOCALE_ENTRY(S2359),
|
|---|
| 109 | LOCALE_ENTRY(ICALENDARTYPE),
|
|---|
| 110 | LOCALE_ENTRY(IOPTIONALCALENDAR),
|
|---|
| 111 | LOCALE_ENTRY(IFIRSTDAYOFWEEK),
|
|---|
| 112 | LOCALE_ENTRY(IFIRSTWEEKOFYEAR),
|
|---|
| 113 | LOCALE_ENTRY(SDAYNAME1),
|
|---|
| 114 | LOCALE_ENTRY(SDAYNAME2),
|
|---|
| 115 | LOCALE_ENTRY(SDAYNAME3),
|
|---|
| 116 | LOCALE_ENTRY(SDAYNAME4),
|
|---|
| 117 | LOCALE_ENTRY(SDAYNAME5),
|
|---|
| 118 | LOCALE_ENTRY(SDAYNAME6),
|
|---|
| 119 | LOCALE_ENTRY(SDAYNAME7),
|
|---|
| 120 | LOCALE_ENTRY(SABBREVDAYNAME1),
|
|---|
| 121 | LOCALE_ENTRY(SABBREVDAYNAME2),
|
|---|
| 122 | LOCALE_ENTRY(SABBREVDAYNAME3),
|
|---|
| 123 | LOCALE_ENTRY(SABBREVDAYNAME4),
|
|---|
| 124 | LOCALE_ENTRY(SABBREVDAYNAME5),
|
|---|
| 125 | LOCALE_ENTRY(SABBREVDAYNAME6),
|
|---|
| 126 | LOCALE_ENTRY(SABBREVDAYNAME7),
|
|---|
| 127 | LOCALE_ENTRY(SMONTHNAME1),
|
|---|
| 128 | LOCALE_ENTRY(SMONTHNAME2),
|
|---|
| 129 | LOCALE_ENTRY(SMONTHNAME3),
|
|---|
| 130 | LOCALE_ENTRY(SMONTHNAME4),
|
|---|
| 131 | LOCALE_ENTRY(SMONTHNAME5),
|
|---|
| 132 | LOCALE_ENTRY(SMONTHNAME6),
|
|---|
| 133 | LOCALE_ENTRY(SMONTHNAME7),
|
|---|
| 134 | LOCALE_ENTRY(SMONTHNAME8),
|
|---|
| 135 | LOCALE_ENTRY(SMONTHNAME9),
|
|---|
| 136 | LOCALE_ENTRY(SMONTHNAME10),
|
|---|
| 137 | LOCALE_ENTRY(SMONTHNAME11),
|
|---|
| 138 | LOCALE_ENTRY(SMONTHNAME12),
|
|---|
| 139 | LOCALE_ENTRY(SMONTHNAME13),
|
|---|
| 140 | LOCALE_ENTRY(SABBREVMONTHNAME1),
|
|---|
| 141 | LOCALE_ENTRY(SABBREVMONTHNAME2),
|
|---|
| 142 | LOCALE_ENTRY(SABBREVMONTHNAME3),
|
|---|
| 143 | LOCALE_ENTRY(SABBREVMONTHNAME4),
|
|---|
| 144 | LOCALE_ENTRY(SABBREVMONTHNAME5),
|
|---|
| 145 | LOCALE_ENTRY(SABBREVMONTHNAME6),
|
|---|
| 146 | LOCALE_ENTRY(SABBREVMONTHNAME7),
|
|---|
| 147 | LOCALE_ENTRY(SABBREVMONTHNAME8),
|
|---|
| 148 | LOCALE_ENTRY(SABBREVMONTHNAME9),
|
|---|
| 149 | LOCALE_ENTRY(SABBREVMONTHNAME10),
|
|---|
| 150 | LOCALE_ENTRY(SABBREVMONTHNAME11),
|
|---|
| 151 | LOCALE_ENTRY(SABBREVMONTHNAME12),
|
|---|
| 152 | LOCALE_ENTRY(SABBREVMONTHNAME13),
|
|---|
| 153 | LOCALE_ENTRY(SPOSITIVESIGN),
|
|---|
| 154 | LOCALE_ENTRY(SNEGATIVESIGN),
|
|---|
| 155 | LOCALE_ENTRY(IPOSSIGNPOSN),
|
|---|
| 156 | LOCALE_ENTRY(INEGSIGNPOSN),
|
|---|
| 157 | LOCALE_ENTRY(IPOSSYMPRECEDES),
|
|---|
| 158 | LOCALE_ENTRY(IPOSSEPBYSPACE),
|
|---|
| 159 | LOCALE_ENTRY(INEGSYMPRECEDES),
|
|---|
| 160 | LOCALE_ENTRY(INEGSEPBYSPACE),
|
|---|
| 161 | LOCALE_ENTRY(FONTSIGNATURE),
|
|---|
| 162 | LOCALE_ENTRY(SISO639LANGNAME),
|
|---|
| 163 | LOCALE_ENTRY(SISO3166CTRYNAME),
|
|---|
| 164 | {NULL,0}
|
|---|
| 165 | };
|
|---|
| 166 |
|
|---|
| 167 | static char *GetLocaleSubkeyName( DWORD lctype );
|
|---|
| 168 |
|
|---|
| 169 | #ifndef __WIN32OS2__
|
|---|
| 170 | /***********************************************************************
|
|---|
| 171 | * GetUserDefaultLCID (KERNEL32.@)
|
|---|
| 172 | * GetUserDefaultLCID (OLE2NLS.1)
|
|---|
| 173 | */
|
|---|
| 174 | LCID WINAPI GetUserDefaultLCID(void)
|
|---|
| 175 | {
|
|---|
| 176 | return MAKELCID( GetUserDefaultLangID() , SORT_DEFAULT );
|
|---|
| 177 | }
|
|---|
| 178 |
|
|---|
| 179 | /***********************************************************************
|
|---|
| 180 | * GetSystemDefaultLCID (KERNEL32.@)
|
|---|
| 181 | * GetSystemDefaultLCID (OLE2NLS.2)
|
|---|
| 182 | */
|
|---|
| 183 | LCID WINAPI GetSystemDefaultLCID(void)
|
|---|
| 184 | {
|
|---|
| 185 | return GetUserDefaultLCID();
|
|---|
| 186 | }
|
|---|
| 187 | #endif //__WIN32OS2__
|
|---|
| 188 |
|
|---|
| 189 | #define NLS_MAX_LANGUAGES 20
|
|---|
| 190 | typedef struct {
|
|---|
| 191 | char lang[128];
|
|---|
| 192 | char country[128];
|
|---|
| 193 | LANGID found_lang_id[NLS_MAX_LANGUAGES];
|
|---|
| 194 | char found_language[NLS_MAX_LANGUAGES][3];
|
|---|
| 195 | char found_country[NLS_MAX_LANGUAGES][3];
|
|---|
| 196 | int n_found;
|
|---|
| 197 | } LANG_FIND_DATA;
|
|---|
| 198 |
|
|---|
| 199 | static BOOL CALLBACK NLS_FindLanguageID_ProcA(HMODULE hModule, LPCSTR type,
|
|---|
| 200 | LPCSTR name, WORD LangID, LONG lParam)
|
|---|
| 201 | {
|
|---|
| 202 | LANG_FIND_DATA *l_data = (LANG_FIND_DATA *)lParam;
|
|---|
| 203 | LCID lcid = MAKELCID(LangID, SORT_DEFAULT);
|
|---|
| 204 | char buf_language[128];
|
|---|
| 205 | char buf_country[128];
|
|---|
| 206 | char buf_en_language[128];
|
|---|
| 207 |
|
|---|
| 208 | TRACE("%04X\n", (UINT)LangID);
|
|---|
| 209 | if(PRIMARYLANGID(LangID) == LANG_NEUTRAL)
|
|---|
| 210 | return TRUE; /* continue search */
|
|---|
| 211 |
|
|---|
| 212 | buf_language[0] = 0;
|
|---|
| 213 | buf_country[0] = 0;
|
|---|
| 214 |
|
|---|
| 215 | GetLocaleInfoA(lcid, LOCALE_SISO639LANGNAME|LOCALE_NOUSEROVERRIDE,
|
|---|
| 216 | buf_language, sizeof(buf_language));
|
|---|
| 217 | TRACE("LOCALE_SISO639LANGNAME: %s\n", buf_language);
|
|---|
| 218 |
|
|---|
| 219 | GetLocaleInfoA(lcid, LOCALE_SISO3166CTRYNAME|LOCALE_NOUSEROVERRIDE,
|
|---|
| 220 | buf_country, sizeof(buf_country));
|
|---|
| 221 | TRACE("LOCALE_SISO3166CTRYNAME: %s\n", buf_country);
|
|---|
| 222 |
|
|---|
| 223 | if(l_data->lang && strlen(l_data->lang) > 0 && !strcasecmp(l_data->lang, buf_language))
|
|---|
| 224 | {
|
|---|
| 225 | if(l_data->country && strlen(l_data->country) > 0)
|
|---|
| 226 | {
|
|---|
| 227 | if(!strcasecmp(l_data->country, buf_country))
|
|---|
| 228 | {
|
|---|
| 229 | l_data->found_lang_id[0] = LangID;
|
|---|
| 230 | l_data->n_found = 1;
|
|---|
| 231 | TRACE("Found lang_id %04X for %s_%s\n", LangID, l_data->lang, l_data->country);
|
|---|
| 232 | return FALSE; /* stop enumeration */
|
|---|
| 233 | }
|
|---|
| 234 | }
|
|---|
| 235 | else /* l_data->country not specified */
|
|---|
| 236 | {
|
|---|
| 237 | if(l_data->n_found < NLS_MAX_LANGUAGES)
|
|---|
| 238 | {
|
|---|
| 239 | l_data->found_lang_id[l_data->n_found] = LangID;
|
|---|
| 240 | strncpy(l_data->found_country[l_data->n_found], buf_country, 3);
|
|---|
| 241 | strncpy(l_data->found_language[l_data->n_found], buf_language, 3);
|
|---|
| 242 | l_data->n_found++;
|
|---|
| 243 | TRACE("Found lang_id %04X for %s\n", LangID, l_data->lang);
|
|---|
| 244 | return TRUE; /* continue search */
|
|---|
| 245 | }
|
|---|
| 246 | }
|
|---|
| 247 | }
|
|---|
| 248 |
|
|---|
| 249 | /* Just in case, check LOCALE_SENGLANGUAGE too,
|
|---|
| 250 | * in hope that possible alias name might have that value.
|
|---|
| 251 | */
|
|---|
| 252 | buf_en_language[0] = 0;
|
|---|
| 253 | GetLocaleInfoA(lcid, LOCALE_SENGLANGUAGE|LOCALE_NOUSEROVERRIDE,
|
|---|
| 254 | buf_en_language, sizeof(buf_en_language));
|
|---|
| 255 | TRACE("LOCALE_SENGLANGUAGE: %s\n", buf_en_language);
|
|---|
| 256 |
|
|---|
| 257 | if(l_data->lang && strlen(l_data->lang) > 0 && !strcasecmp(l_data->lang, buf_en_language))
|
|---|
| 258 | {
|
|---|
| 259 | l_data->found_lang_id[l_data->n_found] = LangID;
|
|---|
| 260 | strncpy(l_data->found_country[l_data->n_found], buf_country, 3);
|
|---|
| 261 | strncpy(l_data->found_language[l_data->n_found], buf_language, 3);
|
|---|
| 262 | l_data->n_found++;
|
|---|
| 263 | TRACE("Found lang_id %04X for %s\n", LangID, l_data->lang);
|
|---|
| 264 | }
|
|---|
| 265 |
|
|---|
| 266 | return TRUE; /* continue search */
|
|---|
| 267 | }
|
|---|
| 268 |
|
|---|
| 269 | /***********************************************************************
|
|---|
| 270 | * NLS_GetLanguageID
|
|---|
| 271 | *
|
|---|
| 272 | * INPUT:
|
|---|
| 273 | * Lang: a string whose two first chars are the iso name of a language.
|
|---|
| 274 | * Country: a string whose two first chars are the iso name of country
|
|---|
| 275 | * Charset: a string defining the chossen charset encoding
|
|---|
| 276 | * Dialect: a string defining a variation of the locale
|
|---|
| 277 | *
|
|---|
| 278 | * all those values are from the standardized format of locale
|
|---|
| 279 | * name in unix which is: Lang[_Country][.Charset][@Dialect]
|
|---|
| 280 | *
|
|---|
| 281 | * RETURNS:
|
|---|
| 282 | * the numeric code of the language used by Windows
|
|---|
| 283 | *
|
|---|
| 284 | * FIXME: Charset and Dialect are not handled
|
|---|
| 285 | */
|
|---|
| 286 | static LANGID NLS_GetLanguageID(LPCSTR Lang, LPCSTR Country, LPCSTR Charset, LPCSTR Dialect)
|
|---|
| 287 | {
|
|---|
| 288 | LANG_FIND_DATA l_data;
|
|---|
| 289 | char lang_string[256];
|
|---|
| 290 |
|
|---|
| 291 | if(!Lang)
|
|---|
| 292 | {
|
|---|
| 293 | l_data.found_lang_id[0] = MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT);
|
|---|
| 294 | goto END;
|
|---|
| 295 | }
|
|---|
| 296 |
|
|---|
| 297 | memset(&l_data, 0, sizeof(LANG_FIND_DATA));
|
|---|
| 298 | strncpy(l_data.lang, Lang, sizeof(l_data.lang));
|
|---|
| 299 |
|
|---|
| 300 | if(Country && strlen(Country) > 0)
|
|---|
| 301 | strncpy(l_data.country, Country, sizeof(l_data.country));
|
|---|
| 302 |
|
|---|
| 303 | EnumResourceLanguagesA(GetModuleHandleA("KERNEL32"), RT_STRINGA,
|
|---|
| 304 | (LPCSTR)LOCALE_ILANGUAGE, NLS_FindLanguageID_ProcA, (LONG)&l_data);
|
|---|
| 305 |
|
|---|
| 306 | strcpy(lang_string, l_data.lang);
|
|---|
| 307 | if(l_data.country && strlen(l_data.country) > 0)
|
|---|
| 308 | {
|
|---|
| 309 | strcat(lang_string, "_");
|
|---|
| 310 | strcat(lang_string, l_data.country);
|
|---|
| 311 | }
|
|---|
| 312 |
|
|---|
| 313 | if(!l_data.n_found)
|
|---|
| 314 | {
|
|---|
| 315 | if(l_data.country && strlen(l_data.country) > 0)
|
|---|
| 316 | {
|
|---|
| 317 | MESSAGE("Warning: Language '%s' was not found, retrying without country name...\n", lang_string);
|
|---|
| 318 | l_data.country[0] = 0;
|
|---|
| 319 | EnumResourceLanguagesA(GetModuleHandleA("KERNEL32"), RT_STRINGA,
|
|---|
| 320 | (LPCSTR)LOCALE_ILANGUAGE, NLS_FindLanguageID_ProcA, (LONG)&l_data);
|
|---|
| 321 | }
|
|---|
| 322 | }
|
|---|
| 323 |
|
|---|
| 324 | /* Re-evaluate lang_string */
|
|---|
| 325 | strcpy(lang_string, l_data.lang);
|
|---|
| 326 | if(l_data.country && strlen(l_data.country) > 0)
|
|---|
| 327 | {
|
|---|
| 328 | strcat(lang_string, "_");
|
|---|
| 329 | strcat(lang_string, l_data.country);
|
|---|
| 330 | }
|
|---|
| 331 |
|
|---|
| 332 | if(!l_data.n_found)
|
|---|
| 333 | {
|
|---|
| 334 | MESSAGE("Warning: Language '%s' was not recognized, defaulting to English\n", lang_string);
|
|---|
| 335 | l_data.found_lang_id[0] = MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT);
|
|---|
| 336 | }
|
|---|
| 337 | else
|
|---|
| 338 | {
|
|---|
| 339 | if(l_data.n_found == 1)
|
|---|
| 340 | TRACE("For language '%s' lang_id %04X was found\n", lang_string, l_data.found_lang_id[0]);
|
|---|
| 341 | else /* l_data->n_found > 1 */
|
|---|
| 342 | {
|
|---|
| 343 | int i;
|
|---|
| 344 | MESSAGE("For language '%s' several language ids were found:\n", lang_string);
|
|---|
| 345 | for(i = 0; i < l_data.n_found; i++)
|
|---|
| 346 | MESSAGE("%s_%s - %04X; ", l_data.found_language[i], l_data.found_country[i], l_data.found_lang_id[i]);
|
|---|
| 347 |
|
|---|
| 348 | MESSAGE("\nInstead of using first in the list, suggest to define\n"
|
|---|
| 349 | "your LANG environment variable like this: LANG=%s_%s\n",
|
|---|
| 350 | l_data.found_language[0], l_data.found_country[0]);
|
|---|
| 351 | }
|
|---|
| 352 | }
|
|---|
| 353 | END:
|
|---|
| 354 | TRACE("Returning %04X\n", l_data.found_lang_id[0]);
|
|---|
| 355 | return l_data.found_lang_id[0];
|
|---|
| 356 | }
|
|---|
| 357 | #ifndef __WIN32OS2__
|
|---|
| 358 | /***********************************************************************
|
|---|
| 359 | * GetUserDefaultLangID (KERNEL32.@)
|
|---|
| 360 | * GetUserDefaultLangID (OLE2NLS.3)
|
|---|
| 361 | */
|
|---|
| 362 | LANGID WINAPI GetUserDefaultLangID(void)
|
|---|
| 363 | {
|
|---|
| 364 | /* caching result, if defined from environment, which should (?) not change during a WINE session */
|
|---|
| 365 | static LANGID userLCID = 0;
|
|---|
| 366 |
|
|---|
| 367 | if (userLCID == 0)
|
|---|
| 368 | {
|
|---|
| 369 | char buf[256];
|
|---|
| 370 | char *lang,*country,*charset,*dialect,*next;
|
|---|
| 371 |
|
|---|
| 372 | if (GetEnvironmentVariableA( "LANGUAGE", buf, sizeof(buf) )) goto ok;
|
|---|
| 373 | if (GetEnvironmentVariableA( "LANG", buf, sizeof(buf) )) goto ok;
|
|---|
| 374 | if (GetEnvironmentVariableA( "LC_ALL", buf, sizeof(buf) )) goto ok;
|
|---|
| 375 | if (GetEnvironmentVariableA( "LC_MESSAGES", buf, sizeof(buf) )) goto ok;
|
|---|
| 376 | if (GetEnvironmentVariableA( "LC_CTYPE", buf, sizeof(buf) )) goto ok;
|
|---|
| 377 |
|
|---|
| 378 | return userLCID = MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT );
|
|---|
| 379 |
|
|---|
| 380 | ok:
|
|---|
| 381 | if (!strcmp(buf,"POSIX") || !strcmp(buf,"C"))
|
|---|
| 382 | return userLCID = MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT );
|
|---|
| 383 |
|
|---|
| 384 | lang=buf;
|
|---|
| 385 |
|
|---|
| 386 | do {
|
|---|
| 387 | next=strchr(lang,':'); if (next) *next++='\0';
|
|---|
| 388 | dialect=strchr(lang,'@'); if (dialect) *dialect++='\0';
|
|---|
| 389 | charset=strchr(lang,'.'); if (charset) *charset++='\0';
|
|---|
| 390 | country=strchr(lang,'_'); if (country) *country++='\0';
|
|---|
| 391 |
|
|---|
| 392 | userLCID = NLS_GetLanguageID(lang, country, charset, dialect);
|
|---|
| 393 |
|
|---|
| 394 | lang=next;
|
|---|
| 395 | } while (lang && !userLCID);
|
|---|
| 396 |
|
|---|
| 397 | if (!userLCID)
|
|---|
| 398 | {
|
|---|
| 399 | MESSAGE( "Warning: language '%s' not recognized, defaulting to English\n",
|
|---|
| 400 | buf );
|
|---|
| 401 | userLCID = MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT );
|
|---|
| 402 | }
|
|---|
| 403 | }
|
|---|
| 404 | return userLCID;
|
|---|
| 405 | }
|
|---|
| 406 |
|
|---|
| 407 | /***********************************************************************
|
|---|
| 408 | * GetSystemDefaultLangID (KERNEL32.@)
|
|---|
| 409 | * GetSystemDefaultLangID (OLE2NLS.4)
|
|---|
| 410 | */
|
|---|
| 411 | LANGID WINAPI GetSystemDefaultLangID(void)
|
|---|
| 412 | {
|
|---|
| 413 | return GetUserDefaultLangID();
|
|---|
| 414 | }
|
|---|
| 415 | #endif //__WIN32OS2__
|
|---|
| 416 | /******************************************************************************
|
|---|
| 417 | * ConvertDefaultLocale (KERNEL32.@)
|
|---|
| 418 | */
|
|---|
| 419 | LCID WINAPI ConvertDefaultLocale (LCID lcid)
|
|---|
| 420 | { switch (lcid)
|
|---|
| 421 | { case LOCALE_SYSTEM_DEFAULT:
|
|---|
| 422 | return GetSystemDefaultLCID();
|
|---|
| 423 | case LOCALE_USER_DEFAULT:
|
|---|
| 424 | return GetUserDefaultLCID();
|
|---|
| 425 | case LOCALE_NEUTRAL:
|
|---|
| 426 | return MAKELCID (LANG_NEUTRAL, SUBLANG_NEUTRAL);
|
|---|
| 427 | }
|
|---|
| 428 | return MAKELANGID( PRIMARYLANGID(lcid), SUBLANG_NEUTRAL);
|
|---|
| 429 | }
|
|---|
| 430 |
|
|---|
| 431 | /* Enhanced version of LoadStringW.
|
|---|
| 432 | * It takes LanguageId to find and load language dependant resources.
|
|---|
| 433 | * Resource is copied as is: "binary" strings are not truncated.
|
|---|
| 434 | * Return: length of resource + 1 to distinguish absent resources
|
|---|
| 435 | * from the resources with zero length.
|
|---|
| 436 | */
|
|---|
| 437 | static INT NLS_LoadStringExW(HMODULE hModule, LANGID lang_id, UINT res_id, LPWSTR buffer, INT buflen)
|
|---|
| 438 | {
|
|---|
| 439 | HRSRC hrsrc;
|
|---|
| 440 | HGLOBAL hmem;
|
|---|
| 441 | WCHAR *p;
|
|---|
| 442 | int string_num;
|
|---|
| 443 | int i;
|
|---|
| 444 |
|
|---|
| 445 | hrsrc = FindResourceExW(hModule, RT_STRINGW, (LPCWSTR)((res_id >> 4) + 1), lang_id);
|
|---|
| 446 |
|
|---|
| 447 | if(!hrsrc) return 0;
|
|---|
| 448 | hmem = LoadResource(hModule, hrsrc);
|
|---|
| 449 | if(!hmem) return 0;
|
|---|
| 450 |
|
|---|
| 451 | #ifdef __WIN32OS2__
|
|---|
| 452 | p = (WCHAR*)LockResource(hmem);
|
|---|
| 453 | #else
|
|---|
| 454 | p = LockResource(hmem);
|
|---|
| 455 | #endif
|
|---|
| 456 | string_num = res_id & 0x000f;
|
|---|
| 457 | for(i = 0; i < string_num; i++)
|
|---|
| 458 | p += *p + 1;
|
|---|
| 459 |
|
|---|
| 460 | TRACE("strlen = %d\n", (int)*p );
|
|---|
| 461 |
|
|---|
| 462 | if (buffer == NULL) return *p;
|
|---|
| 463 | i = min(buflen - 1, *p);
|
|---|
| 464 | if (i > 0) {
|
|---|
| 465 | memcpy(buffer, p + 1, i * sizeof (WCHAR));
|
|---|
| 466 | buffer[i] = (WCHAR) 0;
|
|---|
| 467 | } else {
|
|---|
| 468 | if (buflen > 1)
|
|---|
| 469 | buffer[0] = (WCHAR) 0;
|
|---|
| 470 | }
|
|---|
| 471 |
|
|---|
| 472 | FreeResource(hmem);
|
|---|
| 473 | TRACE("%s loaded!\n", debugstr_w(buffer));
|
|---|
| 474 | return (i + 1);
|
|---|
| 475 | }
|
|---|
| 476 | #ifndef __WIN32OS2__
|
|---|
| 477 | /******************************************************************************
|
|---|
| 478 | * GetLocaleInfoA (KERNEL32.@)
|
|---|
| 479 | *
|
|---|
| 480 | * NOTES
|
|---|
| 481 | * LANG_NEUTRAL is equal to LOCALE_SYSTEM_DEFAULT
|
|---|
| 482 | *
|
|---|
| 483 | * MS online documentation states that the string returned is NULL terminated
|
|---|
| 484 | * except for LOCALE_FONTSIGNATURE which "will return a non-NULL
|
|---|
| 485 | * terminated string".
|
|---|
| 486 | */
|
|---|
| 487 | INT WINAPI GetLocaleInfoA(LCID lcid,LCTYPE LCType,LPSTR buf,INT len)
|
|---|
| 488 | {
|
|---|
| 489 | LPCSTR retString = NULL;
|
|---|
| 490 | int found = 0, i;
|
|---|
| 491 | char *pacKey;
|
|---|
| 492 | char acBuffer[128];
|
|---|
| 493 | DWORD dwBufferSize=128;
|
|---|
| 494 | BOOL NoUserOverride;
|
|---|
| 495 |
|
|---|
| 496 | TRACE("(lcid=0x%lx,lctype=0x%lx,%p,%x)\n",lcid,LCType,buf,len);
|
|---|
| 497 |
|
|---|
| 498 | if (len && (! buf) ) {
|
|---|
| 499 | SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|---|
| 500 | return 0;
|
|---|
| 501 | }
|
|---|
| 502 |
|
|---|
| 503 | if (lcid == LOCALE_NEUTRAL || lcid == LANG_SYSTEM_DEFAULT)
|
|---|
| 504 | {
|
|---|
| 505 | lcid = GetSystemDefaultLCID();
|
|---|
| 506 | }
|
|---|
| 507 | else if (lcid == LANG_USER_DEFAULT) /*0x800*/
|
|---|
| 508 | {
|
|---|
| 509 | lcid = GetUserDefaultLCID();
|
|---|
| 510 | }
|
|---|
| 511 |
|
|---|
| 512 | /* LOCALE_NOUSEROVERRIDE means: do not get user redefined settings
|
|---|
| 513 | from the registry. Instead, use system default values. */
|
|---|
| 514 | NoUserOverride = (LCType & LOCALE_NOUSEROVERRIDE) != 0;
|
|---|
| 515 |
|
|---|
| 516 | LCType &= ~(LOCALE_NOUSEROVERRIDE|LOCALE_USE_CP_ACP);
|
|---|
| 517 |
|
|---|
| 518 | /* First, check if it's in the registry. */
|
|---|
| 519 | /* All user customized values are stored in the registry by SetLocaleInfo */
|
|---|
| 520 | if ( !NoUserOverride && (pacKey = GetLocaleSubkeyName(LCType)) )
|
|---|
| 521 | {
|
|---|
| 522 | char acRealKey[128];
|
|---|
| 523 | HKEY hKey;
|
|---|
| 524 |
|
|---|
| 525 | sprintf( acRealKey, "Control Panel\\International\\%s", pacKey );
|
|---|
| 526 |
|
|---|
| 527 | if ( RegOpenKeyExA( HKEY_CURRENT_USER, acRealKey,
|
|---|
| 528 | 0, KEY_READ, &hKey) == ERROR_SUCCESS )
|
|---|
| 529 | {
|
|---|
| 530 | if ( RegQueryValueExA( hKey, NULL, NULL, NULL, (LPBYTE)acBuffer,
|
|---|
| 531 | &dwBufferSize ) == ERROR_SUCCESS )
|
|---|
| 532 | {
|
|---|
| 533 | retString = acBuffer;
|
|---|
| 534 | found = 1;
|
|---|
| 535 | }
|
|---|
| 536 | RegCloseKey(hKey);
|
|---|
| 537 | }
|
|---|
| 538 | }
|
|---|
| 539 |
|
|---|
| 540 | /* If not in the registry, get it from the NLS entries. */
|
|---|
| 541 | if(!found) {
|
|---|
| 542 | WCHAR wcBuffer[128];
|
|---|
| 543 | int res_size;
|
|---|
| 544 |
|
|---|
| 545 | /* check if language is registered in the kernel32 resources */
|
|---|
| 546 | if((res_size = NLS_LoadStringExW(GetModuleHandleA("KERNEL32"), LANGIDFROMLCID(lcid),
|
|---|
| 547 | LCType, wcBuffer, sizeof(wcBuffer)/sizeof(wcBuffer[0])))) {
|
|---|
| 548 | WideCharToMultiByte(CP_ACP, 0, wcBuffer, res_size, acBuffer, dwBufferSize, NULL, NULL);
|
|---|
| 549 | retString = acBuffer;
|
|---|
| 550 | found = 1;
|
|---|
| 551 | }
|
|---|
| 552 | }
|
|---|
| 553 |
|
|---|
| 554 | /* if not found report a most descriptive error */
|
|---|
| 555 | if(!found) {
|
|---|
| 556 | retString=0;
|
|---|
| 557 | /* If we are through all of this, retLen should not be zero anymore.
|
|---|
| 558 | If it is, the value is not supported */
|
|---|
| 559 | i=0;
|
|---|
| 560 | while (locale_name2id[i].name!=NULL) {
|
|---|
| 561 | if (LCType == locale_name2id[i].id) {
|
|---|
| 562 | retString = locale_name2id[i].name;
|
|---|
| 563 | break;
|
|---|
| 564 | }
|
|---|
| 565 | i++;
|
|---|
| 566 | }
|
|---|
| 567 | if(!retString)
|
|---|
| 568 | FIXME("Unkown LC type %lX\n", LCType);
|
|---|
| 569 | else
|
|---|
| 570 | FIXME("'%s' is not defined for your language (%04X).\n"
|
|---|
| 571 | "Please define it in dlls/kernel/nls/YourLanguage.nls\n"
|
|---|
| 572 | "and submit patch for inclusion into the next Wine release.\n",
|
|---|
| 573 | retString, LOWORD(lcid));
|
|---|
| 574 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 575 | return 0;
|
|---|
| 576 | }
|
|---|
| 577 |
|
|---|
| 578 | /* a FONTSIGNATURE is not a string, just 6 DWORDs */
|
|---|
| 579 | if (LCType == LOCALE_FONTSIGNATURE) {
|
|---|
| 580 | if (len) {
|
|---|
| 581 | len = (len < sizeof(FONTSIGNATURE)) ? len : sizeof(FONTSIGNATURE);
|
|---|
| 582 | memcpy(buf, retString, len);
|
|---|
| 583 | return len;
|
|---|
| 584 | }
|
|---|
| 585 | return sizeof(FONTSIGNATURE);
|
|---|
| 586 | }
|
|---|
| 587 | /* if len=0 return only the length, don't touch the buffer*/
|
|---|
| 588 | if (len) {
|
|---|
| 589 | lstrcpynA(buf,retString,len);
|
|---|
| 590 | return strlen(buf) + 1;
|
|---|
| 591 | }
|
|---|
| 592 | return strlen(retString)+1;
|
|---|
| 593 | }
|
|---|
| 594 |
|
|---|
| 595 | /******************************************************************************
|
|---|
| 596 | * GetLocaleInfoW (KERNEL32.@)
|
|---|
| 597 | *
|
|---|
| 598 | * NOTES
|
|---|
| 599 | * MS documentation states that len "specifies the size, in bytes (ANSI version)
|
|---|
| 600 | * or characters (Unicode version), of" wbuf. Thus the number returned is
|
|---|
| 601 | * the same between GetLocaleInfoW and GetLocaleInfoA.
|
|---|
| 602 | */
|
|---|
| 603 | INT WINAPI GetLocaleInfoW(LCID lcid,LCTYPE LCType,LPWSTR wbuf,INT len)
|
|---|
| 604 | { WORD wlen;
|
|---|
| 605 | LPSTR abuf;
|
|---|
| 606 |
|
|---|
| 607 | if (len && (! wbuf) )
|
|---|
| 608 | { SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|---|
| 609 | return 0;
|
|---|
| 610 | }
|
|---|
| 611 |
|
|---|
| 612 | abuf = (LPSTR)HeapAlloc(GetProcessHeap(),0,len);
|
|---|
| 613 | wlen = GetLocaleInfoA(lcid, LCType, abuf, len);
|
|---|
| 614 |
|
|---|
| 615 | if (wlen && len) /* if len=0 return only the length*/
|
|---|
| 616 | MultiByteToWideChar( CP_ACP, 0, abuf, -1, wbuf, len );
|
|---|
| 617 |
|
|---|
| 618 | HeapFree(GetProcessHeap(),0,abuf);
|
|---|
| 619 | return wlen;
|
|---|
| 620 | }
|
|---|
| 621 | #endif //__WIN32OS2__
|
|---|
| 622 |
|
|---|
| 623 | /******************************************************************************
|
|---|
| 624 | *
|
|---|
| 625 | * GetLocaleSubkeyName [helper function]
|
|---|
| 626 | *
|
|---|
| 627 | * - For use with the registry.
|
|---|
| 628 | * - Gets the registry subkey name for a given lctype.
|
|---|
| 629 | */
|
|---|
| 630 | static char *GetLocaleSubkeyName( DWORD lctype )
|
|---|
| 631 | {
|
|---|
| 632 | char *pacKey=NULL;
|
|---|
| 633 |
|
|---|
| 634 | switch ( lctype )
|
|---|
| 635 | {
|
|---|
| 636 | /* These values are used by SetLocaleInfo and GetLocaleInfo, and
|
|---|
| 637 | * the values are stored in the registry, confirmed under Windows,
|
|---|
| 638 | * for the ones that actually assign pacKey. Cases that aren't finished
|
|---|
| 639 | * have not been confirmed, so that must be done before they can be
|
|---|
| 640 | * added.
|
|---|
| 641 | */
|
|---|
| 642 | case LOCALE_SDATE : /* The date separator. */
|
|---|
| 643 | pacKey = "sDate";
|
|---|
| 644 | break;
|
|---|
| 645 | case LOCALE_ICURRDIGITS:
|
|---|
| 646 | pacKey = "iCurrDigits";
|
|---|
| 647 | break;
|
|---|
| 648 | case LOCALE_SDECIMAL :
|
|---|
| 649 | pacKey = "sDecimal";
|
|---|
| 650 | break;
|
|---|
| 651 | case LOCALE_ICURRENCY:
|
|---|
| 652 | pacKey = "iCurrency";
|
|---|
| 653 | break;
|
|---|
| 654 | case LOCALE_SGROUPING :
|
|---|
| 655 | pacKey = "sGrouping";
|
|---|
| 656 | break;
|
|---|
| 657 | case LOCALE_IDIGITS:
|
|---|
| 658 | pacKey = "iDigits";
|
|---|
| 659 | break;
|
|---|
| 660 | case LOCALE_SLIST :
|
|---|
| 661 | pacKey = "sList";
|
|---|
| 662 | break;
|
|---|
| 663 | /* case LOCALE_ICALENDARTYPE: */
|
|---|
| 664 | /* case LOCALE_IFIRSTDAYOFWEEK: */
|
|---|
| 665 | #ifdef __WIN32OS2__
|
|---|
| 666 | case LOCALE_IFIRSTDAYOFWEEK:
|
|---|
| 667 | pacKey = "iFirstDayOfWeek";
|
|---|
| 668 | break;
|
|---|
| 669 | #endif
|
|---|
| 670 | /* case LOCALE_IFIRSTWEEKOFYEAR: */
|
|---|
| 671 | /* case LOCALE_SYEARMONTH : */
|
|---|
| 672 | /* case LOCALE_SPOSITIVESIGN : */
|
|---|
| 673 | /* case LOCALE_IPAPERSIZE: */
|
|---|
| 674 | /* break; */
|
|---|
| 675 | case LOCALE_SLONGDATE :
|
|---|
| 676 | pacKey = "sLongDate";
|
|---|
| 677 | break;
|
|---|
| 678 | case LOCALE_SMONDECIMALSEP :
|
|---|
| 679 | pacKey = "sMonDecimalSep";
|
|---|
| 680 | break;
|
|---|
| 681 | case LOCALE_SMONGROUPING:
|
|---|
| 682 | pacKey = "sMonGrouping";
|
|---|
| 683 | break;
|
|---|
| 684 | case LOCALE_IMEASURE:
|
|---|
| 685 | pacKey = "iMeasure";
|
|---|
| 686 | break;
|
|---|
| 687 | case LOCALE_SMONTHOUSANDSEP :
|
|---|
| 688 | pacKey = "sMonThousandSep";
|
|---|
| 689 | break;
|
|---|
| 690 | case LOCALE_INEGCURR:
|
|---|
| 691 | pacKey = "iNegCurr";
|
|---|
| 692 | break;
|
|---|
| 693 | case LOCALE_SNEGATIVESIGN :
|
|---|
| 694 | pacKey = "sNegativeSign";
|
|---|
| 695 | break;
|
|---|
| 696 | case LOCALE_INEGNUMBER:
|
|---|
| 697 | pacKey = "iNegNumber";
|
|---|
| 698 | break;
|
|---|
| 699 | case LOCALE_SSHORTDATE :
|
|---|
| 700 | pacKey = "sShortDate";
|
|---|
| 701 | break;
|
|---|
| 702 | case LOCALE_ILDATE: /* Long Date format ordering specifier. */
|
|---|
| 703 | pacKey = "iLDate";
|
|---|
| 704 | break;
|
|---|
| 705 | case LOCALE_ILZERO:
|
|---|
| 706 | pacKey = "iLZero";
|
|---|
| 707 | break;
|
|---|
| 708 | case LOCALE_ITLZERO:
|
|---|
| 709 | pacKey = "iTLZero";
|
|---|
| 710 | break;
|
|---|
| 711 | case LOCALE_ITIME: /* Time format specifier. */
|
|---|
| 712 | pacKey = "iTime";
|
|---|
| 713 | break;
|
|---|
| 714 | case LOCALE_STHOUSAND :
|
|---|
| 715 | pacKey = "sThousand";
|
|---|
| 716 | break;
|
|---|
| 717 | case LOCALE_S1159: /* AM */
|
|---|
| 718 | pacKey = "s1159";
|
|---|
| 719 | break;
|
|---|
| 720 | case LOCALE_STIME:
|
|---|
| 721 | pacKey = "sTime";
|
|---|
| 722 | break;
|
|---|
| 723 | case LOCALE_S2359: /* PM */
|
|---|
| 724 | pacKey = "s2359";
|
|---|
| 725 | break;
|
|---|
| 726 | case LOCALE_STIMEFORMAT :
|
|---|
| 727 | pacKey = "sTimeFormat";
|
|---|
| 728 | break;
|
|---|
| 729 | case LOCALE_SCURRENCY:
|
|---|
| 730 | pacKey = "sCurrency";
|
|---|
| 731 | break;
|
|---|
| 732 |
|
|---|
| 733 | /* The following are not listed under MSDN as supported,
|
|---|
| 734 | * but seem to be used and also stored in the registry.
|
|---|
| 735 | */
|
|---|
| 736 |
|
|---|
| 737 | case LOCALE_IDATE:
|
|---|
| 738 | pacKey = "iDate";
|
|---|
| 739 | break;
|
|---|
| 740 | case LOCALE_SCOUNTRY:
|
|---|
| 741 | pacKey = "sCountry";
|
|---|
| 742 | break;
|
|---|
| 743 | case LOCALE_ICOUNTRY:
|
|---|
| 744 | pacKey = "iCountry";
|
|---|
| 745 | break;
|
|---|
| 746 | case LOCALE_SLANGUAGE:
|
|---|
| 747 | pacKey = "sLanguage";
|
|---|
| 748 | break;
|
|---|
| 749 |
|
|---|
| 750 | default:
|
|---|
| 751 | break;
|
|---|
| 752 | }
|
|---|
| 753 |
|
|---|
| 754 | return( pacKey );
|
|---|
| 755 | }
|
|---|
| 756 |
|
|---|
| 757 | /******************************************************************************
|
|---|
| 758 | * SetLocaleInfoA [KERNEL32.656]
|
|---|
| 759 | */
|
|---|
| 760 | BOOL WINAPI SetLocaleInfoA(DWORD lcid, DWORD lctype, LPCSTR data)
|
|---|
| 761 | {
|
|---|
| 762 | HKEY hKey;
|
|---|
| 763 | char *pacKey;
|
|---|
| 764 | char acRealKey[128];
|
|---|
| 765 |
|
|---|
| 766 | if ( (pacKey = GetLocaleSubkeyName(lctype)) )
|
|---|
| 767 | {
|
|---|
| 768 | sprintf( acRealKey, "Control Panel\\International\\%s", pacKey );
|
|---|
| 769 | if ( RegCreateKeyA( HKEY_CURRENT_USER, acRealKey,
|
|---|
| 770 | &hKey ) == ERROR_SUCCESS )
|
|---|
| 771 | {
|
|---|
| 772 | if ( RegSetValueExA( hKey, NULL, 0, REG_SZ,
|
|---|
| 773 | #ifdef __WIN32OS2__
|
|---|
| 774 | (LPBYTE)data, strlen(data)+1 ) != ERROR_SUCCESS )
|
|---|
| 775 | #else
|
|---|
| 776 | data, strlen(data)+1 ) != ERROR_SUCCESS )
|
|---|
| 777 | #endif
|
|---|
| 778 | {
|
|---|
| 779 | ERR("SetLocaleInfoA: %s did not work\n", pacKey );
|
|---|
| 780 | }
|
|---|
| 781 | RegCloseKey( hKey );
|
|---|
| 782 | }
|
|---|
| 783 | }
|
|---|
| 784 | else
|
|---|
| 785 | {
|
|---|
| 786 | FIXME("(%ld,%ld,%s): stub\n",lcid,lctype,data);
|
|---|
| 787 | }
|
|---|
| 788 | return TRUE;
|
|---|
| 789 | }
|
|---|
| 790 |
|
|---|
| 791 | #ifdef __WIN32OS2__
|
|---|
| 792 | /*****************************************************************************
|
|---|
| 793 | * Name : BOOL SetLocaleInfoW
|
|---|
| 794 | * Purpose : The SetLocaleInfoW function sets an item of locale information.
|
|---|
| 795 | * It does so by making an entry in the process portion of the
|
|---|
| 796 | * locale table. This setting only affects the user override portion
|
|---|
| 797 | * of the locale settings; it does not set the system defaults.
|
|---|
| 798 | * Only certain types of locale information, or LCTYPE values, can
|
|---|
| 799 | * be set by this function. See the following Remarks section for a
|
|---|
| 800 | * list of valid LCTYPE values.
|
|---|
| 801 | * The locale information is always passed in as a null-terminated
|
|---|
| 802 | * Unicode string in the Unicode (W) version of the function, and as
|
|---|
| 803 | * a null-terminated ANSI string in the ANSI (A) version. No integers
|
|---|
| 804 | * are allowed by this function; any numeric values must be specified
|
|---|
| 805 | * as Unicode or ANSI text. Each LCTYPE has a particular format, as
|
|---|
| 806 | * noted in Locale Identifiers.
|
|---|
| 807 | * Parameters: LCID Locale locale identifier
|
|---|
| 808 | * LCTYPE LCType type of information to set
|
|---|
| 809 | * LPCTSTR lpLCData pointer to information to set
|
|---|
| 810 | * Variables :
|
|---|
| 811 | * Result : TRUE / FALSE
|
|---|
| 812 | * Remark :
|
|---|
| 813 | * Status : UNTESTED STUB
|
|---|
| 814 | *
|
|---|
| 815 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
|---|
| 816 | *****************************************************************************/
|
|---|
| 817 |
|
|---|
| 818 | BOOL WIN32API SetLocaleInfoW(LCID Locale,
|
|---|
| 819 | LCTYPE LCType,
|
|---|
| 820 | LPCWSTR lpLCData)
|
|---|
| 821 | {
|
|---|
| 822 | dprintf(("KERNEL32: SetLocaleInfoW(%08xh,%08xh,%08xh) not implemented.\n",
|
|---|
| 823 | Locale,
|
|---|
| 824 | LCType,
|
|---|
| 825 | lpLCData));
|
|---|
| 826 |
|
|---|
| 827 | return (FALSE);
|
|---|
| 828 | }
|
|---|
| 829 | #endif
|
|---|
| 830 |
|
|---|
| 831 | /******************************************************************************
|
|---|
| 832 | * IsValidLocale [KERNEL32.489]
|
|---|
| 833 | */
|
|---|
| 834 | BOOL WINAPI IsValidLocale(LCID lcid,DWORD flags)
|
|---|
| 835 | {
|
|---|
| 836 | #ifdef __WIN32OS2__
|
|---|
| 837 | //SvL/MN: code below doesn't work -> winhlp32 complains about different language helpfiles
|
|---|
| 838 | dprintf(("KERNEL32: IsValidLocale, always returns TRUE\n"));
|
|---|
| 839 | return TRUE;
|
|---|
| 840 | #else
|
|---|
| 841 | /* check if language is registered in the kernel32 resources */
|
|---|
| 842 | if(!FindResourceExW(GetModuleHandleA("KERNEL32"), RT_STRINGW, (LPCWSTR)LOCALE_ILANGUAGE, LOWORD(lcid)))
|
|---|
| 843 | return FALSE;
|
|---|
| 844 | else
|
|---|
| 845 | return TRUE;
|
|---|
| 846 | #endif
|
|---|
| 847 | }
|
|---|
| 848 |
|
|---|
| 849 | static BOOL CALLBACK EnumResourceLanguagesProcW(HMODULE hModule, LPCWSTR type,
|
|---|
| 850 | LPCWSTR name, WORD LangID, LONG lParam)
|
|---|
| 851 | {
|
|---|
| 852 | CHAR bufA[20];
|
|---|
| 853 | WCHAR bufW[20];
|
|---|
| 854 | LOCALE_ENUMPROCW lpfnLocaleEnum = (LOCALE_ENUMPROCW)lParam;
|
|---|
| 855 | sprintf(bufA, "%08X", (UINT)LangID);
|
|---|
| 856 | MultiByteToWideChar(CP_ACP, 0, bufA, -1, bufW, sizeof(bufW)/sizeof(bufW[0]));
|
|---|
| 857 | return lpfnLocaleEnum(bufW);
|
|---|
| 858 | }
|
|---|
| 859 |
|
|---|
| 860 | /******************************************************************************
|
|---|
| 861 | * EnumSystemLocalesW [KERNEL32.209]
|
|---|
| 862 | */
|
|---|
| 863 | BOOL WINAPI EnumSystemLocalesW( LOCALE_ENUMPROCW lpfnLocaleEnum,
|
|---|
| 864 | DWORD flags )
|
|---|
| 865 | {
|
|---|
| 866 | TRACE("(%p,%08lx)\n", lpfnLocaleEnum,flags);
|
|---|
| 867 |
|
|---|
| 868 | EnumResourceLanguagesW(GetModuleHandleA("KERNEL32"), RT_STRINGW,
|
|---|
| 869 | (LPCWSTR)LOCALE_ILANGUAGE, EnumResourceLanguagesProcW,
|
|---|
| 870 | (LONG)lpfnLocaleEnum);
|
|---|
| 871 |
|
|---|
| 872 | return TRUE;
|
|---|
| 873 | }
|
|---|
| 874 |
|
|---|
| 875 | static BOOL CALLBACK EnumResourceLanguagesProcA(HMODULE hModule, LPCSTR type,
|
|---|
| 876 | LPCSTR name, WORD LangID, LONG lParam)
|
|---|
| 877 | {
|
|---|
| 878 | CHAR bufA[20];
|
|---|
| 879 | LOCALE_ENUMPROCA lpfnLocaleEnum = (LOCALE_ENUMPROCA)lParam;
|
|---|
| 880 | sprintf(bufA, "%08X", (UINT)LangID);
|
|---|
| 881 | return lpfnLocaleEnum(bufA);
|
|---|
| 882 | }
|
|---|
| 883 |
|
|---|
| 884 | /******************************************************************************
|
|---|
| 885 | * EnumSystemLocalesA [KERNEL32.208]
|
|---|
| 886 | */
|
|---|
| 887 | BOOL WINAPI EnumSystemLocalesA(LOCALE_ENUMPROCA lpfnLocaleEnum,
|
|---|
| 888 | DWORD flags)
|
|---|
| 889 | {
|
|---|
| 890 | TRACE("(%p,%08lx)\n", lpfnLocaleEnum,flags);
|
|---|
| 891 |
|
|---|
| 892 | EnumResourceLanguagesA(GetModuleHandleA("KERNEL32"), RT_STRINGA,
|
|---|
| 893 | (LPCSTR)LOCALE_ILANGUAGE, EnumResourceLanguagesProcA,
|
|---|
| 894 | (LONG)lpfnLocaleEnum);
|
|---|
| 895 |
|
|---|
| 896 | return TRUE;
|
|---|
| 897 | }
|
|---|
| 898 |
|
|---|
| 899 | static const unsigned char CT_CType2_LUT[] = {
|
|---|
| 900 | C2_NOTAPPLICABLE, /* - 0 */
|
|---|
| 901 | C2_NOTAPPLICABLE, /* - 1 */
|
|---|
| 902 | C2_NOTAPPLICABLE, /* - 2 */
|
|---|
| 903 | C2_NOTAPPLICABLE, /* - 3 */
|
|---|
| 904 | C2_NOTAPPLICABLE, /* - 4 */
|
|---|
| 905 | C2_NOTAPPLICABLE, /* - 5 */
|
|---|
| 906 | C2_NOTAPPLICABLE, /* - 6 */
|
|---|
| 907 | C2_NOTAPPLICABLE, /* - 7 */
|
|---|
| 908 | C2_NOTAPPLICABLE, /* - 8 */
|
|---|
| 909 | C2_SEGMENTSEPARATOR, /* - 9 */
|
|---|
| 910 | C2_NOTAPPLICABLE, /* - 10 */
|
|---|
| 911 | C2_NOTAPPLICABLE, /* - 11 */
|
|---|
| 912 | C2_NOTAPPLICABLE, /* - 12 */
|
|---|
| 913 | C2_NOTAPPLICABLE, /* - 13 */
|
|---|
| 914 | C2_NOTAPPLICABLE, /* - 14 */
|
|---|
| 915 | C2_NOTAPPLICABLE, /* - 15 */
|
|---|
| 916 | C2_NOTAPPLICABLE, /* - 16 */
|
|---|
| 917 | C2_NOTAPPLICABLE, /* - 17 */
|
|---|
| 918 | C2_NOTAPPLICABLE, /* - 18 */
|
|---|
| 919 | C2_NOTAPPLICABLE, /* - 19 */
|
|---|
| 920 | C2_NOTAPPLICABLE, /* - 20 */
|
|---|
| 921 | C2_NOTAPPLICABLE, /* - 21 */
|
|---|
| 922 | C2_NOTAPPLICABLE, /* - 22 */
|
|---|
| 923 | C2_NOTAPPLICABLE, /* - 23 */
|
|---|
| 924 | C2_NOTAPPLICABLE, /* - 24 */
|
|---|
| 925 | C2_NOTAPPLICABLE, /* - 25 */
|
|---|
| 926 | C2_NOTAPPLICABLE, /* - 26 */
|
|---|
| 927 | C2_NOTAPPLICABLE, /* - 27 */
|
|---|
| 928 | C2_NOTAPPLICABLE, /* - 28 */
|
|---|
| 929 | C2_NOTAPPLICABLE, /* - 29 */
|
|---|
| 930 | C2_NOTAPPLICABLE, /* - 30 */
|
|---|
| 931 | C2_NOTAPPLICABLE, /* - 31 */
|
|---|
| 932 | C2_WHITESPACE, /* - 32 */
|
|---|
| 933 | C2_OTHERNEUTRAL, /* ! - 33 */
|
|---|
| 934 | C2_OTHERNEUTRAL, /* " - 34 */ /* " */
|
|---|
| 935 | C2_EUROPETERMINATOR, /* # - 35 */
|
|---|
| 936 | C2_EUROPETERMINATOR, /* $ - 36 */
|
|---|
| 937 | C2_EUROPETERMINATOR, /* % - 37 */
|
|---|
| 938 | C2_LEFTTORIGHT, /* & - 38 */
|
|---|
| 939 | C2_OTHERNEUTRAL, /* ' - 39 */
|
|---|
| 940 | C2_OTHERNEUTRAL, /* ( - 40 */
|
|---|
| 941 | C2_OTHERNEUTRAL, /* ) - 41 */
|
|---|
| 942 | C2_OTHERNEUTRAL, /* * - 42 */
|
|---|
| 943 | C2_EUROPETERMINATOR, /* + - 43 */
|
|---|
| 944 | C2_COMMONSEPARATOR, /* , - 44 */
|
|---|
| 945 | C2_EUROPETERMINATOR, /* - - 45 */
|
|---|
| 946 | C2_EUROPESEPARATOR, /* . - 46 */
|
|---|
| 947 | C2_EUROPESEPARATOR, /* / - 47 */
|
|---|
| 948 | C2_EUROPENUMBER, /* 0 - 48 */
|
|---|
| 949 | C2_EUROPENUMBER, /* 1 - 49 */
|
|---|
| 950 | C2_EUROPENUMBER, /* 2 - 50 */
|
|---|
| 951 | C2_EUROPENUMBER, /* 3 - 51 */
|
|---|
| 952 | C2_EUROPENUMBER, /* 4 - 52 */
|
|---|
| 953 | C2_EUROPENUMBER, /* 5 - 53 */
|
|---|
| 954 | C2_EUROPENUMBER, /* 6 - 54 */
|
|---|
| 955 | C2_EUROPENUMBER, /* 7 - 55 */
|
|---|
| 956 | C2_EUROPENUMBER, /* 8 - 56 */
|
|---|
| 957 | C2_EUROPENUMBER, /* 9 - 57 */
|
|---|
| 958 | C2_COMMONSEPARATOR, /* : - 58 */
|
|---|
| 959 | C2_OTHERNEUTRAL, /* ; - 59 */
|
|---|
| 960 | C2_OTHERNEUTRAL, /* < - 60 */
|
|---|
| 961 | C2_OTHERNEUTRAL, /* = - 61 */
|
|---|
| 962 | C2_OTHERNEUTRAL, /* > - 62 */
|
|---|
| 963 | C2_OTHERNEUTRAL, /* ? - 63 */
|
|---|
| 964 | C2_LEFTTORIGHT, /* @ - 64 */
|
|---|
| 965 | C2_LEFTTORIGHT, /* A - 65 */
|
|---|
| 966 | C2_LEFTTORIGHT, /* B - 66 */
|
|---|
| 967 | C2_LEFTTORIGHT, /* C - 67 */
|
|---|
| 968 | C2_LEFTTORIGHT, /* D - 68 */
|
|---|
| 969 | C2_LEFTTORIGHT, /* E - 69 */
|
|---|
| 970 | C2_LEFTTORIGHT, /* F - 70 */
|
|---|
| 971 | C2_LEFTTORIGHT, /* G - 71 */
|
|---|
| 972 | C2_LEFTTORIGHT, /* H - 72 */
|
|---|
| 973 | C2_LEFTTORIGHT, /* I - 73 */
|
|---|
| 974 | C2_LEFTTORIGHT, /* J - 74 */
|
|---|
| 975 | C2_LEFTTORIGHT, /* K - 75 */
|
|---|
| 976 | C2_LEFTTORIGHT, /* L - 76 */
|
|---|
| 977 | C2_LEFTTORIGHT, /* M - 77 */
|
|---|
| 978 | C2_LEFTTORIGHT, /* N - 78 */
|
|---|
| 979 | C2_LEFTTORIGHT, /* O - 79 */
|
|---|
| 980 | C2_LEFTTORIGHT, /* P - 80 */
|
|---|
| 981 | C2_LEFTTORIGHT, /* Q - 81 */
|
|---|
| 982 | C2_LEFTTORIGHT, /* R - 82 */
|
|---|
| 983 | C2_LEFTTORIGHT, /* S - 83 */
|
|---|
| 984 | C2_LEFTTORIGHT, /* T - 84 */
|
|---|
| 985 | C2_LEFTTORIGHT, /* U - 85 */
|
|---|
| 986 | C2_LEFTTORIGHT, /* V - 86 */
|
|---|
| 987 | C2_LEFTTORIGHT, /* W - 87 */
|
|---|
| 988 | C2_LEFTTORIGHT, /* X - 88 */
|
|---|
| 989 | C2_LEFTTORIGHT, /* Y - 89 */
|
|---|
| 990 | C2_LEFTTORIGHT, /* Z - 90 */
|
|---|
| 991 | C2_OTHERNEUTRAL, /* [ - 91 */
|
|---|
| 992 | C2_OTHERNEUTRAL, /* \ - 92 */
|
|---|
| 993 | C2_OTHERNEUTRAL, /* ] - 93 */
|
|---|
| 994 | C2_OTHERNEUTRAL, /* ^ - 94 */
|
|---|
| 995 | C2_OTHERNEUTRAL, /* _ - 95 */
|
|---|
| 996 | C2_OTHERNEUTRAL, /* ` - 96 */
|
|---|
| 997 | C2_LEFTTORIGHT, /* a - 97 */
|
|---|
| 998 | C2_LEFTTORIGHT, /* b - 98 */
|
|---|
| 999 | C2_LEFTTORIGHT, /* c - 99 */
|
|---|
| 1000 | C2_LEFTTORIGHT, /* d - 100 */
|
|---|
| 1001 | C2_LEFTTORIGHT, /* e - 101 */
|
|---|
| 1002 | C2_LEFTTORIGHT, /* f - 102 */
|
|---|
| 1003 | C2_LEFTTORIGHT, /* g - 103 */
|
|---|
| 1004 | C2_LEFTTORIGHT, /* h - 104 */
|
|---|
| 1005 | C2_LEFTTORIGHT, /* i - 105 */
|
|---|
| 1006 | C2_LEFTTORIGHT, /* j - 106 */
|
|---|
| 1007 | C2_LEFTTORIGHT, /* k - 107 */
|
|---|
| 1008 | C2_LEFTTORIGHT, /* l - 108 */
|
|---|
| 1009 | C2_LEFTTORIGHT, /* m - 109 */
|
|---|
| 1010 | C2_LEFTTORIGHT, /* n - 110 */
|
|---|
| 1011 | C2_LEFTTORIGHT, /* o - 111 */
|
|---|
| 1012 | C2_LEFTTORIGHT, /* p - 112 */
|
|---|
| 1013 | C2_LEFTTORIGHT, /* q - 113 */
|
|---|
| 1014 | C2_LEFTTORIGHT, /* r - 114 */
|
|---|
| 1015 | C2_LEFTTORIGHT, /* s - 115 */
|
|---|
| 1016 | C2_LEFTTORIGHT, /* t - 116 */
|
|---|
| 1017 | C2_LEFTTORIGHT, /* u - 117 */
|
|---|
| 1018 | C2_LEFTTORIGHT, /* v - 118 */
|
|---|
| 1019 | C2_LEFTTORIGHT, /* w - 119 */
|
|---|
| 1020 | C2_LEFTTORIGHT, /* x - 120 */
|
|---|
| 1021 | C2_LEFTTORIGHT, /* y - 121 */
|
|---|
| 1022 | C2_LEFTTORIGHT, /* z - 122 */
|
|---|
| 1023 | C2_OTHERNEUTRAL, /* { - 123 */
|
|---|
| 1024 | C2_OTHERNEUTRAL, /* | - 124 */
|
|---|
| 1025 | C2_OTHERNEUTRAL, /* } - 125 */
|
|---|
| 1026 | C2_OTHERNEUTRAL, /* ~ - 126 */
|
|---|
| 1027 | C2_NOTAPPLICABLE, /* - 127 */
|
|---|
| 1028 | C2_NOTAPPLICABLE, /* - 128 */
|
|---|
| 1029 | C2_NOTAPPLICABLE, /* - 129 */
|
|---|
| 1030 | C2_OTHERNEUTRAL, /* - 130 */
|
|---|
| 1031 | C2_LEFTTORIGHT, /* - 131 */
|
|---|
| 1032 | C2_OTHERNEUTRAL, /* - 132 */
|
|---|
| 1033 | C2_OTHERNEUTRAL, /*
|
|---|
| 1034 | - 133 */
|
|---|
| 1035 | C2_OTHERNEUTRAL, /* - 134 */
|
|---|
| 1036 | C2_OTHERNEUTRAL, /* - 135 */
|
|---|
| 1037 | C2_LEFTTORIGHT, /* - 136 */
|
|---|
| 1038 | C2_EUROPETERMINATOR, /* - 137 */
|
|---|
| 1039 | C2_LEFTTORIGHT, /* - 138 */
|
|---|
| 1040 | C2_OTHERNEUTRAL, /* - 139 */
|
|---|
| 1041 | C2_LEFTTORIGHT, /* - 140 */
|
|---|
| 1042 | C2_NOTAPPLICABLE, /* - 141 */
|
|---|
| 1043 | C2_NOTAPPLICABLE, /* - 142 */
|
|---|
| 1044 | C2_NOTAPPLICABLE, /* - 143 */
|
|---|
| 1045 | C2_NOTAPPLICABLE, /* - 144 */
|
|---|
| 1046 | C2_OTHERNEUTRAL, /* - 145 */
|
|---|
| 1047 | C2_OTHERNEUTRAL, /* - 146 */
|
|---|
| 1048 | C2_OTHERNEUTRAL, /* - 147 */
|
|---|
| 1049 | C2_OTHERNEUTRAL, /* - 148 */
|
|---|
| 1050 | C2_OTHERNEUTRAL, /* - 149 */
|
|---|
| 1051 | C2_OTHERNEUTRAL, /* - 150 */
|
|---|
| 1052 | C2_OTHERNEUTRAL, /* - 151 */
|
|---|
| 1053 | C2_LEFTTORIGHT, /* - 152 */
|
|---|
| 1054 | C2_OTHERNEUTRAL, /* - 153 */
|
|---|
| 1055 | C2_LEFTTORIGHT, /* - 154 */
|
|---|
| 1056 | C2_OTHERNEUTRAL, /* - 155 */
|
|---|
| 1057 | C2_LEFTTORIGHT, /* - 156 */
|
|---|
| 1058 | C2_NOTAPPLICABLE, /* - 157 */
|
|---|
| 1059 | C2_NOTAPPLICABLE, /* - 158 */
|
|---|
| 1060 | C2_LEFTTORIGHT, /* - 159 */
|
|---|
| 1061 | C2_WHITESPACE, /* - 160 */
|
|---|
| 1062 | C2_OTHERNEUTRAL, /* ¡ - 161 */
|
|---|
| 1063 | C2_EUROPETERMINATOR, /* ¢ - 162 */
|
|---|
| 1064 | C2_EUROPETERMINATOR, /* £ - 163 */
|
|---|
| 1065 | C2_EUROPETERMINATOR, /* € - 164 */
|
|---|
| 1066 | C2_EUROPETERMINATOR, /* ¥ - 165 */
|
|---|
| 1067 | C2_OTHERNEUTRAL, /* Š - 166 */
|
|---|
| 1068 | C2_OTHERNEUTRAL, /* § - 167 */
|
|---|
| 1069 | C2_OTHERNEUTRAL, /* š - 168 */
|
|---|
| 1070 | C2_OTHERNEUTRAL, /* © - 169 */
|
|---|
| 1071 | C2_OTHERNEUTRAL, /* ª - 170 */
|
|---|
| 1072 | C2_OTHERNEUTRAL, /* « - 171 */
|
|---|
| 1073 | C2_OTHERNEUTRAL, /* ¬ - 172 */
|
|---|
| 1074 | C2_OTHERNEUTRAL, /* - 173 */
|
|---|
| 1075 | C2_OTHERNEUTRAL, /* ® - 174 */
|
|---|
| 1076 | C2_OTHERNEUTRAL, /* ¯ - 175 */
|
|---|
| 1077 | C2_EUROPETERMINATOR, /* ° - 176 */
|
|---|
| 1078 | C2_EUROPETERMINATOR, /* ± - 177 */
|
|---|
| 1079 | C2_EUROPENUMBER, /* ² - 178 */
|
|---|
| 1080 | C2_EUROPENUMBER, /* ³ - 179 */
|
|---|
| 1081 | C2_OTHERNEUTRAL, /* Ž - 180 */
|
|---|
| 1082 | C2_OTHERNEUTRAL, /* µ - 181 */
|
|---|
| 1083 | C2_OTHERNEUTRAL, /* ¶ - 182 */
|
|---|
| 1084 | C2_OTHERNEUTRAL, /* · - 183 */
|
|---|
| 1085 | C2_OTHERNEUTRAL, /* ž - 184 */
|
|---|
| 1086 | C2_EUROPENUMBER, /* ¹ - 185 */
|
|---|
| 1087 | C2_OTHERNEUTRAL, /* º - 186 */
|
|---|
| 1088 | C2_OTHERNEUTRAL, /* » - 187 */
|
|---|
| 1089 | C2_OTHERNEUTRAL, /* Œ - 188 */
|
|---|
| 1090 | C2_OTHERNEUTRAL, /* œ - 189 */
|
|---|
| 1091 | C2_OTHERNEUTRAL, /* Ÿ - 190 */
|
|---|
| 1092 | C2_OTHERNEUTRAL, /* ¿ - 191 */
|
|---|
| 1093 | C2_LEFTTORIGHT, /* À - 192 */
|
|---|
| 1094 | C2_LEFTTORIGHT, /* Á - 193 */
|
|---|
| 1095 | C2_LEFTTORIGHT, /* Â - 194 */
|
|---|
| 1096 | C2_LEFTTORIGHT, /* Ã - 195 */
|
|---|
| 1097 | C2_LEFTTORIGHT, /* Ä - 196 */
|
|---|
| 1098 | C2_LEFTTORIGHT, /* Å - 197 */
|
|---|
| 1099 | C2_LEFTTORIGHT, /* Æ - 198 */
|
|---|
| 1100 | C2_LEFTTORIGHT, /* Ç - 199 */
|
|---|
| 1101 | C2_LEFTTORIGHT, /* È - 200 */
|
|---|
| 1102 | C2_LEFTTORIGHT, /* É - 201 */
|
|---|
| 1103 | C2_LEFTTORIGHT, /* Ê - 202 */
|
|---|
| 1104 | C2_LEFTTORIGHT, /* Ë - 203 */
|
|---|
| 1105 | C2_LEFTTORIGHT, /* Ì - 204 */
|
|---|
| 1106 | C2_LEFTTORIGHT, /* Í - 205 */
|
|---|
| 1107 | C2_LEFTTORIGHT, /* Î - 206 */
|
|---|
| 1108 | C2_LEFTTORIGHT, /* Ï - 207 */
|
|---|
| 1109 | C2_LEFTTORIGHT, /* Ð - 208 */
|
|---|
| 1110 | C2_LEFTTORIGHT, /* Ñ - 209 */
|
|---|
| 1111 | C2_LEFTTORIGHT, /* Ò - 210 */
|
|---|
| 1112 | C2_LEFTTORIGHT, /* Ó - 211 */
|
|---|
| 1113 | C2_LEFTTORIGHT, /* Ô - 212 */
|
|---|
| 1114 | C2_LEFTTORIGHT, /* Õ - 213 */
|
|---|
| 1115 | C2_LEFTTORIGHT, /* Ö - 214 */
|
|---|
| 1116 | C2_OTHERNEUTRAL, /* × - 215 */
|
|---|
| 1117 | C2_LEFTTORIGHT, /* Ø - 216 */
|
|---|
| 1118 | C2_LEFTTORIGHT, /* Ù - 217 */
|
|---|
| 1119 | C2_LEFTTORIGHT, /* Ú - 218 */
|
|---|
| 1120 | C2_LEFTTORIGHT, /* Û - 219 */
|
|---|
| 1121 | C2_LEFTTORIGHT, /* Ü - 220 */
|
|---|
| 1122 | C2_LEFTTORIGHT, /* Ý - 221 */
|
|---|
| 1123 | C2_LEFTTORIGHT, /* Þ - 222 */
|
|---|
| 1124 | C2_LEFTTORIGHT, /* ß - 223 */
|
|---|
| 1125 | C2_LEFTTORIGHT, /* à - 224 */
|
|---|
| 1126 | C2_LEFTTORIGHT, /* á - 225 */
|
|---|
| 1127 | C2_LEFTTORIGHT, /* â - 226 */
|
|---|
| 1128 | C2_LEFTTORIGHT, /* ã - 227 */
|
|---|
| 1129 | C2_LEFTTORIGHT, /* ä - 228 */
|
|---|
| 1130 | C2_LEFTTORIGHT, /* å - 229 */
|
|---|
| 1131 | C2_LEFTTORIGHT, /* æ - 230 */
|
|---|
| 1132 | C2_LEFTTORIGHT, /* ç - 231 */
|
|---|
| 1133 | C2_LEFTTORIGHT, /* è - 232 */
|
|---|
| 1134 | C2_LEFTTORIGHT, /* é - 233 */
|
|---|
| 1135 | C2_LEFTTORIGHT, /* ê - 234 */
|
|---|
| 1136 | C2_LEFTTORIGHT, /* ë - 235 */
|
|---|
| 1137 | C2_LEFTTORIGHT, /* ì - 236 */
|
|---|
| 1138 | C2_LEFTTORIGHT, /* í - 237 */
|
|---|
| 1139 | C2_LEFTTORIGHT, /* î - 238 */
|
|---|
| 1140 | C2_LEFTTORIGHT, /* ï - 239 */
|
|---|
| 1141 | C2_LEFTTORIGHT, /* ð - 240 */
|
|---|
| 1142 | C2_LEFTTORIGHT, /* ñ - 241 */
|
|---|
| 1143 | C2_LEFTTORIGHT, /* ò - 242 */
|
|---|
| 1144 | C2_LEFTTORIGHT, /* ó - 243 */
|
|---|
| 1145 | C2_LEFTTORIGHT, /* ô - 244 */
|
|---|
| 1146 | C2_LEFTTORIGHT, /* õ - 245 */
|
|---|
| 1147 | C2_LEFTTORIGHT, /* ö - 246 */
|
|---|
| 1148 | C2_OTHERNEUTRAL, /* ÷ - 247 */
|
|---|
| 1149 | C2_LEFTTORIGHT, /* ø - 248 */
|
|---|
| 1150 | C2_LEFTTORIGHT, /* ù - 249 */
|
|---|
| 1151 | C2_LEFTTORIGHT, /* ú - 250 */
|
|---|
| 1152 | C2_LEFTTORIGHT, /* û - 251 */
|
|---|
| 1153 | C2_LEFTTORIGHT, /* ü - 252 */
|
|---|
| 1154 | C2_LEFTTORIGHT, /* ý - 253 */
|
|---|
| 1155 | C2_LEFTTORIGHT, /* þ - 254 */
|
|---|
| 1156 | C2_LEFTTORIGHT /* ÿ - 255 */
|
|---|
| 1157 | };
|
|---|
| 1158 |
|
|---|
| 1159 | const WORD OLE2NLS_CT_CType3_LUT[] = {
|
|---|
| 1160 | 0x0000, /* - 0 */
|
|---|
| 1161 | 0x0000, /* - 1 */
|
|---|
| 1162 | 0x0000, /* - 2 */
|
|---|
| 1163 | 0x0000, /* - 3 */
|
|---|
| 1164 | 0x0000, /* - 4 */
|
|---|
| 1165 | 0x0000, /* - 5 */
|
|---|
| 1166 | 0x0000, /* - 6 */
|
|---|
| 1167 | 0x0000, /* - 7 */
|
|---|
| 1168 | 0x0000, /* - 8 */
|
|---|
| 1169 | 0x0008, /* - 9 */
|
|---|
| 1170 | 0x0008, /* - 10 */
|
|---|
| 1171 | 0x0008, /* - 11 */
|
|---|
| 1172 | 0x0008, /* - 12 */
|
|---|
| 1173 | 0x0008, /* - 13 */
|
|---|
| 1174 | 0x0000, /* - 14 */
|
|---|
| 1175 | 0x0000, /* - 15 */
|
|---|
| 1176 | 0x0000, /* - 16 */
|
|---|
| 1177 | 0x0000, /* - 17 */
|
|---|
| 1178 | 0x0000, /* - 18 */
|
|---|
| 1179 | 0x0000, /* - 19 */
|
|---|
| 1180 | 0x0000, /* - 20 */
|
|---|
| 1181 | 0x0000, /* - 21 */
|
|---|
| 1182 | 0x0000, /* - 22 */
|
|---|
| 1183 | 0x0000, /* - 23 */
|
|---|
| 1184 | 0x0000, /* - 24 */
|
|---|
| 1185 | 0x0000, /* - 25 */
|
|---|
| 1186 | 0x0000, /* - 26 */
|
|---|
| 1187 | 0x0000, /* - 27 */
|
|---|
| 1188 | 0x0000, /* - 28 */
|
|---|
| 1189 | 0x0000, /* - 29 */
|
|---|
| 1190 | 0x0000, /* - 30 */
|
|---|
| 1191 | 0x0000, /* - 31 */
|
|---|
| 1192 | 0x0048, /* - 32 */
|
|---|
| 1193 | 0x0048, /* ! - 33 */
|
|---|
| 1194 | 0x0448, /* " - 34 */ /* " */
|
|---|
| 1195 | 0x0048, /* # - 35 */
|
|---|
| 1196 | 0x0448, /* $ - 36 */
|
|---|
| 1197 | 0x0048, /* % - 37 */
|
|---|
| 1198 | 0x0048, /* & - 38 */
|
|---|
| 1199 | 0x0440, /* ' - 39 */
|
|---|
| 1200 | 0x0048, /* ( - 40 */
|
|---|
| 1201 | 0x0048, /* ) - 41 */
|
|---|
| 1202 | 0x0048, /* * - 42 */
|
|---|
| 1203 | 0x0048, /* + - 43 */
|
|---|
| 1204 | 0x0048, /* , - 44 */
|
|---|
| 1205 | 0x0440, /* - - 45 */
|
|---|
| 1206 | 0x0048, /* . - 46 */
|
|---|
| 1207 | 0x0448, /* / - 47 */
|
|---|
| 1208 | 0x0040, /* 0 - 48 */
|
|---|
| 1209 | 0x0040, /* 1 - 49 */
|
|---|
| 1210 | 0x0040, /* 2 - 50 */
|
|---|
| 1211 | 0x0040, /* 3 - 51 */
|
|---|
| 1212 | 0x0040, /* 4 - 52 */
|
|---|
| 1213 | 0x0040, /* 5 - 53 */
|
|---|
| 1214 | 0x0040, /* 6 - 54 */
|
|---|
| 1215 | 0x0040, /* 7 - 55 */
|
|---|
| 1216 | 0x0040, /* 8 - 56 */
|
|---|
| 1217 | 0x0040, /* 9 - 57 */
|
|---|
| 1218 | 0x0048, /* : - 58 */
|
|---|
| 1219 | 0x0048, /* ; - 59 */
|
|---|
| 1220 | 0x0048, /* < - 60 */
|
|---|
| 1221 | 0x0448, /* = - 61 */
|
|---|
| 1222 | 0x0048, /* > - 62 */
|
|---|
| 1223 | 0x0048, /* ? - 63 */
|
|---|
| 1224 | 0x0448, /* @ - 64 */
|
|---|
| 1225 | 0x8040, /* A - 65 */
|
|---|
| 1226 | 0x8040, /* B - 66 */
|
|---|
| 1227 | 0x8040, /* C - 67 */
|
|---|
| 1228 | 0x8040, /* D - 68 */
|
|---|
| 1229 | 0x8040, /* E - 69 */
|
|---|
| 1230 | 0x8040, /* F - 70 */
|
|---|
| 1231 | 0x8040, /* G - 71 */
|
|---|
| 1232 | 0x8040, /* H - 72 */
|
|---|
| 1233 | 0x8040, /* I - 73 */
|
|---|
| 1234 | 0x8040, /* J - 74 */
|
|---|
| 1235 | 0x8040, /* K - 75 */
|
|---|
| 1236 | 0x8040, /* L - 76 */
|
|---|
| 1237 | 0x8040, /* M - 77 */
|
|---|
| 1238 | 0x8040, /* N - 78 */
|
|---|
| 1239 | 0x8040, /* O - 79 */
|
|---|
| 1240 | 0x8040, /* P - 80 */
|
|---|
| 1241 | 0x8040, /* Q - 81 */
|
|---|
| 1242 | 0x8040, /* R - 82 */
|
|---|
| 1243 | 0x8040, /* S - 83 */
|
|---|
| 1244 | 0x8040, /* T - 84 */
|
|---|
| 1245 | 0x8040, /* U - 85 */
|
|---|
| 1246 | 0x8040, /* V - 86 */
|
|---|
| 1247 | 0x8040, /* W - 87 */
|
|---|
| 1248 | 0x8040, /* X - 88 */
|
|---|
| 1249 | 0x8040, /* Y - 89 */
|
|---|
| 1250 | 0x8040, /* Z - 90 */
|
|---|
| 1251 | 0x0048, /* [ - 91 */
|
|---|
| 1252 | 0x0448, /* \ - 92 */
|
|---|
| 1253 | 0x0048, /* ] - 93 */
|
|---|
| 1254 | 0x0448, /* ^ - 94 */
|
|---|
| 1255 | 0x0448, /* _ - 95 */
|
|---|
| 1256 | 0x0448, /* ` - 96 */
|
|---|
| 1257 | 0x8040, /* a - 97 */
|
|---|
| 1258 | 0x8040, /* b - 98 */
|
|---|
| 1259 | 0x8040, /* c - 99 */
|
|---|
| 1260 | 0x8040, /* d - 100 */
|
|---|
| 1261 | 0x8040, /* e - 101 */
|
|---|
| 1262 | 0x8040, /* f - 102 */
|
|---|
| 1263 | 0x8040, /* g - 103 */
|
|---|
| 1264 | 0x8040, /* h - 104 */
|
|---|
| 1265 | 0x8040, /* i - 105 */
|
|---|
| 1266 | 0x8040, /* j - 106 */
|
|---|
| 1267 | 0x8040, /* k - 107 */
|
|---|
| 1268 | 0x8040, /* l - 108 */
|
|---|
| 1269 | 0x8040, /* m - 109 */
|
|---|
| 1270 | 0x8040, /* n - 110 */
|
|---|
| 1271 | 0x8040, /* o - 111 */
|
|---|
| 1272 | 0x8040, /* p - 112 */
|
|---|
| 1273 | 0x8040, /* q - 113 */
|
|---|
| 1274 | 0x8040, /* r - 114 */
|
|---|
| 1275 | 0x8040, /* s - 115 */
|
|---|
| 1276 | 0x8040, /* t - 116 */
|
|---|
| 1277 | 0x8040, /* u - 117 */
|
|---|
| 1278 | 0x8040, /* v - 118 */
|
|---|
| 1279 | 0x8040, /* w - 119 */
|
|---|
| 1280 | 0x8040, /* x - 120 */
|
|---|
| 1281 | 0x8040, /* y - 121 */
|
|---|
| 1282 | 0x8040, /* z - 122 */
|
|---|
| 1283 | 0x0048, /* { - 123 */
|
|---|
| 1284 | 0x0048, /* | - 124 */
|
|---|
| 1285 | 0x0048, /* } - 125 */
|
|---|
| 1286 | 0x0448, /* ~ - 126 */
|
|---|
| 1287 | 0x0000, /* - 127 */
|
|---|
| 1288 | 0x0000, /* - 128 */
|
|---|
| 1289 | 0x0000, /* - 129 */
|
|---|
| 1290 | 0x0008, /* - 130 */
|
|---|
| 1291 | 0x8000, /* - 131 */
|
|---|
| 1292 | 0x0008, /* - 132 */
|
|---|
| 1293 | 0x0008, /*
|
|---|
| 1294 | - 133 */
|
|---|
| 1295 | 0x0008, /* - 134 */
|
|---|
| 1296 | 0x0008, /* - 135 */
|
|---|
| 1297 | 0x0001, /* - 136 */
|
|---|
| 1298 | 0x0008, /* - 137 */
|
|---|
| 1299 | 0x8003, /* - 138 */
|
|---|
| 1300 | 0x0008, /* - 139 */
|
|---|
| 1301 | 0x8000, /* - 140 */
|
|---|
| 1302 | 0x0000, /* - 141 */
|
|---|
| 1303 | 0x0000, /* - 142 */
|
|---|
| 1304 | 0x0000, /* - 143 */
|
|---|
| 1305 | 0x0000, /* - 144 */
|
|---|
| 1306 | 0x0088, /* - 145 */
|
|---|
| 1307 | 0x0088, /* - 146 */
|
|---|
| 1308 | 0x0088, /* - 147 */
|
|---|
| 1309 | 0x0088, /* - 148 */
|
|---|
| 1310 | 0x0008, /* - 149 */
|
|---|
| 1311 | 0x0400, /* - 150 */
|
|---|
| 1312 | 0x0400, /* - 151 */
|
|---|
| 1313 | 0x0408, /* - 152 */
|
|---|
| 1314 | 0x0000, /* - 153 */
|
|---|
| 1315 | 0x8003, /* - 154 */
|
|---|
| 1316 | 0x0008, /* - 155 */
|
|---|
| 1317 | 0x8000, /* - 156 */
|
|---|
| 1318 | 0x0000, /* - 157 */
|
|---|
| 1319 | 0x0000, /* - 158 */
|
|---|
| 1320 | 0x8003, /* - 159 */
|
|---|
| 1321 | 0x0008, /* - 160 */
|
|---|
| 1322 | 0x0008, /* ¡ - 161 */
|
|---|
| 1323 | 0x0048, /* ¢ - 162 */
|
|---|
| 1324 | 0x0048, /* £ - 163 */
|
|---|
| 1325 | 0x0008, /* € - 164 */
|
|---|
| 1326 | 0x0048, /* ¥ - 165 */
|
|---|
| 1327 | 0x0048, /* Š - 166 */
|
|---|
| 1328 | 0x0008, /* § - 167 */
|
|---|
| 1329 | 0x0408, /* š - 168 */
|
|---|
| 1330 | 0x0008, /* © - 169 */
|
|---|
| 1331 | 0x0400, /* ª - 170 */
|
|---|
| 1332 | 0x0008, /* « - 171 */
|
|---|
| 1333 | 0x0048, /* ¬ - 172 */
|
|---|
| 1334 | 0x0408, /* - 173 */
|
|---|
| 1335 | 0x0008, /* ® - 174 */
|
|---|
| 1336 | 0x0448, /* ¯ - 175 */
|
|---|
| 1337 | 0x0008, /* ° - 176 */
|
|---|
| 1338 | 0x0008, /* ± - 177 */
|
|---|
| 1339 | 0x0000, /* ² - 178 */
|
|---|
| 1340 | 0x0000, /* ³ - 179 */
|
|---|
| 1341 | 0x0408, /* Ž - 180 */
|
|---|
| 1342 | 0x0008, /* µ - 181 */
|
|---|
| 1343 | 0x0008, /* ¶ - 182 */
|
|---|
| 1344 | 0x0008, /* · - 183 */
|
|---|
| 1345 | 0x0408, /* ž - 184 */
|
|---|
| 1346 | 0x0000, /* ¹ - 185 */
|
|---|
| 1347 | 0x0400, /* º - 186 */
|
|---|
| 1348 | 0x0008, /* » - 187 */
|
|---|
| 1349 | 0x0000, /* Œ - 188 */
|
|---|
| 1350 | 0x0000, /* œ - 189 */
|
|---|
| 1351 | 0x0000, /* Ÿ - 190 */
|
|---|
| 1352 | 0x0008, /* ¿ - 191 */
|
|---|
| 1353 | 0x8003, /* À - 192 */
|
|---|
| 1354 | 0x8003, /* Á - 193 */
|
|---|
| 1355 | 0x8003, /* Â - 194 */
|
|---|
| 1356 | 0x8003, /* Ã - 195 */
|
|---|
| 1357 | 0x8003, /* Ä - 196 */
|
|---|
| 1358 | 0x8003, /* Å - 197 */
|
|---|
| 1359 | 0x8000, /* Æ - 198 */
|
|---|
| 1360 | 0x8003, /* Ç - 199 */
|
|---|
| 1361 | 0x8003, /* È - 200 */
|
|---|
| 1362 | 0x8003, /* É - 201 */
|
|---|
| 1363 | 0x8003, /* Ê - 202 */
|
|---|
| 1364 | 0x8003, /* Ë - 203 */
|
|---|
| 1365 | 0x8003, /* Ì - 204 */
|
|---|
| 1366 | 0x8003, /* Í - 205 */
|
|---|
| 1367 | 0x8003, /* Î - 206 */
|
|---|
| 1368 | 0x8003, /* Ï - 207 */
|
|---|
| 1369 | 0x8000, /* Ð - 208 */
|
|---|
| 1370 | 0x8003, /* Ñ - 209 */
|
|---|
| 1371 | 0x8003, /* Ò - 210 */
|
|---|
| 1372 | 0x8003, /* Ó - 211 */
|
|---|
| 1373 | 0x8003, /* Ô - 212 */
|
|---|
| 1374 | 0x8003, /* Õ - 213 */
|
|---|
| 1375 | 0x8003, /* Ö - 214 */
|
|---|
| 1376 | 0x0008, /* × - 215 */
|
|---|
| 1377 | 0x8003, /* Ø - 216 */
|
|---|
| 1378 | 0x8003, /* Ù - 217 */
|
|---|
| 1379 | 0x8003, /* Ú - 218 */
|
|---|
| 1380 | 0x8003, /* Û - 219 */
|
|---|
| 1381 | 0x8003, /* Ü - 220 */
|
|---|
| 1382 | 0x8003, /* Ý - 221 */
|
|---|
| 1383 | 0x8000, /* Þ - 222 */
|
|---|
| 1384 | 0x8000, /* ß - 223 */
|
|---|
| 1385 | 0x8003, /* à - 224 */
|
|---|
| 1386 | 0x8003, /* á - 225 */
|
|---|
| 1387 | 0x8003, /* â - 226 */
|
|---|
| 1388 | 0x8003, /* ã - 227 */
|
|---|
| 1389 | 0x8003, /* ä - 228 */
|
|---|
| 1390 | 0x8003, /* å - 229 */
|
|---|
| 1391 | 0x8000, /* æ - 230 */
|
|---|
| 1392 | 0x8003, /* ç - 231 */
|
|---|
| 1393 | 0x8003, /* è - 232 */
|
|---|
| 1394 | 0x8003, /* é - 233 */
|
|---|
| 1395 | 0x8003, /* ê - 234 */
|
|---|
| 1396 | 0x8003, /* ë - 235 */
|
|---|
| 1397 | 0x8003, /* ì - 236 */
|
|---|
| 1398 | 0x8003, /* í - 237 */
|
|---|
| 1399 | 0x8003, /* î - 238 */
|
|---|
| 1400 | 0x8003, /* ï - 239 */
|
|---|
| 1401 | 0x8000, /* ð - 240 */
|
|---|
| 1402 | 0x8003, /* ñ - 241 */
|
|---|
| 1403 | 0x8003, /* ò - 242 */
|
|---|
| 1404 | 0x8003, /* ó - 243 */
|
|---|
| 1405 | 0x8003, /* ô - 244 */
|
|---|
| 1406 | 0x8003, /* õ - 245 */
|
|---|
| 1407 | 0x8003, /* ö - 246 */
|
|---|
| 1408 | 0x0008, /* ÷ - 247 */
|
|---|
| 1409 | 0x8003, /* ø - 248 */
|
|---|
| 1410 | 0x8003, /* ù - 249 */
|
|---|
| 1411 | 0x8003, /* ú - 250 */
|
|---|
| 1412 | 0x8003, /* û - 251 */
|
|---|
| 1413 | 0x8003, /* ü - 252 */
|
|---|
| 1414 | 0x8003, /* ý - 253 */
|
|---|
| 1415 | 0x8000, /* þ - 254 */
|
|---|
| 1416 | 0x8003 /* ÿ - 255 */
|
|---|
| 1417 | };
|
|---|
| 1418 |
|
|---|
| 1419 | /******************************************************************************
|
|---|
| 1420 | * GetStringTypeA [KERNEL32.396]
|
|---|
| 1421 | */
|
|---|
| 1422 | BOOL WINAPI GetStringTypeA(LCID locale,DWORD dwInfoType,LPCSTR src,
|
|---|
| 1423 | INT cchSrc,LPWORD chartype)
|
|---|
| 1424 | {
|
|---|
| 1425 | return GetStringTypeExA(locale,dwInfoType,src,cchSrc,chartype);
|
|---|
| 1426 | }
|
|---|
| 1427 |
|
|---|
| 1428 | /******************************************************************************
|
|---|
| 1429 | * GetStringTypeExA [KERNEL32.397]
|
|---|
| 1430 | *
|
|---|
| 1431 | * FIXME: Ignores the locale.
|
|---|
| 1432 | */
|
|---|
| 1433 | BOOL WINAPI GetStringTypeExA(LCID locale,DWORD dwInfoType,LPCSTR src,
|
|---|
| 1434 | INT cchSrc,LPWORD chartype)
|
|---|
| 1435 | {
|
|---|
| 1436 | int i;
|
|---|
| 1437 |
|
|---|
| 1438 | if ((src==NULL) || (chartype==NULL) || (src==(LPSTR)chartype))
|
|---|
| 1439 | {
|
|---|
| 1440 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 1441 | return FALSE;
|
|---|
| 1442 | }
|
|---|
| 1443 |
|
|---|
| 1444 | if (cchSrc==-1)
|
|---|
| 1445 | cchSrc=strlen(src)+1;
|
|---|
| 1446 |
|
|---|
| 1447 | switch (dwInfoType) {
|
|---|
| 1448 | case CT_CTYPE1:
|
|---|
| 1449 | for (i=0;i<cchSrc;i++)
|
|---|
| 1450 | {
|
|---|
| 1451 | chartype[i] = 0;
|
|---|
| 1452 | if (isdigit(src[i])) chartype[i]|=C1_DIGIT;
|
|---|
| 1453 | if (isalpha(src[i])) chartype[i]|=C1_ALPHA;
|
|---|
| 1454 | if (islower(src[i])) chartype[i]|=C1_LOWER;
|
|---|
| 1455 | if (isupper(src[i])) chartype[i]|=C1_UPPER;
|
|---|
| 1456 | if (isspace(src[i])) chartype[i]|=C1_SPACE;
|
|---|
| 1457 | if (ispunct(src[i])) chartype[i]|=C1_PUNCT;
|
|---|
| 1458 | if (iscntrl(src[i])) chartype[i]|=C1_CNTRL;
|
|---|
| 1459 | /* FIXME: isblank() is a GNU extension */
|
|---|
| 1460 | /* if (isblank(src[i])) chartype[i]|=C1_BLANK; */
|
|---|
| 1461 | if ((src[i] == ' ') || (src[i] == '\t')) chartype[i]|=C1_BLANK;
|
|---|
| 1462 | /* C1_XDIGIT */
|
|---|
| 1463 | }
|
|---|
| 1464 | return TRUE;
|
|---|
| 1465 |
|
|---|
| 1466 | case CT_CTYPE2:
|
|---|
| 1467 | for (i=0;i<cchSrc;i++)
|
|---|
| 1468 | {
|
|---|
| 1469 | chartype[i]=(WORD)CT_CType2_LUT[i];
|
|---|
| 1470 | }
|
|---|
| 1471 | return TRUE;
|
|---|
| 1472 |
|
|---|
| 1473 | case CT_CTYPE3:
|
|---|
| 1474 | for (i=0;i<cchSrc;i++)
|
|---|
| 1475 | {
|
|---|
| 1476 | chartype[i]=OLE2NLS_CT_CType3_LUT[i];
|
|---|
| 1477 | }
|
|---|
| 1478 | return TRUE;
|
|---|
| 1479 |
|
|---|
| 1480 | default:
|
|---|
| 1481 | ERR("Unknown dwInfoType:%ld\n",dwInfoType);
|
|---|
| 1482 | return FALSE;
|
|---|
| 1483 | }
|
|---|
| 1484 | }
|
|---|
| 1485 |
|
|---|
| 1486 | /***********************************************************************
|
|---|
| 1487 | * VerLanguageNameA [KERNEL32.709][VERSION.9]
|
|---|
| 1488 | */
|
|---|
| 1489 | DWORD WINAPI VerLanguageNameA( UINT wLang, LPSTR szLang, UINT nSize )
|
|---|
| 1490 | {
|
|---|
| 1491 | if(!szLang)
|
|---|
| 1492 | return 0;
|
|---|
| 1493 |
|
|---|
| 1494 | return GetLocaleInfoA(MAKELCID(wLang, SORT_DEFAULT), LOCALE_SENGLANGUAGE, szLang, nSize);
|
|---|
| 1495 | }
|
|---|
| 1496 |
|
|---|
| 1497 | /***********************************************************************
|
|---|
| 1498 | * VerLanguageNameW [KERNEL32.710][VERSION.10]
|
|---|
| 1499 | */
|
|---|
| 1500 | DWORD WINAPI VerLanguageNameW( UINT wLang, LPWSTR szLang, UINT nSize )
|
|---|
| 1501 | {
|
|---|
| 1502 | if(!szLang)
|
|---|
| 1503 | return 0;
|
|---|
| 1504 |
|
|---|
| 1505 | return GetLocaleInfoW(MAKELCID(wLang, SORT_DEFAULT), LOCALE_SENGLANGUAGE, szLang, nSize);
|
|---|
| 1506 | }
|
|---|
| 1507 |
|
|---|
| 1508 |
|
|---|
| 1509 | static const unsigned char LCM_Unicode_LUT[] = {
|
|---|
| 1510 | 6 , 3, /* - 1 */
|
|---|
| 1511 | 6 , 4, /* - 2 */
|
|---|
| 1512 | 6 , 5, /* - 3 */
|
|---|
| 1513 | 6 , 6, /* - 4 */
|
|---|
| 1514 | 6 , 7, /* - 5 */
|
|---|
| 1515 | 6 , 8, /* - 6 */
|
|---|
| 1516 | 6 , 9, /* - 7 */
|
|---|
| 1517 | 6 , 10, /* - 8 */
|
|---|
| 1518 | 7 , 5, /* - 9 */
|
|---|
| 1519 | 7 , 6, /* - 10 */
|
|---|
| 1520 | 7 , 7, /* - 11 */
|
|---|
| 1521 | 7 , 8, /* - 12 */
|
|---|
| 1522 | 7 , 9, /* - 13 */
|
|---|
| 1523 | 6 , 11, /* - 14 */
|
|---|
| 1524 | 6 , 12, /* - 15 */
|
|---|
| 1525 | 6 , 13, /* - 16 */
|
|---|
| 1526 | 6 , 14, /* - 17 */
|
|---|
| 1527 | 6 , 15, /* - 18 */
|
|---|
| 1528 | 6 , 16, /* - 19 */
|
|---|
| 1529 | 6 , 17, /* - 20 */
|
|---|
| 1530 | 6 , 18, /* - 21 */
|
|---|
| 1531 | 6 , 19, /* - 22 */
|
|---|
| 1532 | 6 , 20, /* - 23 */
|
|---|
| 1533 | 6 , 21, /* - 24 */
|
|---|
| 1534 | 6 , 22, /* - 25 */
|
|---|
| 1535 | 6 , 23, /* - 26 */
|
|---|
| 1536 | 6 , 24, /* - 27 */
|
|---|
| 1537 | 6 , 25, /* - 28 */
|
|---|
| 1538 | 6 , 26, /* - 29 */
|
|---|
| 1539 | 6 , 27, /* - 30 */
|
|---|
| 1540 | 6 , 28, /* - 31 */
|
|---|
| 1541 | 7 , 2, /* - 32 */
|
|---|
| 1542 | 7 , 28, /* ! - 33 */
|
|---|
| 1543 | 7 , 29, /* " - 34 */ /* " */
|
|---|
| 1544 | 7 , 31, /* # - 35 */
|
|---|
| 1545 | 7 , 33, /* $ - 36 */
|
|---|
| 1546 | 7 , 35, /* % - 37 */
|
|---|
| 1547 | 7 , 37, /* & - 38 */
|
|---|
| 1548 | 6 , 128, /* ' - 39 */
|
|---|
| 1549 | 7 , 39, /* ( - 40 */
|
|---|
| 1550 | 7 , 42, /* ) - 41 */
|
|---|
| 1551 | 7 , 45, /* * - 42 */
|
|---|
| 1552 | 8 , 3, /* + - 43 */
|
|---|
| 1553 | 7 , 47, /* , - 44 */
|
|---|
| 1554 | 6 , 130, /* - - 45 */
|
|---|
| 1555 | 7 , 51, /* . - 46 */
|
|---|
| 1556 | 7 , 53, /* / - 47 */
|
|---|
| 1557 | 12 , 3, /* 0 - 48 */
|
|---|
| 1558 | 12 , 33, /* 1 - 49 */
|
|---|
| 1559 | 12 , 51, /* 2 - 50 */
|
|---|
| 1560 | 12 , 70, /* 3 - 51 */
|
|---|
| 1561 | 12 , 88, /* 4 - 52 */
|
|---|
| 1562 | 12 , 106, /* 5 - 53 */
|
|---|
| 1563 | 12 , 125, /* 6 - 54 */
|
|---|
| 1564 | 12 , 144, /* 7 - 55 */
|
|---|
| 1565 | 12 , 162, /* 8 - 56 */
|
|---|
| 1566 | 12 , 180, /* 9 - 57 */
|
|---|
| 1567 | 7 , 55, /* : - 58 */
|
|---|
| 1568 | 7 , 58, /* ; - 59 */
|
|---|
| 1569 | 8 , 14, /* < - 60 */
|
|---|
| 1570 | 8 , 18, /* = - 61 */
|
|---|
| 1571 | 8 , 20, /* > - 62 */
|
|---|
| 1572 | 7 , 60, /* ? - 63 */
|
|---|
| 1573 | 7 , 62, /* @ - 64 */
|
|---|
| 1574 | 14 , 2, /* A - 65 */
|
|---|
| 1575 | 14 , 9, /* B - 66 */
|
|---|
| 1576 | 14 , 10, /* C - 67 */
|
|---|
| 1577 | 14 , 26, /* D - 68 */
|
|---|
| 1578 | 14 , 33, /* E - 69 */
|
|---|
| 1579 | 14 , 35, /* F - 70 */
|
|---|
| 1580 | 14 , 37, /* G - 71 */
|
|---|
| 1581 | 14 , 44, /* H - 72 */
|
|---|
| 1582 | 14 , 50, /* I - 73 */
|
|---|
| 1583 | 14 , 53, /* J - 74 */
|
|---|
| 1584 | 14 , 54, /* K - 75 */
|
|---|
| 1585 | 14 , 72, /* L - 76 */
|
|---|
| 1586 | 14 , 81, /* M - 77 */
|
|---|
| 1587 | 14 , 112, /* N - 78 */
|
|---|
| 1588 | 14 , 124, /* O - 79 */
|
|---|
| 1589 | 14 , 126, /* P - 80 */
|
|---|
| 1590 | 14 , 137, /* Q - 81 */
|
|---|
| 1591 | 14 , 138, /* R - 82 */
|
|---|
| 1592 | 14 , 145, /* S - 83 */
|
|---|
| 1593 | 14 , 153, /* T - 84 */
|
|---|
| 1594 | 14 , 159, /* U - 85 */
|
|---|
| 1595 | 14 , 162, /* V - 86 */
|
|---|
| 1596 | 14 , 164, /* W - 87 */
|
|---|
| 1597 | 14 , 166, /* X - 88 */
|
|---|
| 1598 | 14 , 167, /* Y - 89 */
|
|---|
| 1599 | 14 , 169, /* Z - 90 */
|
|---|
| 1600 | 7 , 63, /* [ - 91 */
|
|---|
| 1601 | 7 , 65, /* \ - 92 */
|
|---|
| 1602 | 7 , 66, /* ] - 93 */
|
|---|
| 1603 | 7 , 67, /* ^ - 94 */
|
|---|
| 1604 | 7 , 68, /* _ - 95 */
|
|---|
| 1605 | 7 , 72, /* ` - 96 */
|
|---|
| 1606 | 14 , 2, /* a - 97 */
|
|---|
| 1607 | 14 , 9, /* b - 98 */
|
|---|
| 1608 | 14 , 10, /* c - 99 */
|
|---|
| 1609 | 14 , 26, /* d - 100 */
|
|---|
| 1610 | 14 , 33, /* e - 101 */
|
|---|
| 1611 | 14 , 35, /* f - 102 */
|
|---|
| 1612 | 14 , 37, /* g - 103 */
|
|---|
| 1613 | 14 , 44, /* h - 104 */
|
|---|
| 1614 | 14 , 50, /* i - 105 */
|
|---|
| 1615 | 14 , 53, /* j - 106 */
|
|---|
| 1616 | 14 , 54, /* k - 107 */
|
|---|
| 1617 | 14 , 72, /* l - 108 */
|
|---|
| 1618 | 14 , 81, /* m - 109 */
|
|---|
| 1619 | 14 , 112, /* n - 110 */
|
|---|
| 1620 | 14 , 124, /* o - 111 */
|
|---|
| 1621 | 14 , 126, /* p - 112 */
|
|---|
| 1622 | 14 , 137, /* q - 113 */
|
|---|
| 1623 | 14 , 138, /* r - 114 */
|
|---|
| 1624 | 14 , 145, /* s - 115 */
|
|---|
| 1625 | 14 , 153, /* t - 116 */
|
|---|
| 1626 | 14 , 159, /* u - 117 */
|
|---|
| 1627 | 14 , 162, /* v - 118 */
|
|---|
| 1628 | 14 , 164, /* w - 119 */
|
|---|
| 1629 | 14 , 166, /* x - 120 */
|
|---|
| 1630 | 14 , 167, /* y - 121 */
|
|---|
| 1631 | 14 , 169, /* z - 122 */
|
|---|
| 1632 | 7 , 74, /* { - 123 */
|
|---|
| 1633 | 7 , 76, /* | - 124 */
|
|---|
| 1634 | 7 , 78, /* } - 125 */
|
|---|
| 1635 | 7 , 80, /* ~ - 126 */
|
|---|
| 1636 | 6 , 29, /* - 127 */
|
|---|
| 1637 | 6 , 30, /* - 128 */
|
|---|
| 1638 | 6 , 31, /* - 129 */
|
|---|
| 1639 | 7 , 123, /* - 130 */
|
|---|
| 1640 | 14 , 35, /* - 131 */
|
|---|
| 1641 | 7 , 127, /* - 132 */
|
|---|
| 1642 | 10 , 21, /*
|
|---|
| 1643 | - 133 */
|
|---|
| 1644 | 10 , 15, /* - 134 */
|
|---|
| 1645 | 10 , 16, /* - 135 */
|
|---|
| 1646 | 7 , 67, /* - 136 */
|
|---|
| 1647 | 10 , 22, /* - 137 */
|
|---|
| 1648 | 14 , 145, /* - 138 */
|
|---|
| 1649 | 7 , 136, /* - 139 */
|
|---|
| 1650 | 14 + 16 , 124, /* - 140 */
|
|---|
| 1651 | 6 , 43, /* - 141 */
|
|---|
| 1652 | 6 , 44, /* - 142 */
|
|---|
| 1653 | 6 , 45, /* - 143 */
|
|---|
| 1654 | 6 , 46, /* - 144 */
|
|---|
| 1655 | 7 , 121, /* - 145 */
|
|---|
| 1656 | 7 , 122, /* - 146 */
|
|---|
| 1657 | 7 , 125, /* - 147 */
|
|---|
| 1658 | 7 , 126, /* - 148 */
|
|---|
| 1659 | 10 , 17, /* - 149 */
|
|---|
| 1660 | 6 , 137, /* - 150 */
|
|---|
| 1661 | 6 , 139, /* - 151 */
|
|---|
| 1662 | 7 , 93, /* - 152 */
|
|---|
| 1663 | 14 , 156, /* - 153 */
|
|---|
| 1664 | 14 , 145, /* - 154 */
|
|---|
| 1665 | 7 , 137, /* - 155 */
|
|---|
| 1666 | 14 + 16 , 124, /* - 156 */
|
|---|
| 1667 | 6 , 59, /* - 157 */
|
|---|
| 1668 | 6 , 60, /* - 158 */
|
|---|
| 1669 | 14 , 167, /* - 159 */
|
|---|
| 1670 | 7 , 4, /* - 160 */
|
|---|
| 1671 | 7 , 81, /* ¡ - 161 */
|
|---|
| 1672 | 10 , 2, /* ¢ - 162 */
|
|---|
| 1673 | 10 , 3, /* £ - 163 */
|
|---|
| 1674 | 10 , 4, /* € - 164 */
|
|---|
| 1675 | 10 , 5, /* ¥ - 165 */
|
|---|
| 1676 | 7 , 82, /* Š - 166 */
|
|---|
| 1677 | 10 , 6, /* § - 167 */
|
|---|
| 1678 | 7 , 83, /* š - 168 */
|
|---|
| 1679 | 10 , 7, /* © - 169 */
|
|---|
| 1680 | 14 , 2, /* ª - 170 */
|
|---|
| 1681 | 8 , 24, /* « - 171 */
|
|---|
| 1682 | 10 , 8, /* ¬ - 172 */
|
|---|
| 1683 | 6 , 131, /* - 173 */
|
|---|
| 1684 | 10 , 9, /* ® - 174 */
|
|---|
| 1685 | 7 , 84, /* ¯ - 175 */
|
|---|
| 1686 | 10 , 10, /* ° - 176 */
|
|---|
| 1687 | 8 , 23, /* ± - 177 */
|
|---|
| 1688 | 12 , 51, /* ² - 178 */
|
|---|
| 1689 | 12 , 70, /* ³ - 179 */
|
|---|
| 1690 | 7 , 85, /* Ž - 180 */
|
|---|
| 1691 | 10 , 11, /* µ - 181 */
|
|---|
| 1692 | 10 , 12, /* ¶ - 182 */
|
|---|
| 1693 | 10 , 13, /* · - 183 */
|
|---|
| 1694 | 7 , 86, /* ž - 184 */
|
|---|
| 1695 | 12 , 33, /* ¹ - 185 */
|
|---|
| 1696 | 14 , 124, /* º - 186 */
|
|---|
| 1697 | 8 , 26, /* » - 187 */
|
|---|
| 1698 | 12 , 21, /* Œ - 188 */
|
|---|
| 1699 | 12 , 25, /* œ - 189 */
|
|---|
| 1700 | 12 , 29, /* Ÿ - 190 */
|
|---|
| 1701 | 7 , 87, /* ¿ - 191 */
|
|---|
| 1702 | 14 , 2, /* À - 192 */
|
|---|
| 1703 | 14 , 2, /* Á - 193 */
|
|---|
| 1704 | 14 , 2, /* Â - 194 */
|
|---|
| 1705 | 14 , 2, /* Ã - 195 */
|
|---|
| 1706 | 14 , 2, /* Ä - 196 */
|
|---|
| 1707 | 14 , 2, /* Å - 197 */
|
|---|
| 1708 | 14 + 16 , 2, /* Æ - 198 */
|
|---|
| 1709 | 14 , 10, /* Ç - 199 */
|
|---|
| 1710 | 14 , 33, /* È - 200 */
|
|---|
| 1711 | 14 , 33, /* É - 201 */
|
|---|
| 1712 | 14 , 33, /* Ê - 202 */
|
|---|
| 1713 | 14 , 33, /* Ë - 203 */
|
|---|
| 1714 | 14 , 50, /* Ì - 204 */
|
|---|
| 1715 | 14 , 50, /* Í - 205 */
|
|---|
| 1716 | 14 , 50, /* Î - 206 */
|
|---|
| 1717 | 14 , 50, /* Ï - 207 */
|
|---|
| 1718 | 14 , 26, /* Ð - 208 */
|
|---|
| 1719 | 14 , 112, /* Ñ - 209 */
|
|---|
| 1720 | 14 , 124, /* Ò - 210 */
|
|---|
| 1721 | 14 , 124, /* Ó - 211 */
|
|---|
| 1722 | 14 , 124, /* Ô - 212 */
|
|---|
| 1723 | 14 , 124, /* Õ - 213 */
|
|---|
| 1724 | 14 , 124, /* Ö - 214 */
|
|---|
| 1725 | 8 , 28, /* × - 215 */
|
|---|
| 1726 | 14 , 124, /* Ø - 216 */
|
|---|
| 1727 | 14 , 159, /* Ù - 217 */
|
|---|
| 1728 | 14 , 159, /* Ú - 218 */
|
|---|
| 1729 | 14 , 159, /* Û - 219 */
|
|---|
| 1730 | 14 , 159, /* Ü - 220 */
|
|---|
| 1731 | 14 , 167, /* Ý - 221 */
|
|---|
| 1732 | 14 + 32 , 153, /* Þ - 222 */
|
|---|
| 1733 | 14 + 48 , 145, /* ß - 223 */
|
|---|
| 1734 | 14 , 2, /* à - 224 */
|
|---|
| 1735 | 14 , 2, /* á - 225 */
|
|---|
| 1736 | 14 , 2, /* â - 226 */
|
|---|
| 1737 | 14 , 2, /* ã - 227 */
|
|---|
| 1738 | 14 , 2, /* ä - 228 */
|
|---|
| 1739 | 14 , 2, /* å - 229 */
|
|---|
| 1740 | 14 + 16 , 2, /* æ - 230 */
|
|---|
| 1741 | 14 , 10, /* ç - 231 */
|
|---|
| 1742 | 14 , 33, /* è - 232 */
|
|---|
| 1743 | 14 , 33, /* é - 233 */
|
|---|
| 1744 | 14 , 33, /* ê - 234 */
|
|---|
| 1745 | 14 , 33, /* ë - 235 */
|
|---|
| 1746 | 14 , 50, /* ì - 236 */
|
|---|
| 1747 | 14 , 50, /* í - 237 */
|
|---|
| 1748 | 14 , 50, /* î - 238 */
|
|---|
| 1749 | 14 , 50, /* ï - 239 */
|
|---|
| 1750 | 14 , 26, /* ð - 240 */
|
|---|
| 1751 | 14 , 112, /* ñ - 241 */
|
|---|
| 1752 | 14 , 124, /* ò - 242 */
|
|---|
| 1753 | 14 , 124, /* ó - 243 */
|
|---|
| 1754 | 14 , 124, /* ô - 244 */
|
|---|
| 1755 | 14 , 124, /* õ - 245 */
|
|---|
| 1756 | 14 , 124, /* ö - 246 */
|
|---|
| 1757 | 8 , 29, /* ÷ - 247 */
|
|---|
| 1758 | 14 , 124, /* ø - 248 */
|
|---|
| 1759 | 14 , 159, /* ù - 249 */
|
|---|
| 1760 | 14 , 159, /* ú - 250 */
|
|---|
| 1761 | 14 , 159, /* û - 251 */
|
|---|
| 1762 | 14 , 159, /* ü - 252 */
|
|---|
| 1763 | 14 , 167, /* ý - 253 */
|
|---|
| 1764 | 14 + 32 , 153, /* þ - 254 */
|
|---|
| 1765 | 14 , 167 /* ÿ - 255 */ };
|
|---|
| 1766 |
|
|---|
| 1767 | static const unsigned char LCM_Unicode_LUT_2[] = { 33, 44, 145 };
|
|---|
| 1768 |
|
|---|
| 1769 | #define LCM_Diacritic_Start 131
|
|---|
| 1770 |
|
|---|
| 1771 | static const unsigned char LCM_Diacritic_LUT[] = {
|
|---|
| 1772 | 123, /* - 131 */
|
|---|
| 1773 | 2, /* - 132 */
|
|---|
| 1774 | 2, /*
|
|---|
| 1775 | - 133 */
|
|---|
| 1776 | 2, /* - 134 */
|
|---|
| 1777 | 2, /* - 135 */
|
|---|
| 1778 | 3, /* - 136 */
|
|---|
| 1779 | 2, /* - 137 */
|
|---|
| 1780 | 20, /* - 138 */
|
|---|
| 1781 | 2, /* - 139 */
|
|---|
| 1782 | 2, /* - 140 */
|
|---|
| 1783 | 2, /* - 141 */
|
|---|
| 1784 | 2, /* - 142 */
|
|---|
| 1785 | 2, /* - 143 */
|
|---|
| 1786 | 2, /* - 144 */
|
|---|
| 1787 | 2, /* - 145 */
|
|---|
| 1788 | 2, /* - 146 */
|
|---|
| 1789 | 2, /* - 147 */
|
|---|
| 1790 | 2, /* - 148 */
|
|---|
| 1791 | 2, /* - 149 */
|
|---|
| 1792 | 2, /* - 150 */
|
|---|
| 1793 | 2, /* - 151 */
|
|---|
| 1794 | 2, /* - 152 */
|
|---|
| 1795 | 2, /* - 153 */
|
|---|
| 1796 | 20, /* - 154 */
|
|---|
| 1797 | 2, /* - 155 */
|
|---|
| 1798 | 2, /* - 156 */
|
|---|
| 1799 | 2, /* - 157 */
|
|---|
| 1800 | 2, /* - 158 */
|
|---|
| 1801 | 19, /* - 159 */
|
|---|
| 1802 | 2, /* - 160 */
|
|---|
| 1803 | 2, /* ¡ - 161 */
|
|---|
| 1804 | 2, /* ¢ - 162 */
|
|---|
| 1805 | 2, /* £ - 163 */
|
|---|
| 1806 | 2, /* € - 164 */
|
|---|
| 1807 | 2, /* ¥ - 165 */
|
|---|
| 1808 | 2, /* Š - 166 */
|
|---|
| 1809 | 2, /* § - 167 */
|
|---|
| 1810 | 2, /* š - 168 */
|
|---|
| 1811 | 2, /* © - 169 */
|
|---|
| 1812 | 3, /* ª - 170 */
|
|---|
| 1813 | 2, /* « - 171 */
|
|---|
| 1814 | 2, /* ¬ - 172 */
|
|---|
| 1815 | 2, /* - 173 */
|
|---|
| 1816 | 2, /* ® - 174 */
|
|---|
| 1817 | 2, /* ¯ - 175 */
|
|---|
| 1818 | 2, /* ° - 176 */
|
|---|
| 1819 | 2, /* ± - 177 */
|
|---|
| 1820 | 2, /* ² - 178 */
|
|---|
| 1821 | 2, /* ³ - 179 */
|
|---|
| 1822 | 2, /* Ž - 180 */
|
|---|
| 1823 | 2, /* µ - 181 */
|
|---|
| 1824 | 2, /* ¶ - 182 */
|
|---|
| 1825 | 2, /* · - 183 */
|
|---|
| 1826 | 2, /* ž - 184 */
|
|---|
| 1827 | 2, /* ¹ - 185 */
|
|---|
| 1828 | 3, /* º - 186 */
|
|---|
| 1829 | 2, /* » - 187 */
|
|---|
| 1830 | 2, /* Œ - 188 */
|
|---|
| 1831 | 2, /* œ - 189 */
|
|---|
| 1832 | 2, /* Ÿ - 190 */
|
|---|
| 1833 | 2, /* ¿ - 191 */
|
|---|
| 1834 | 15, /* À - 192 */
|
|---|
| 1835 | 14, /* Á - 193 */
|
|---|
| 1836 | 18, /* Â - 194 */
|
|---|
| 1837 | 25, /* Ã - 195 */
|
|---|
| 1838 | 19, /* Ä - 196 */
|
|---|
| 1839 | 26, /* Å - 197 */
|
|---|
| 1840 | 2, /* Æ - 198 */
|
|---|
| 1841 | 28, /* Ç - 199 */
|
|---|
| 1842 | 15, /* È - 200 */
|
|---|
| 1843 | 14, /* É - 201 */
|
|---|
| 1844 | 18, /* Ê - 202 */
|
|---|
| 1845 | 19, /* Ë - 203 */
|
|---|
| 1846 | 15, /* Ì - 204 */
|
|---|
| 1847 | 14, /* Í - 205 */
|
|---|
| 1848 | 18, /* Î - 206 */
|
|---|
| 1849 | 19, /* Ï - 207 */
|
|---|
| 1850 | 104, /* Ð - 208 */
|
|---|
| 1851 | 25, /* Ñ - 209 */
|
|---|
| 1852 | 15, /* Ò - 210 */
|
|---|
| 1853 | 14, /* Ó - 211 */
|
|---|
| 1854 | 18, /* Ô - 212 */
|
|---|
| 1855 | 25, /* Õ - 213 */
|
|---|
| 1856 | 19, /* Ö - 214 */
|
|---|
| 1857 | 2, /* × - 215 */
|
|---|
| 1858 | 33, /* Ø - 216 */
|
|---|
| 1859 | 15, /* Ù - 217 */
|
|---|
| 1860 | 14, /* Ú - 218 */
|
|---|
| 1861 | 18, /* Û - 219 */
|
|---|
| 1862 | 19, /* Ü - 220 */
|
|---|
| 1863 | 14, /* Ý - 221 */
|
|---|
| 1864 | 2, /* Þ - 222 */
|
|---|
| 1865 | 2, /* ß - 223 */
|
|---|
| 1866 | 15, /* à - 224 */
|
|---|
| 1867 | 14, /* á - 225 */
|
|---|
| 1868 | 18, /* â - 226 */
|
|---|
| 1869 | 25, /* ã - 227 */
|
|---|
| 1870 | 19, /* ä - 228 */
|
|---|
| 1871 | 26, /* å - 229 */
|
|---|
| 1872 | 2, /* æ - 230 */
|
|---|
| 1873 | 28, /* ç - 231 */
|
|---|
| 1874 | 15, /* è - 232 */
|
|---|
| 1875 | 14, /* é - 233 */
|
|---|
| 1876 | 18, /* ê - 234 */
|
|---|
| 1877 | 19, /* ë - 235 */
|
|---|
| 1878 | 15, /* ì - 236 */
|
|---|
| 1879 | 14, /* í - 237 */
|
|---|
| 1880 | 18, /* î - 238 */
|
|---|
| 1881 | 19, /* ï - 239 */
|
|---|
| 1882 | 104, /* ð - 240 */
|
|---|
| 1883 | 25, /* ñ - 241 */
|
|---|
| 1884 | 15, /* ò - 242 */
|
|---|
| 1885 | 14, /* ó - 243 */
|
|---|
| 1886 | 18, /* ô - 244 */
|
|---|
| 1887 | 25, /* õ - 245 */
|
|---|
| 1888 | 19, /* ö - 246 */
|
|---|
| 1889 | 2, /* ÷ - 247 */
|
|---|
| 1890 | 33, /* ø - 248 */
|
|---|
| 1891 | 15, /* ù - 249 */
|
|---|
| 1892 | 14, /* ú - 250 */
|
|---|
| 1893 | 18, /* û - 251 */
|
|---|
| 1894 | 19, /* ü - 252 */
|
|---|
| 1895 | 14, /* ý - 253 */
|
|---|
| 1896 | 2, /* þ - 254 */
|
|---|
| 1897 | 19, /* ÿ - 255 */
|
|---|
| 1898 | } ;
|
|---|
| 1899 |
|
|---|
| 1900 | /******************************************************************************
|
|---|
| 1901 | * OLE2NLS_isPunctuation [INTERNAL]
|
|---|
| 1902 | */
|
|---|
| 1903 | static int OLE2NLS_isPunctuation(unsigned char c)
|
|---|
| 1904 | {
|
|---|
| 1905 | /* "punctuation character" in this context is a character which is
|
|---|
| 1906 | considered "less important" during word sort comparison.
|
|---|
| 1907 | See LCMapString implementation for the precise definition
|
|---|
| 1908 | of "less important". */
|
|---|
| 1909 |
|
|---|
| 1910 | return (LCM_Unicode_LUT[-2+2*c]==6);
|
|---|
| 1911 | }
|
|---|
| 1912 |
|
|---|
| 1913 | /******************************************************************************
|
|---|
| 1914 | * OLE2NLS_isNonSpacing [INTERNAL]
|
|---|
| 1915 | */
|
|---|
| 1916 | static int OLE2NLS_isNonSpacing(unsigned char c)
|
|---|
| 1917 | {
|
|---|
| 1918 | /* This function is used by LCMapStringA. Characters
|
|---|
| 1919 | for which it returns true are ignored when mapping a
|
|---|
| 1920 | string with NORM_IGNORENONSPACE */
|
|---|
| 1921 | return ((c==136) || (c==170) || (c==186));
|
|---|
| 1922 | }
|
|---|
| 1923 |
|
|---|
| 1924 | /******************************************************************************
|
|---|
| 1925 | * OLE2NLS_isSymbol [INTERNAL]
|
|---|
| 1926 | */
|
|---|
| 1927 | static int OLE2NLS_isSymbol(unsigned char c)
|
|---|
| 1928 | {
|
|---|
| 1929 | /* This function is used by LCMapStringA. Characters
|
|---|
| 1930 | for which it returns true are ignored when mapping a
|
|---|
| 1931 | string with NORM_IGNORESYMBOLS */
|
|---|
| 1932 | #ifdef __WIN32OS2__
|
|---|
| 1933 | return ( (c!=0) && !iswalpha((wint_t)c) );
|
|---|
| 1934 | #else
|
|---|
| 1935 | return ( (c!=0) && !IsCharAlphaNumericA(c) );
|
|---|
| 1936 | #endif
|
|---|
| 1937 | }
|
|---|
| 1938 |
|
|---|
| 1939 | /******************************************************************************
|
|---|
| 1940 | * identity [Internal]
|
|---|
| 1941 | */
|
|---|
| 1942 | #ifdef __WIN32OS2__
|
|---|
| 1943 | static int _Optlink identity(int c)
|
|---|
| 1944 | #else
|
|---|
| 1945 | static int identity(int c)
|
|---|
| 1946 | #endif
|
|---|
| 1947 | {
|
|---|
| 1948 | return c;
|
|---|
| 1949 | }
|
|---|
| 1950 |
|
|---|
| 1951 | /*************************************************************************
|
|---|
| 1952 | * LCMapStringA [KERNEL32.492]
|
|---|
| 1953 | *
|
|---|
| 1954 | * Convert a string, or generate a sort key from it.
|
|---|
| 1955 | *
|
|---|
| 1956 | * If (mapflags & LCMAP_SORTKEY), the function will generate
|
|---|
| 1957 | * a sort key for the source string. Else, it will convert it
|
|---|
| 1958 | * accordingly to the flags LCMAP_UPPERCASE, LCMAP_LOWERCASE,...
|
|---|
| 1959 | *
|
|---|
| 1960 | * RETURNS
|
|---|
| 1961 | * Error : 0.
|
|---|
| 1962 | * Success : length of the result string.
|
|---|
| 1963 | *
|
|---|
| 1964 | * NOTES
|
|---|
| 1965 | * If called with scrlen = -1, the function will compute the length
|
|---|
| 1966 | * of the 0-terminated string strsrc by itself.
|
|---|
| 1967 | *
|
|---|
| 1968 | * If called with dstlen = 0, returns the buffer length that
|
|---|
| 1969 | * would be required.
|
|---|
| 1970 | *
|
|---|
| 1971 | * NORM_IGNOREWIDTH means to compare ASCII and wide characters
|
|---|
| 1972 | * as if they are equal.
|
|---|
| 1973 | * In the only code page implemented so far, there may not be
|
|---|
| 1974 | * wide characters in strings passed to LCMapStringA,
|
|---|
| 1975 | * so there is nothing to be done for this flag.
|
|---|
| 1976 | */
|
|---|
| 1977 | #ifdef __WIN32OS2__
|
|---|
| 1978 | ODINFUNCTION6(INT, LCMapStringA,
|
|---|
| 1979 | LCID, lcid, /* [in] locale identifier created with MAKELCID;
|
|---|
| 1980 | LOCALE_SYSTEM_DEFAULT and LOCALE_USER_DEFAULT are
|
|---|
| 1981 | predefined values. */
|
|---|
| 1982 | DWORD, mapflags, /* [in] flags */
|
|---|
| 1983 | LPCSTR, srcstr, /* [in] source buffer */
|
|---|
| 1984 | INT, srclen, /* [in] source length */
|
|---|
| 1985 | LPSTR, dststr, /* [out] destination buffer */
|
|---|
| 1986 | INT, dstlen) /* [in] destination buffer length */
|
|---|
| 1987 | #else
|
|---|
| 1988 | INT WINAPI LCMapStringA(
|
|---|
| 1989 | LCID lcid, /* [in] locale identifier created with MAKELCID;
|
|---|
| 1990 | LOCALE_SYSTEM_DEFAULT and LOCALE_USER_DEFAULT are
|
|---|
| 1991 | predefined values. */
|
|---|
| 1992 | DWORD mapflags, /* [in] flags */
|
|---|
| 1993 | LPCSTR srcstr, /* [in] source buffer */
|
|---|
| 1994 | INT srclen, /* [in] source length */
|
|---|
| 1995 | LPSTR dststr, /* [out] destination buffer */
|
|---|
| 1996 | INT dstlen) /* [in] destination buffer length */
|
|---|
| 1997 | #endif
|
|---|
| 1998 | {
|
|---|
| 1999 | int i;
|
|---|
| 2000 |
|
|---|
| 2001 | TRACE("(0x%04lx,0x%08lx,%s,%d,%p,%d)\n",
|
|---|
| 2002 | lcid,mapflags,srcstr,srclen,dststr,dstlen);
|
|---|
| 2003 |
|
|---|
| 2004 | if ( ((dstlen!=0) && (dststr==NULL)) || (srcstr==NULL) )
|
|---|
| 2005 | {
|
|---|
| 2006 | ERR("(src=%s,dest=%s): Invalid NULL string\n", srcstr, dststr);
|
|---|
| 2007 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 2008 | return 0;
|
|---|
| 2009 | }
|
|---|
| 2010 | if (srclen == -1)
|
|---|
| 2011 | srclen = strlen(srcstr) + 1 ; /* (include final '\0') */
|
|---|
| 2012 |
|
|---|
| 2013 | #define LCMAPSTRINGA_SUPPORTED_FLAGS (LCMAP_UPPERCASE | \
|
|---|
| 2014 | LCMAP_LOWERCASE | \
|
|---|
| 2015 | LCMAP_SORTKEY | \
|
|---|
| 2016 | NORM_IGNORECASE | \
|
|---|
| 2017 | NORM_IGNORENONSPACE | \
|
|---|
| 2018 | SORT_STRINGSORT | \
|
|---|
| 2019 | NORM_IGNOREWIDTH | \
|
|---|
| 2020 | NORM_IGNOREKANATYPE)
|
|---|
| 2021 | /* FIXME: as long as we don't support Katakana nor Hiragana
|
|---|
| 2022 | * characters, we can support NORM_IGNOREKANATYPE
|
|---|
| 2023 | */
|
|---|
| 2024 | if (mapflags & ~LCMAPSTRINGA_SUPPORTED_FLAGS)
|
|---|
| 2025 | {
|
|---|
| 2026 | FIXME("(0x%04lx,0x%08lx,%p,%d,%p,%d): "
|
|---|
| 2027 | "unimplemented flags: 0x%08lx\n",
|
|---|
| 2028 | lcid,
|
|---|
| 2029 | mapflags,
|
|---|
| 2030 | srcstr,
|
|---|
| 2031 | srclen,
|
|---|
| 2032 | dststr,
|
|---|
| 2033 | dstlen,
|
|---|
| 2034 | mapflags & ~LCMAPSTRINGA_SUPPORTED_FLAGS
|
|---|
| 2035 | );
|
|---|
| 2036 | }
|
|---|
| 2037 |
|
|---|
| 2038 | if ( !(mapflags & LCMAP_SORTKEY) )
|
|---|
| 2039 | {
|
|---|
| 2040 | int i,j;
|
|---|
| 2041 | #ifdef __WIN32OS2__
|
|---|
| 2042 | int (* _Optlink f)(int) = identity;
|
|---|
| 2043 | #else
|
|---|
| 2044 | int (* f)(int) = identity;
|
|---|
| 2045 | #endif
|
|---|
| 2046 | int flag_ignorenonspace = mapflags & NORM_IGNORENONSPACE;
|
|---|
| 2047 | int flag_ignoresymbols = mapflags & NORM_IGNORESYMBOLS;
|
|---|
| 2048 |
|
|---|
| 2049 | if (flag_ignorenonspace || flag_ignoresymbols)
|
|---|
| 2050 | {
|
|---|
| 2051 | /* For some values of mapflags, the length of the resulting
|
|---|
| 2052 | string is not known at this point. Windows does map the string
|
|---|
| 2053 | and does not SetLastError ERROR_INSUFFICIENT_BUFFER in
|
|---|
| 2054 | these cases. */
|
|---|
| 2055 | if (dstlen==0)
|
|---|
| 2056 | {
|
|---|
| 2057 | /* Compute required length */
|
|---|
| 2058 | for (i=j=0; i < srclen; i++)
|
|---|
| 2059 | {
|
|---|
| 2060 | if ( !(flag_ignorenonspace && OLE2NLS_isNonSpacing(srcstr[i]))
|
|---|
| 2061 | && !(flag_ignoresymbols && OLE2NLS_isSymbol(srcstr[i])) )
|
|---|
| 2062 | j++;
|
|---|
| 2063 | }
|
|---|
| 2064 | return j;
|
|---|
| 2065 | }
|
|---|
| 2066 | }
|
|---|
| 2067 | else
|
|---|
| 2068 | {
|
|---|
| 2069 | if (dstlen==0)
|
|---|
| 2070 | return srclen;
|
|---|
| 2071 | if (dstlen<srclen)
|
|---|
| 2072 | {
|
|---|
| 2073 | SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|---|
| 2074 | return 0;
|
|---|
| 2075 | }
|
|---|
| 2076 | }
|
|---|
| 2077 | if (mapflags & LCMAP_UPPERCASE)
|
|---|
| 2078 | f = toupper;
|
|---|
| 2079 | else if (mapflags & LCMAP_LOWERCASE)
|
|---|
| 2080 | f = tolower;
|
|---|
| 2081 | /* FIXME: NORM_IGNORENONSPACE requires another conversion */
|
|---|
| 2082 | for (i=j=0; (i<srclen) && (j<dstlen) ; i++)
|
|---|
| 2083 | {
|
|---|
| 2084 | if ( !(flag_ignorenonspace && OLE2NLS_isNonSpacing(srcstr[i]))
|
|---|
| 2085 | && !(flag_ignoresymbols && OLE2NLS_isSymbol(srcstr[i])) )
|
|---|
| 2086 | {
|
|---|
| 2087 | dststr[j] = (CHAR) f(srcstr[i]);
|
|---|
| 2088 | j++;
|
|---|
| 2089 | }
|
|---|
| 2090 | }
|
|---|
| 2091 | return j;
|
|---|
| 2092 | }
|
|---|
| 2093 |
|
|---|
| 2094 | /* FIXME: This function completely ignores the "lcid" parameter. */
|
|---|
| 2095 | /* else ... (mapflags & LCMAP_SORTKEY) */
|
|---|
| 2096 | {
|
|---|
| 2097 | int unicode_len=0;
|
|---|
| 2098 | int case_len=0;
|
|---|
| 2099 | int diacritic_len=0;
|
|---|
| 2100 | int delayed_punctuation_len=0;
|
|---|
| 2101 | char *case_component;
|
|---|
| 2102 | char *diacritic_component;
|
|---|
| 2103 | char *delayed_punctuation_component;
|
|---|
| 2104 | int room,count;
|
|---|
| 2105 | int flag_stringsort = mapflags & SORT_STRINGSORT;
|
|---|
| 2106 |
|
|---|
| 2107 | /* compute how much room we will need */
|
|---|
| 2108 | for (i=0;i<srclen;i++)
|
|---|
| 2109 | {
|
|---|
| 2110 | int ofs;
|
|---|
| 2111 | unsigned char source_char = srcstr[i];
|
|---|
| 2112 | if (source_char!='\0')
|
|---|
| 2113 | {
|
|---|
| 2114 | if (flag_stringsort || !OLE2NLS_isPunctuation(source_char))
|
|---|
| 2115 | {
|
|---|
| 2116 | unicode_len++;
|
|---|
| 2117 | if ( LCM_Unicode_LUT[-2+2*source_char] & ~15 )
|
|---|
| 2118 | unicode_len++; /* double letter */
|
|---|
| 2119 | }
|
|---|
| 2120 | else
|
|---|
| 2121 | {
|
|---|
| 2122 | delayed_punctuation_len++;
|
|---|
| 2123 | }
|
|---|
| 2124 | }
|
|---|
| 2125 |
|
|---|
| 2126 | if (isupper(source_char))
|
|---|
| 2127 | case_len=unicode_len;
|
|---|
| 2128 |
|
|---|
| 2129 | ofs = source_char - LCM_Diacritic_Start;
|
|---|
| 2130 | if ((ofs>=0) && (LCM_Diacritic_LUT[ofs]!=2))
|
|---|
| 2131 | diacritic_len=unicode_len;
|
|---|
| 2132 | }
|
|---|
| 2133 |
|
|---|
| 2134 | if (mapflags & NORM_IGNORECASE)
|
|---|
| 2135 | case_len=0;
|
|---|
| 2136 | if (mapflags & NORM_IGNORENONSPACE)
|
|---|
| 2137 | diacritic_len=0;
|
|---|
| 2138 |
|
|---|
| 2139 | room = 2 * unicode_len /* "unicode" component */
|
|---|
| 2140 | + diacritic_len /* "diacritic" component */
|
|---|
| 2141 | + case_len /* "case" component */
|
|---|
| 2142 | + 4 * delayed_punctuation_len /* punctuation in word sort mode */
|
|---|
| 2143 | + 4 /* four '\1' separators */
|
|---|
| 2144 | + 1 ; /* terminal '\0' */
|
|---|
| 2145 | if (dstlen==0)
|
|---|
| 2146 | return room;
|
|---|
| 2147 | else if (dstlen<room)
|
|---|
| 2148 | {
|
|---|
| 2149 | SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|---|
| 2150 | return 0;
|
|---|
| 2151 | }
|
|---|
| 2152 | #if 0
|
|---|
| 2153 | /*FIXME the Pointercheck should not be nessesary */
|
|---|
| 2154 | if (IsBadWritePtr (dststr,room))
|
|---|
| 2155 | { ERR("bad destination buffer (dststr) : %p,%d\n",dststr,dstlen);
|
|---|
| 2156 | SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|---|
| 2157 | return 0;
|
|---|
| 2158 | }
|
|---|
| 2159 | #endif
|
|---|
| 2160 | /* locate each component, write separators */
|
|---|
| 2161 | diacritic_component = dststr + 2*unicode_len ;
|
|---|
| 2162 | *diacritic_component++ = '\1';
|
|---|
| 2163 | case_component = diacritic_component + diacritic_len ;
|
|---|
| 2164 | *case_component++ = '\1';
|
|---|
| 2165 | delayed_punctuation_component = case_component + case_len ;
|
|---|
| 2166 | *delayed_punctuation_component++ = '\1';
|
|---|
| 2167 | *delayed_punctuation_component++ = '\1';
|
|---|
| 2168 |
|
|---|
| 2169 | /* read source string char by char, write
|
|---|
| 2170 | corresponding weight in each component. */
|
|---|
| 2171 | for (i=0,count=0;i<srclen;i++)
|
|---|
| 2172 | {
|
|---|
| 2173 | unsigned char source_char=srcstr[i];
|
|---|
| 2174 | if (source_char!='\0')
|
|---|
| 2175 | {
|
|---|
| 2176 | int type,longcode;
|
|---|
| 2177 | type = LCM_Unicode_LUT[-2+2*source_char];
|
|---|
| 2178 | longcode = type >> 4;
|
|---|
| 2179 | type &= 15;
|
|---|
| 2180 | if (!flag_stringsort && OLE2NLS_isPunctuation(source_char))
|
|---|
| 2181 | {
|
|---|
| 2182 | WORD encrypted_location = (1<<15) + 7 + 4*count;
|
|---|
| 2183 | *delayed_punctuation_component++ = (unsigned char) (encrypted_location>>8);
|
|---|
| 2184 | *delayed_punctuation_component++ = (unsigned char) (encrypted_location&255);
|
|---|
| 2185 | /* big-endian is used here because it lets string comparison be
|
|---|
| 2186 | compatible with numerical comparison */
|
|---|
| 2187 |
|
|---|
| 2188 | *delayed_punctuation_component++ = type;
|
|---|
| 2189 | *delayed_punctuation_component++ = LCM_Unicode_LUT[-1+2*source_char];
|
|---|
| 2190 | /* assumption : a punctuation character is never a
|
|---|
| 2191 | double or accented letter */
|
|---|
| 2192 | }
|
|---|
| 2193 | else
|
|---|
| 2194 | {
|
|---|
| 2195 | dststr[2*count] = type;
|
|---|
| 2196 | dststr[2*count+1] = LCM_Unicode_LUT[-1+2*source_char];
|
|---|
| 2197 | if (longcode)
|
|---|
| 2198 | {
|
|---|
| 2199 | if (count<case_len)
|
|---|
| 2200 | case_component[count] = ( isupper(source_char) ? 18 : 2 ) ;
|
|---|
| 2201 | if (count<diacritic_len)
|
|---|
| 2202 | diacritic_component[count] = 2; /* assumption: a double letter
|
|---|
| 2203 | is never accented */
|
|---|
| 2204 | count++;
|
|---|
| 2205 |
|
|---|
| 2206 | dststr[2*count] = type;
|
|---|
| 2207 | dststr[2*count+1] = *(LCM_Unicode_LUT_2 - 1 + longcode);
|
|---|
| 2208 | /* 16 in the first column of LCM_Unicode_LUT --> longcode = 1
|
|---|
| 2209 | 32 in the first column of LCM_Unicode_LUT --> longcode = 2
|
|---|
| 2210 | 48 in the first column of LCM_Unicode_LUT --> longcode = 3 */
|
|---|
| 2211 | }
|
|---|
| 2212 |
|
|---|
| 2213 | if (count<case_len)
|
|---|
| 2214 | case_component[count] = ( isupper(source_char) ? 18 : 2 ) ;
|
|---|
| 2215 | if (count<diacritic_len)
|
|---|
| 2216 | {
|
|---|
| 2217 | int ofs = source_char - LCM_Diacritic_Start;
|
|---|
| 2218 | diacritic_component[count] = (ofs>=0 ? LCM_Diacritic_LUT[ofs] : 2);
|
|---|
| 2219 | }
|
|---|
| 2220 | count++;
|
|---|
| 2221 | }
|
|---|
| 2222 | }
|
|---|
| 2223 | }
|
|---|
| 2224 | dststr[room-1] = '\0';
|
|---|
| 2225 | return room;
|
|---|
| 2226 | }
|
|---|
| 2227 | }
|
|---|
| 2228 |
|
|---|
| 2229 | /*************************************************************************
|
|---|
| 2230 | * LCMapStringW [KERNEL32.493]
|
|---|
| 2231 | *
|
|---|
| 2232 | * Convert a string, or generate a sort key from it.
|
|---|
| 2233 | *
|
|---|
| 2234 | * NOTE
|
|---|
| 2235 | *
|
|---|
| 2236 | * See LCMapStringA for documentation
|
|---|
| 2237 | */
|
|---|
| 2238 | #ifdef __WIN32OS2__
|
|---|
| 2239 | ODINFUNCTION6(INT, LCMapStringW,
|
|---|
| 2240 | LCID, lcid,DWORD, mapflags,LPCWSTR, srcstr,INT, srclen,LPWSTR, dststr,
|
|---|
| 2241 | INT, dstlen)
|
|---|
| 2242 | #else
|
|---|
| 2243 | INT WINAPI LCMapStringW(
|
|---|
| 2244 | LCID lcid,DWORD mapflags,LPCWSTR srcstr,INT srclen,LPWSTR dststr,
|
|---|
| 2245 | INT dstlen)
|
|---|
| 2246 | #endif
|
|---|
| 2247 | {
|
|---|
| 2248 | int i;
|
|---|
| 2249 |
|
|---|
| 2250 | TRACE("(0x%04lx,0x%08lx,%p,%d,%p,%d)\n",
|
|---|
| 2251 | lcid, mapflags, srcstr, srclen, dststr, dstlen);
|
|---|
| 2252 |
|
|---|
| 2253 | if ( ((dstlen!=0) && (dststr==NULL)) || (srcstr==NULL) )
|
|---|
| 2254 | {
|
|---|
| 2255 | ERR("(src=%p,dst=%p): Invalid NULL string\n", srcstr, dststr);
|
|---|
| 2256 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 2257 | return 0;
|
|---|
| 2258 | }
|
|---|
| 2259 | if (srclen==-1)
|
|---|
| 2260 | srclen = strlenW(srcstr)+1;
|
|---|
| 2261 |
|
|---|
| 2262 | /* FIXME: Both this function and it's companion LCMapStringA()
|
|---|
| 2263 | * completely ignore the "lcid" parameter. In place of the "lcid"
|
|---|
| 2264 | * parameter the application must set the "LC_COLLATE" or "LC_ALL"
|
|---|
| 2265 | * environment variable prior to invoking this function. */
|
|---|
| 2266 | if (mapflags & LCMAP_SORTKEY)
|
|---|
| 2267 | {
|
|---|
| 2268 | /* Possible values of LC_COLLATE. */
|
|---|
| 2269 | char *lc_collate_default = 0; /* value prior to this function */
|
|---|
| 2270 | char *lc_collate_env = 0; /* value retrieved from the environment */
|
|---|
| 2271 |
|
|---|
| 2272 | /* General purpose index into strings of any type. */
|
|---|
| 2273 | int str_idx = 0;
|
|---|
| 2274 |
|
|---|
| 2275 | /* Lengths of various strings where the length is measured in
|
|---|
| 2276 | * wide characters for wide character strings and in bytes for
|
|---|
| 2277 | * native strings. The lengths include the NULL terminator. */
|
|---|
| 2278 | size_t returned_len = 0;
|
|---|
| 2279 | size_t src_native_len = 0;
|
|---|
| 2280 | size_t dst_native_len = 0;
|
|---|
| 2281 | size_t dststr_libc_len = 0;
|
|---|
| 2282 |
|
|---|
| 2283 | /* Native (character set determined by locale) versions of the
|
|---|
| 2284 | * strings source and destination strings. */
|
|---|
| 2285 | LPSTR src_native = 0;
|
|---|
| 2286 | LPSTR dst_native = 0;
|
|---|
| 2287 |
|
|---|
| 2288 | /* Version of the source and destination strings using the
|
|---|
| 2289 | * "wchar_t" Unicode data type needed by various libc functions. */
|
|---|
| 2290 | wchar_t *srcstr_libc = 0;
|
|---|
| 2291 | wchar_t *dststr_libc = 0;
|
|---|
| 2292 |
|
|---|
| 2293 | if(!(srcstr_libc = (wchar_t *)HeapAlloc(GetProcessHeap(), 0,
|
|---|
| 2294 | srclen * sizeof(wchar_t))))
|
|---|
| 2295 | {
|
|---|
| 2296 | ERR("Unable to allocate %d bytes for srcstr_libc\n",
|
|---|
| 2297 | srclen * sizeof(wchar_t));
|
|---|
| 2298 | SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|---|
| 2299 | return 0;
|
|---|
| 2300 | }
|
|---|
| 2301 |
|
|---|
| 2302 | /* Convert source string to a libc Unicode string. */
|
|---|
| 2303 | for(str_idx = 0; str_idx < srclen; str_idx++)
|
|---|
| 2304 | {
|
|---|
| 2305 | srcstr_libc[str_idx] = srcstr[str_idx];
|
|---|
| 2306 | }
|
|---|
| 2307 |
|
|---|
| 2308 | /* src_native should contain at most 3 bytes for each
|
|---|
| 2309 | * multibyte characters in the original srcstr string. */
|
|---|
| 2310 | src_native_len = 3 * srclen;
|
|---|
| 2311 | if(!(src_native = (LPSTR)HeapAlloc(GetProcessHeap(), 0,
|
|---|
| 2312 | src_native_len)))
|
|---|
| 2313 | {
|
|---|
| 2314 | ERR("Unable to allocate %d bytes for src_native\n", src_native_len);
|
|---|
| 2315 | SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|---|
| 2316 | if(srcstr_libc) HeapFree(GetProcessHeap(), 0, srcstr_libc);
|
|---|
| 2317 | return 0;
|
|---|
| 2318 | }
|
|---|
| 2319 |
|
|---|
| 2320 | /* FIXME: Prior to to setting the LC_COLLATE locale category the
|
|---|
| 2321 | * current value is backed up so it can be restored after the
|
|---|
| 2322 | * last LC_COLLATE sensitive function returns.
|
|---|
| 2323 | *
|
|---|
| 2324 | * Even though the locale is adjusted for a minimum amount of
|
|---|
| 2325 | * time a race condition exists where other threads may be
|
|---|
| 2326 | * affected if they invoke LC_COLLATE sensitive functions. One
|
|---|
| 2327 | * possible solution is to wrap all LC_COLLATE sensitive Wine
|
|---|
| 2328 | * functions, like LCMapStringW(), in a mutex.
|
|---|
| 2329 | *
|
|---|
| 2330 | * Another enhancement to the following would be to set the
|
|---|
| 2331 | * LC_COLLATE locale category as a function of the "lcid"
|
|---|
| 2332 | * parameter instead of the "LC_COLLATE" environment variable. */
|
|---|
| 2333 | if(!(lc_collate_default = setlocale(LC_COLLATE, NULL)))
|
|---|
| 2334 | {
|
|---|
| 2335 | ERR("Unable to query the LC_COLLATE catagory\n");
|
|---|
| 2336 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 2337 | if(srcstr_libc) HeapFree(GetProcessHeap(), 0, srcstr_libc);
|
|---|
| 2338 | if(src_native) HeapFree(GetProcessHeap(), 0, src_native);
|
|---|
| 2339 | return 0;
|
|---|
| 2340 | }
|
|---|
| 2341 |
|
|---|
| 2342 | if(!(lc_collate_env = setlocale(LC_COLLATE, "")))
|
|---|
| 2343 | {
|
|---|
| 2344 | ERR("Unable to inherit the LC_COLLATE locale category from the "
|
|---|
| 2345 | "environment. The \"LC_COLLATE\" environment variable is "
|
|---|
| 2346 | "\"%s\".\n", getenv("LC_COLLATE") ?
|
|---|
| 2347 | getenv("LC_COLLATE") : "<unset>");
|
|---|
| 2348 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 2349 | if(srcstr_libc) HeapFree(GetProcessHeap(), 0, srcstr_libc);
|
|---|
| 2350 | if(src_native) HeapFree(GetProcessHeap(), 0, src_native);
|
|---|
| 2351 | return 0;
|
|---|
| 2352 | }
|
|---|
| 2353 |
|
|---|
| 2354 | TRACE("lc_collate_default = %s\n", lc_collate_default);
|
|---|
| 2355 | TRACE("lc_collate_env = %s\n", lc_collate_env);
|
|---|
| 2356 |
|
|---|
| 2357 | /* Convert the libc Unicode string to a native multibyte character
|
|---|
| 2358 | * string. */
|
|---|
| 2359 | returned_len = wcstombs(src_native, srcstr_libc, src_native_len) + 1;
|
|---|
| 2360 | if(returned_len == 0)
|
|---|
| 2361 | {
|
|---|
| 2362 | LPSTR srcstr_ascii = (LPSTR)HEAP_strdupWtoA(GetProcessHeap(),
|
|---|
| 2363 | 0, srcstr);
|
|---|
| 2364 | ERR("wcstombs failed. The string specified (%s) may contains an "
|
|---|
| 2365 | "invalid character.\n", srcstr_ascii);
|
|---|
| 2366 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 2367 | if(srcstr_ascii) HeapFree(GetProcessHeap(), 0, srcstr_ascii);
|
|---|
| 2368 | if(srcstr_libc) HeapFree(GetProcessHeap(), 0, srcstr_libc);
|
|---|
| 2369 | if(src_native) HeapFree(GetProcessHeap(), 0, src_native);
|
|---|
| 2370 | setlocale(LC_COLLATE, lc_collate_default);
|
|---|
| 2371 | return 0;
|
|---|
| 2372 | }
|
|---|
| 2373 | else if(returned_len > src_native_len)
|
|---|
| 2374 | {
|
|---|
| 2375 | src_native[src_native_len - 1] = 0;
|
|---|
| 2376 | ERR("wcstombs returned a string (%s) that was longer (%d bytes) "
|
|---|
| 2377 | "than expected (%d bytes).\n", src_native, returned_len,
|
|---|
| 2378 | dst_native_len);
|
|---|
| 2379 |
|
|---|
| 2380 | /* Since this is an internal error I'm not sure what the correct
|
|---|
| 2381 | * error code is. */
|
|---|
| 2382 | SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|---|
| 2383 |
|
|---|
| 2384 | if(srcstr_libc) HeapFree(GetProcessHeap(), 0, srcstr_libc);
|
|---|
| 2385 | if(src_native) HeapFree(GetProcessHeap(), 0, src_native);
|
|---|
| 2386 | setlocale(LC_COLLATE, lc_collate_default);
|
|---|
| 2387 | return 0;
|
|---|
| 2388 | }
|
|---|
| 2389 | src_native_len = returned_len;
|
|---|
| 2390 |
|
|---|
| 2391 | TRACE("src_native = %s src_native_len = %d\n",
|
|---|
| 2392 | src_native, src_native_len);
|
|---|
| 2393 |
|
|---|
| 2394 | /* dst_native seems to contain at most 4 bytes for each byte in
|
|---|
| 2395 | * the original src_native string. Change if need be since this
|
|---|
| 2396 | * isn't documented by the strxfrm() man page. */
|
|---|
| 2397 | dst_native_len = 4 * src_native_len;
|
|---|
| 2398 | if(!(dst_native = (LPSTR)HeapAlloc(GetProcessHeap(), 0, dst_native_len)))
|
|---|
| 2399 | {
|
|---|
| 2400 | ERR("Unable to allocate %d bytes for dst_native\n", dst_native_len);
|
|---|
| 2401 | SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|---|
| 2402 | if(srcstr_libc) HeapFree(GetProcessHeap(), 0, srcstr_libc);
|
|---|
| 2403 | if(src_native) HeapFree(GetProcessHeap(), 0, src_native);
|
|---|
| 2404 | setlocale(LC_COLLATE, lc_collate_default);
|
|---|
| 2405 | return 0;
|
|---|
| 2406 | }
|
|---|
| 2407 |
|
|---|
| 2408 | /* The actual translation is done by the following call to
|
|---|
| 2409 | * strxfrm(). The surrounding code could have been simplified
|
|---|
| 2410 | * by calling wcsxfrm() instead except that wcsxfrm() is not
|
|---|
| 2411 | * available on older Linux systems (RedHat 4.1 with
|
|---|
| 2412 | * libc-5.3.12-17).
|
|---|
| 2413 | *
|
|---|
| 2414 | * Also, it is possible that the translation could be done by
|
|---|
| 2415 | * various tables as it is done in LCMapStringA(). However, I'm
|
|---|
| 2416 | * not sure what those tables are. */
|
|---|
| 2417 | returned_len = strxfrm(dst_native, src_native, dst_native_len) + 1;
|
|---|
| 2418 |
|
|---|
| 2419 | if(returned_len > dst_native_len)
|
|---|
| 2420 | {
|
|---|
| 2421 | dst_native[dst_native_len - 1] = 0;
|
|---|
| 2422 | ERR("strxfrm returned a string (%s) that was longer (%d bytes) "
|
|---|
| 2423 | "than expected (%d bytes).\n", dst_native, returned_len,
|
|---|
| 2424 | dst_native_len);
|
|---|
| 2425 |
|
|---|
| 2426 | /* Since this is an internal error I'm not sure what the correct
|
|---|
| 2427 | * error code is. */
|
|---|
| 2428 | SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|---|
| 2429 |
|
|---|
| 2430 | if(srcstr_libc) HeapFree(GetProcessHeap(), 0, srcstr_libc);
|
|---|
| 2431 | if(src_native) HeapFree(GetProcessHeap(), 0, src_native);
|
|---|
| 2432 | if(dst_native) HeapFree(GetProcessHeap(), 0, dst_native);
|
|---|
| 2433 | setlocale(LC_COLLATE, lc_collate_default);
|
|---|
| 2434 | return 0;
|
|---|
| 2435 | }
|
|---|
| 2436 | dst_native_len = returned_len;
|
|---|
| 2437 |
|
|---|
| 2438 | TRACE("dst_native = %s dst_native_len = %d\n",
|
|---|
| 2439 | dst_native, dst_native_len);
|
|---|
| 2440 |
|
|---|
| 2441 | dststr_libc_len = dst_native_len;
|
|---|
| 2442 | if(!(dststr_libc = (wchar_t *)HeapAlloc(GetProcessHeap(), 0,
|
|---|
| 2443 | dststr_libc_len * sizeof(wchar_t))))
|
|---|
| 2444 | {
|
|---|
| 2445 | ERR("Unable to allocate %d bytes for dststr_libc\n",
|
|---|
| 2446 | dststr_libc_len * sizeof(wchar_t));
|
|---|
| 2447 | SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|---|
| 2448 | if(srcstr_libc) HeapFree(GetProcessHeap(), 0, srcstr_libc);
|
|---|
| 2449 | if(src_native) HeapFree(GetProcessHeap(), 0, src_native);
|
|---|
| 2450 | if(dst_native) HeapFree(GetProcessHeap(), 0, dst_native);
|
|---|
| 2451 | setlocale(LC_COLLATE, lc_collate_default);
|
|---|
| 2452 | return 0;
|
|---|
| 2453 | }
|
|---|
| 2454 |
|
|---|
| 2455 | /* Convert the native multibyte string to a libc Unicode string. */
|
|---|
| 2456 | returned_len = mbstowcs(dststr_libc, dst_native, dst_native_len) + 1;
|
|---|
| 2457 |
|
|---|
| 2458 | /* Restore LC_COLLATE now that the last LC_COLLATE sensitive
|
|---|
| 2459 | * function has returned. */
|
|---|
| 2460 | setlocale(LC_COLLATE, lc_collate_default);
|
|---|
| 2461 |
|
|---|
| 2462 | if(returned_len == 0)
|
|---|
| 2463 | {
|
|---|
| 2464 | ERR("mbstowcs failed. The native version of the translated string "
|
|---|
| 2465 | "(%s) may contain an invalid character.\n", dst_native);
|
|---|
| 2466 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 2467 | if(srcstr_libc) HeapFree(GetProcessHeap(), 0, srcstr_libc);
|
|---|
| 2468 | if(src_native) HeapFree(GetProcessHeap(), 0, src_native);
|
|---|
| 2469 | if(dst_native) HeapFree(GetProcessHeap(), 0, dst_native);
|
|---|
| 2470 | if(dststr_libc) HeapFree(GetProcessHeap(), 0, dststr_libc);
|
|---|
| 2471 | return 0;
|
|---|
| 2472 | }
|
|---|
| 2473 | if(dstlen)
|
|---|
| 2474 | {
|
|---|
| 2475 | if(returned_len > dstlen)
|
|---|
| 2476 | {
|
|---|
| 2477 | ERR("mbstowcs returned a string that was longer (%d chars) "
|
|---|
| 2478 | "than the buffer provided (%d chars).\n", returned_len,
|
|---|
| 2479 | dstlen);
|
|---|
| 2480 | SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|---|
| 2481 | if(srcstr_libc) HeapFree(GetProcessHeap(), 0, srcstr_libc);
|
|---|
| 2482 | if(src_native) HeapFree(GetProcessHeap(), 0, src_native);
|
|---|
| 2483 | if(dst_native) HeapFree(GetProcessHeap(), 0, dst_native);
|
|---|
| 2484 | if(dststr_libc) HeapFree(GetProcessHeap(), 0, dststr_libc);
|
|---|
| 2485 | return 0;
|
|---|
| 2486 | }
|
|---|
| 2487 | dstlen = returned_len;
|
|---|
| 2488 |
|
|---|
| 2489 | /* Convert a libc Unicode string to the destination string. */
|
|---|
| 2490 | for(str_idx = 0; str_idx < dstlen; str_idx++)
|
|---|
| 2491 | {
|
|---|
| 2492 | dststr[str_idx] = dststr_libc[str_idx];
|
|---|
| 2493 | }
|
|---|
| 2494 | TRACE("1st 4 int sized chunks of dststr = %x %x %x %x\n",
|
|---|
| 2495 | *(((int *)dststr) + 0),
|
|---|
| 2496 | *(((int *)dststr) + 1),
|
|---|
| 2497 | *(((int *)dststr) + 2),
|
|---|
| 2498 | *(((int *)dststr) + 3));
|
|---|
| 2499 | }
|
|---|
| 2500 | else
|
|---|
| 2501 | {
|
|---|
| 2502 | dstlen = returned_len;
|
|---|
| 2503 | }
|
|---|
| 2504 | TRACE("dstlen (return) = %d\n", dstlen);
|
|---|
| 2505 | if(srcstr_libc) HeapFree(GetProcessHeap(), 0, srcstr_libc);
|
|---|
| 2506 | if(src_native) HeapFree(GetProcessHeap(), 0, src_native);
|
|---|
| 2507 | if(dst_native) HeapFree(GetProcessHeap(), 0, dst_native);
|
|---|
| 2508 | if(dststr_libc) HeapFree(GetProcessHeap(), 0, dststr_libc);
|
|---|
| 2509 | return dstlen;
|
|---|
| 2510 | }
|
|---|
| 2511 | else
|
|---|
| 2512 | {
|
|---|
| 2513 | #ifdef __WIN32OS2__
|
|---|
| 2514 | int (* _Optlink f)(int) = identity;
|
|---|
| 2515 | #else
|
|---|
| 2516 | int (*f)(int)=identity;
|
|---|
| 2517 | #endif
|
|---|
| 2518 |
|
|---|
| 2519 | if (dstlen==0)
|
|---|
| 2520 | return srclen;
|
|---|
| 2521 | if (dstlen<srclen)
|
|---|
| 2522 | {
|
|---|
| 2523 | SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|---|
| 2524 | return 0;
|
|---|
| 2525 | }
|
|---|
| 2526 |
|
|---|
| 2527 | if (mapflags & LCMAP_UPPERCASE)
|
|---|
| 2528 | f = toupper;
|
|---|
| 2529 | else if (mapflags & LCMAP_LOWERCASE)
|
|---|
| 2530 | f = tolower;
|
|---|
| 2531 | for (i=0; i < srclen; i++)
|
|---|
| 2532 | dststr[i] = (WCHAR) f(srcstr[i]);
|
|---|
| 2533 | return srclen;
|
|---|
| 2534 | }
|
|---|
| 2535 | }
|
|---|
| 2536 |
|
|---|
| 2537 |
|
|---|
| 2538 | /***********************************************************************
|
|---|
| 2539 | * OLE2NLS_EstimateMappingLength
|
|---|
| 2540 | *
|
|---|
| 2541 | * Estimates the number of characters required to hold the string
|
|---|
| 2542 | * computed by LCMapStringA.
|
|---|
| 2543 | *
|
|---|
| 2544 | * The size is always over-estimated, with a fixed limit on the
|
|---|
| 2545 | * amount of estimation error.
|
|---|
| 2546 | *
|
|---|
| 2547 | * Note that len == -1 is not permitted.
|
|---|
| 2548 | */
|
|---|
| 2549 | static inline int OLE2NLS_EstimateMappingLength(LCID lcid, DWORD dwMapFlags,
|
|---|
| 2550 | LPCSTR str, DWORD len)
|
|---|
| 2551 | {
|
|---|
| 2552 | /* Estimate only for small strings to keep the estimation error from
|
|---|
| 2553 | * becoming too large. */
|
|---|
| 2554 | if (len < 128) return len * 8 + 5;
|
|---|
| 2555 | else return LCMapStringA(lcid, dwMapFlags, str, len, NULL, 0);
|
|---|
| 2556 | }
|
|---|
| 2557 |
|
|---|
| 2558 | /******************************************************************************
|
|---|
| 2559 | * CompareStringA [KERNEL32.143]
|
|---|
| 2560 | * Compares two strings using locale
|
|---|
| 2561 | *
|
|---|
| 2562 | * RETURNS
|
|---|
| 2563 | *
|
|---|
| 2564 | * success: CSTR_LESS_THAN, CSTR_EQUAL, CSTR_GREATER_THAN
|
|---|
| 2565 | * failure: 0
|
|---|
| 2566 | *
|
|---|
| 2567 | * NOTES
|
|---|
| 2568 | *
|
|---|
| 2569 | * Defaults to a word sort, but uses a string sort if
|
|---|
| 2570 | * SORT_STRINGSORT is set.
|
|---|
| 2571 | * Calls SetLastError for ERROR_INVALID_FLAGS, ERROR_INVALID_PARAMETER.
|
|---|
| 2572 | *
|
|---|
| 2573 | * BUGS
|
|---|
| 2574 | *
|
|---|
| 2575 | * This implementation ignores the locale
|
|---|
| 2576 | *
|
|---|
| 2577 | * FIXME
|
|---|
| 2578 | *
|
|---|
| 2579 | * Quite inefficient.
|
|---|
| 2580 | */
|
|---|
| 2581 | UINT WINAPI CompareStringA(
|
|---|
| 2582 | DWORD lcid, /* [in] locale ID */
|
|---|
| 2583 | DWORD fdwStyle, /* [in] comparison-style options */
|
|---|
| 2584 | LPCSTR s1, /* [in] first string */
|
|---|
| 2585 | DWORD l1, /* [in] length of first string */
|
|---|
| 2586 | LPCSTR s2, /* [in] second string */
|
|---|
| 2587 | DWORD l2) /* [in] length of second string */
|
|---|
| 2588 | {
|
|---|
| 2589 | int mapstring_flags;
|
|---|
| 2590 | int len1,len2;
|
|---|
| 2591 | int result;
|
|---|
| 2592 | LPSTR sk1,sk2;
|
|---|
| 2593 | TRACE("%s and %s\n",
|
|---|
| 2594 | debugstr_a (s1), debugstr_a (s2));
|
|---|
| 2595 |
|
|---|
| 2596 | if ( (s1==NULL) || (s2==NULL) )
|
|---|
| 2597 | {
|
|---|
| 2598 | ERR("(s1=%s,s2=%s): Invalid NULL string\n", s1, s2);
|
|---|
| 2599 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 2600 | return 0;
|
|---|
| 2601 | }
|
|---|
| 2602 |
|
|---|
| 2603 | if(fdwStyle & NORM_IGNORESYMBOLS)
|
|---|
| 2604 | FIXME("IGNORESYMBOLS not supported\n");
|
|---|
| 2605 |
|
|---|
| 2606 | if (l1 == -1) l1 = strlen(s1);
|
|---|
| 2607 | if (l2 == -1) l2 = strlen(s2);
|
|---|
| 2608 |
|
|---|
| 2609 | mapstring_flags = LCMAP_SORTKEY | fdwStyle ;
|
|---|
| 2610 | len1 = OLE2NLS_EstimateMappingLength(lcid, mapstring_flags, s1, l1);
|
|---|
| 2611 | len2 = OLE2NLS_EstimateMappingLength(lcid, mapstring_flags, s2, l2);
|
|---|
| 2612 |
|
|---|
| 2613 | if ((len1==0)||(len2==0))
|
|---|
| 2614 | return 0; /* something wrong happened */
|
|---|
| 2615 |
|
|---|
| 2616 | sk1 = (LPSTR)HeapAlloc(GetProcessHeap(), 0, len1 + len2);
|
|---|
| 2617 | sk2 = sk1 + len1;
|
|---|
| 2618 | if ( (!LCMapStringA(lcid,mapstring_flags,s1,l1,sk1,len1))
|
|---|
| 2619 | || (!LCMapStringA(lcid,mapstring_flags,s2,l2,sk2,len2)) )
|
|---|
| 2620 | {
|
|---|
| 2621 | ERR("Bug in LCmapStringA.\n");
|
|---|
| 2622 | result = 0;
|
|---|
| 2623 | }
|
|---|
| 2624 | else
|
|---|
| 2625 | {
|
|---|
| 2626 | /* strcmp doesn't necessarily return -1, 0, or 1 */
|
|---|
| 2627 | result = strcmp(sk1,sk2);
|
|---|
| 2628 | }
|
|---|
| 2629 | HeapFree(GetProcessHeap(),0,sk1);
|
|---|
| 2630 |
|
|---|
| 2631 | if (result < 0)
|
|---|
| 2632 | return 1;
|
|---|
| 2633 | if (result == 0)
|
|---|
| 2634 | return 2;
|
|---|
| 2635 |
|
|---|
| 2636 | /* must be greater, if we reach this point */
|
|---|
| 2637 | return 3;
|
|---|
| 2638 | }
|
|---|
| 2639 |
|
|---|
| 2640 | /******************************************************************************
|
|---|
| 2641 | * CompareStringW [KERNEL32.144]
|
|---|
| 2642 | * This implementation ignores the locale
|
|---|
| 2643 | * FIXME : Does only string sort. Should
|
|---|
| 2644 | * be reimplemented the same way as CompareStringA.
|
|---|
| 2645 | */
|
|---|
| 2646 | UINT WINAPI CompareStringW(DWORD lcid, DWORD fdwStyle,
|
|---|
| 2647 | LPCWSTR s1, DWORD l1, LPCWSTR s2,DWORD l2)
|
|---|
| 2648 | {
|
|---|
| 2649 | int len,ret;
|
|---|
| 2650 | if(fdwStyle & NORM_IGNORENONSPACE)
|
|---|
| 2651 | FIXME("IGNORENONSPACE not supprted\n");
|
|---|
| 2652 | if(fdwStyle & NORM_IGNORESYMBOLS)
|
|---|
| 2653 | FIXME("IGNORESYMBOLS not supported\n");
|
|---|
| 2654 |
|
|---|
| 2655 | /* Is strcmp defaulting to string sort or to word sort?? */
|
|---|
| 2656 | /* FIXME: Handle NORM_STRINGSORT */
|
|---|
| 2657 | l1 = (l1==-1)?strlenW(s1):l1;
|
|---|
| 2658 | l2 = (l2==-1)?strlenW(s2):l2;
|
|---|
| 2659 | len = l1<l2 ? l1:l2;
|
|---|
| 2660 | ret = (fdwStyle & NORM_IGNORECASE) ? strncmpiW(s1,s2,len) : strncmpW(s1,s2,len);
|
|---|
| 2661 | /* not equal, return 1 or 3 */
|
|---|
| 2662 | if(ret!=0) {
|
|---|
| 2663 | /* need to translate result */
|
|---|
| 2664 | return ((int)ret < 0) ? 1 : 3;
|
|---|
| 2665 | }
|
|---|
| 2666 | /* same len, return 2 */
|
|---|
| 2667 | if(l1==l2) return 2;
|
|---|
| 2668 | /* the longer one is lexically greater */
|
|---|
| 2669 | return (l1<l2)? 1 : 3;
|
|---|
| 2670 | }
|
|---|
| 2671 |
|
|---|
| 2672 | /******************************************************************************
|
|---|
| 2673 | * OLE_GetFormatA [Internal]
|
|---|
| 2674 | *
|
|---|
| 2675 | * FIXME
|
|---|
| 2676 | * If datelen == 0, it should return the reguired string length.
|
|---|
| 2677 | *
|
|---|
| 2678 | This function implements stuff for GetDateFormat() and
|
|---|
| 2679 | GetTimeFormat().
|
|---|
| 2680 |
|
|---|
| 2681 | d single-digit (no leading zero) day (of month)
|
|---|
| 2682 | dd two-digit day (of month)
|
|---|
| 2683 | ddd short day-of-week name
|
|---|
| 2684 | dddd long day-of-week name
|
|---|
| 2685 | M single-digit month
|
|---|
| 2686 | MM two-digit month
|
|---|
| 2687 | MMM short month name
|
|---|
| 2688 | MMMM full month name
|
|---|
| 2689 | y two-digit year, no leading 0
|
|---|
| 2690 | yy two-digit year
|
|---|
| 2691 | yyyy four-digit year
|
|---|
| 2692 | gg era string
|
|---|
| 2693 | h hours with no leading zero (12-hour)
|
|---|
| 2694 | hh hours with full two digits
|
|---|
| 2695 | H hours with no leading zero (24-hour)
|
|---|
| 2696 | HH hours with full two digits
|
|---|
| 2697 | m minutes with no leading zero
|
|---|
| 2698 | mm minutes with full two digits
|
|---|
| 2699 | s seconds with no leading zero
|
|---|
| 2700 | ss seconds with full two digits
|
|---|
| 2701 | t time marker (A or P)
|
|---|
| 2702 | tt time marker (AM, PM)
|
|---|
| 2703 | '' used to quote literal characters
|
|---|
| 2704 | '' (within a quoted string) indicates a literal '
|
|---|
| 2705 |
|
|---|
| 2706 | These functions REQUIRE valid locale, date, and format.
|
|---|
| 2707 | */
|
|---|
| 2708 | static INT OLE_GetFormatA(LCID locale,
|
|---|
| 2709 | DWORD flags,
|
|---|
| 2710 | DWORD tflags,
|
|---|
| 2711 | LPSYSTEMTIME xtime,
|
|---|
| 2712 | LPCSTR _format, /*in*/
|
|---|
| 2713 | LPSTR date, /*out*/
|
|---|
| 2714 | INT datelen)
|
|---|
| 2715 | {
|
|---|
| 2716 | INT inpos, outpos;
|
|---|
| 2717 | int count, type, inquote, Overflow;
|
|---|
| 2718 | char buf[40];
|
|---|
| 2719 | char format[40];
|
|---|
| 2720 | char * pos;
|
|---|
| 2721 | int buflen;
|
|---|
| 2722 |
|
|---|
| 2723 | const char * _dgfmt[] = { "%d", "%02d" };
|
|---|
| 2724 | const char ** dgfmt = _dgfmt - 1;
|
|---|
| 2725 |
|
|---|
| 2726 | /* report, for debugging */
|
|---|
| 2727 | 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",
|
|---|
| 2728 | locale, flags, tflags,
|
|---|
| 2729 | xtime->wYear,xtime->wMonth,xtime->wDayOfWeek,xtime->wDay, xtime->wHour, xtime->wMinute, xtime->wSecond,
|
|---|
| 2730 | _format, _format, date, datelen);
|
|---|
| 2731 |
|
|---|
| 2732 | if(datelen == 0) {
|
|---|
| 2733 | FIXME("datelen = 0, returning 255\n");
|
|---|
| 2734 | return 255;
|
|---|
| 2735 | }
|
|---|
| 2736 |
|
|---|
| 2737 | /* initalize state variables and output buffer */
|
|---|
| 2738 | inpos = outpos = 0;
|
|---|
| 2739 | count = 0; inquote = 0; Overflow = 0;
|
|---|
| 2740 | type = '\0';
|
|---|
| 2741 | date[0] = buf[0] = '\0';
|
|---|
| 2742 |
|
|---|
| 2743 | strcpy(format,_format);
|
|---|
| 2744 |
|
|---|
| 2745 | /* alter the formatstring, while it works for all languages now in wine
|
|---|
| 2746 | its possible that it fails when the time looks like ss:mm:hh as example*/
|
|---|
| 2747 | if (tflags & (TIME_NOMINUTESORSECONDS))
|
|---|
| 2748 | { if ((pos = strstr ( format, ":mm")))
|
|---|
| 2749 | { memcpy ( pos, pos+3, strlen(format)-(pos-format)-2 );
|
|---|
| 2750 | }
|
|---|
| 2751 | }
|
|---|
| 2752 | if (tflags & (TIME_NOSECONDS))
|
|---|
| 2753 | { if ((pos = strstr ( format, ":ss")))
|
|---|
| 2754 | { memcpy ( pos, pos+3, strlen(format)-(pos-format)-2 );
|
|---|
| 2755 | }
|
|---|
| 2756 | }
|
|---|
| 2757 |
|
|---|
| 2758 | for (inpos = 0;; inpos++) {
|
|---|
| 2759 | /* 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]); */
|
|---|
| 2760 | if (inquote) {
|
|---|
| 2761 | if (format[inpos] == '\'') {
|
|---|
| 2762 | if (format[inpos+1] == '\'') {
|
|---|
| 2763 | inpos += 1;
|
|---|
| 2764 | date[outpos++] = '\'';
|
|---|
| 2765 | } else {
|
|---|
| 2766 | inquote = 0;
|
|---|
| 2767 | continue; /* we did nothing to the output */
|
|---|
| 2768 | }
|
|---|
| 2769 | } else if (format[inpos] == '\0') {
|
|---|
| 2770 | date[outpos++] = '\0';
|
|---|
| 2771 | if (outpos > datelen) Overflow = 1;
|
|---|
| 2772 | break;
|
|---|
| 2773 | } else {
|
|---|
| 2774 | date[outpos++] = format[inpos];
|
|---|
| 2775 | if (outpos > datelen) {
|
|---|
| 2776 | Overflow = 1;
|
|---|
| 2777 | date[outpos-1] = '\0'; /* this is the last place where
|
|---|
| 2778 | it's safe to write */
|
|---|
| 2779 | break;
|
|---|
| 2780 | }
|
|---|
| 2781 | }
|
|---|
| 2782 | } else if ( (count && (format[inpos] != type))
|
|---|
| 2783 | || count == 4
|
|---|
| 2784 | || (count == 2 && strchr("ghHmst", type)) ) {
|
|---|
| 2785 | if (type == 'h' && (tflags & TIME_FORCE24HOURFORMAT)) type= 'H';
|
|---|
| 2786 | if (type == 'd') {
|
|---|
| 2787 | if (count == 4) {
|
|---|
| 2788 | GetLocaleInfoA(locale,
|
|---|
| 2789 | LOCALE_SDAYNAME1
|
|---|
| 2790 | + (xtime->wDayOfWeek+6)%7,
|
|---|
| 2791 | buf, sizeof(buf));
|
|---|
| 2792 | } else if (count == 3) {
|
|---|
| 2793 | GetLocaleInfoA(locale,
|
|---|
| 2794 | LOCALE_SABBREVDAYNAME1
|
|---|
| 2795 | + (xtime->wDayOfWeek+6)%7,
|
|---|
| 2796 | buf, sizeof(buf));
|
|---|
| 2797 | } else {
|
|---|
| 2798 | sprintf(buf, dgfmt[count], xtime->wDay);
|
|---|
| 2799 | }
|
|---|
| 2800 | } else if (type == 'M') {
|
|---|
| 2801 | if (count == 3) {
|
|---|
| 2802 | GetLocaleInfoA(locale,
|
|---|
| 2803 | LOCALE_SABBREVMONTHNAME1
|
|---|
| 2804 | + xtime->wMonth - 1,
|
|---|
| 2805 | buf, sizeof(buf));
|
|---|
| 2806 | } else if (count == 4) {
|
|---|
| 2807 | GetLocaleInfoA(locale,
|
|---|
| 2808 | LOCALE_SMONTHNAME1
|
|---|
| 2809 | + xtime->wMonth - 1,
|
|---|
| 2810 | buf, sizeof(buf));
|
|---|
| 2811 | } else {
|
|---|
| 2812 | sprintf(buf, dgfmt[count], xtime->wMonth);
|
|---|
| 2813 | }
|
|---|
| 2814 | } else if (type == 'y') {
|
|---|
| 2815 | if (count == 4) {
|
|---|
| 2816 | sprintf(buf, "%d", xtime->wYear);
|
|---|
| 2817 | } else if (count == 3) {
|
|---|
| 2818 | strcpy(buf, "yyy");
|
|---|
| 2819 | WARN("unknown format, c=%c, n=%d\n", type, count);
|
|---|
| 2820 | } else {
|
|---|
| 2821 | sprintf(buf, dgfmt[count], xtime->wYear % 100);
|
|---|
| 2822 | }
|
|---|
| 2823 | } else if (type == 'g') {
|
|---|
| 2824 | if (count == 2) {
|
|---|
| 2825 | FIXME("LOCALE_ICALENDARTYPE unimp.\n");
|
|---|
| 2826 | strcpy(buf, "AD");
|
|---|
| 2827 | } else {
|
|---|
| 2828 | strcpy(buf, "g");
|
|---|
| 2829 | WARN("unknown format, c=%c, n=%d\n", type, count);
|
|---|
| 2830 | }
|
|---|
| 2831 | } else if (type == 'h') {
|
|---|
| 2832 | /* gives us hours 1:00 -- 12:00 */
|
|---|
| 2833 | sprintf(buf, dgfmt[count], (xtime->wHour-1)%12 +1);
|
|---|
| 2834 | } else if (type == 'H') {
|
|---|
| 2835 | /* 24-hour time */
|
|---|
| 2836 | sprintf(buf, dgfmt[count], xtime->wHour);
|
|---|
| 2837 | } else if ( type == 'm') {
|
|---|
| 2838 | sprintf(buf, dgfmt[count], xtime->wMinute);
|
|---|
| 2839 | } else if ( type == 's') {
|
|---|
| 2840 | sprintf(buf, dgfmt[count], xtime->wSecond);
|
|---|
| 2841 | } else if (type == 't') {
|
|---|
| 2842 | if ((tflags & TIME_NOTIMEMARKER))
|
|---|
| 2843 | buf[0]='\0';
|
|---|
| 2844 | else if (count == 1) {
|
|---|
| 2845 | sprintf(buf, "%c", (xtime->wHour < 12) ? 'A' : 'P');
|
|---|
| 2846 | } else if (count == 2) {
|
|---|
| 2847 | /* sprintf(buf, "%s", (xtime->wHour < 12) ? "AM" : "PM"); */
|
|---|
| 2848 | GetLocaleInfoA(locale,
|
|---|
| 2849 | (xtime->wHour<12)
|
|---|
| 2850 | ? LOCALE_S1159 : LOCALE_S2359,
|
|---|
| 2851 | buf, sizeof(buf));
|
|---|
| 2852 | }
|
|---|
| 2853 | };
|
|---|
| 2854 |
|
|---|
| 2855 | /* we need to check the next char in the format string
|
|---|
| 2856 | again, no matter what happened */
|
|---|
| 2857 | inpos--;
|
|---|
| 2858 |
|
|---|
| 2859 | /* add the contents of buf to the output */
|
|---|
| 2860 | buflen = strlen(buf);
|
|---|
| 2861 | if (outpos + buflen < datelen) {
|
|---|
| 2862 | date[outpos] = '\0'; /* for strcat to hook onto */
|
|---|
| 2863 | strcat(date, buf);
|
|---|
| 2864 | outpos += buflen;
|
|---|
| 2865 | } else {
|
|---|
| 2866 | date[outpos] = '\0';
|
|---|
| 2867 | strncat(date, buf, datelen - outpos);
|
|---|
| 2868 | date[datelen - 1] = '\0';
|
|---|
| 2869 | SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|---|
| 2870 | WARN("insufficient buffer\n");
|
|---|
| 2871 | return 0;
|
|---|
| 2872 | }
|
|---|
| 2873 |
|
|---|
| 2874 | /* reset the variables we used to keep track of this item */
|
|---|
| 2875 | count = 0;
|
|---|
| 2876 | type = '\0';
|
|---|
| 2877 | } else if (format[inpos] == '\0') {
|
|---|
| 2878 | /* we can't check for this at the loop-head, because
|
|---|
| 2879 | that breaks the printing of the last format-item */
|
|---|
| 2880 | date[outpos] = '\0';
|
|---|
| 2881 | break;
|
|---|
| 2882 | } else if (count) {
|
|---|
| 2883 | /* continuing a code for an item */
|
|---|
| 2884 | count +=1;
|
|---|
| 2885 | continue;
|
|---|
| 2886 | } else if (strchr("hHmstyMdg", format[inpos])) {
|
|---|
| 2887 | type = format[inpos];
|
|---|
| 2888 | count = 1;
|
|---|
| 2889 | continue;
|
|---|
| 2890 | } else if (format[inpos] == '\'') {
|
|---|
| 2891 | inquote = 1;
|
|---|
| 2892 | continue;
|
|---|
| 2893 | } else {
|
|---|
| 2894 | date[outpos++] = format[inpos];
|
|---|
| 2895 | }
|
|---|
| 2896 | /* now deal with a possible buffer overflow */
|
|---|
| 2897 | if (outpos >= datelen) {
|
|---|
| 2898 | date[datelen - 1] = '\0';
|
|---|
| 2899 | SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|---|
| 2900 | return 0;
|
|---|
| 2901 | }
|
|---|
| 2902 | }
|
|---|
| 2903 |
|
|---|
| 2904 | if (Overflow) {
|
|---|
| 2905 | SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|---|
| 2906 | };
|
|---|
| 2907 |
|
|---|
| 2908 | /* finish it off with a string terminator */
|
|---|
| 2909 | outpos++;
|
|---|
| 2910 | /* sanity check */
|
|---|
| 2911 | if (outpos > datelen-1) outpos = datelen-1;
|
|---|
| 2912 | date[outpos] = '\0';
|
|---|
| 2913 |
|
|---|
| 2914 | TRACE("returns string '%s', len %d\n", date, outpos);
|
|---|
| 2915 | return outpos;
|
|---|
| 2916 | }
|
|---|
| 2917 |
|
|---|
| 2918 | /******************************************************************************
|
|---|
| 2919 | * OLE_GetFormatW [INTERNAL]
|
|---|
| 2920 | */
|
|---|
| 2921 | static INT OLE_GetFormatW(LCID locale, DWORD flags, DWORD tflags,
|
|---|
| 2922 | LPSYSTEMTIME xtime,
|
|---|
| 2923 | LPCWSTR format,
|
|---|
| 2924 | LPWSTR output, INT outlen)
|
|---|
| 2925 | {
|
|---|
| 2926 | INT inpos, outpos;
|
|---|
| 2927 | int count, type=0, inquote;
|
|---|
| 2928 | int Overflow; /* loop check */
|
|---|
| 2929 | char tmp[16];
|
|---|
| 2930 | WCHAR buf[40];
|
|---|
| 2931 | int buflen=0;
|
|---|
| 2932 | WCHAR arg0[] = {0}, arg1[] = {'%','d',0};
|
|---|
| 2933 | WCHAR arg2[] = {'%','0','2','d',0};
|
|---|
| 2934 | WCHAR *argarr[3];
|
|---|
| 2935 | int datevars=0, timevars=0;
|
|---|
| 2936 |
|
|---|
| 2937 | argarr[0] = arg0;
|
|---|
| 2938 | argarr[1] = arg1;
|
|---|
| 2939 | argarr[2] = arg2;
|
|---|
| 2940 |
|
|---|
| 2941 | /* make a debug report */
|
|---|
| 2942 | TRACE("args: 0x%lx, 0x%lx, 0x%lx, time(d=%d,h=%d,m=%d,s=%d), fmt:%s (at %p), "
|
|---|
| 2943 | "%p with max len %d\n",
|
|---|
| 2944 | locale, flags, tflags,
|
|---|
| 2945 | xtime->wDay, xtime->wHour, xtime->wMinute, xtime->wSecond,
|
|---|
| 2946 | debugstr_w(format), format, output, outlen);
|
|---|
| 2947 |
|
|---|
| 2948 | if(outlen == 0) {
|
|---|
| 2949 | FIXME("outlen = 0, returning 255\n");
|
|---|
| 2950 | return 255;
|
|---|
| 2951 | }
|
|---|
| 2952 |
|
|---|
| 2953 | /* initialize state variables */
|
|---|
| 2954 | inpos = outpos = 0;
|
|---|
| 2955 | count = 0;
|
|---|
| 2956 | inquote = Overflow = 0;
|
|---|
| 2957 | /* this is really just a sanity check */
|
|---|
| 2958 | output[0] = buf[0] = 0;
|
|---|
| 2959 |
|
|---|
| 2960 | /* this loop is the core of the function */
|
|---|
| 2961 | for (inpos = 0; /* we have several break points */ ; inpos++) {
|
|---|
| 2962 | if (inquote) {
|
|---|
| 2963 | if (format[inpos] == (WCHAR) '\'') {
|
|---|
| 2964 | if (format[inpos+1] == '\'') {
|
|---|
| 2965 | inpos++;
|
|---|
| 2966 | output[outpos++] = '\'';
|
|---|
| 2967 | } else {
|
|---|
| 2968 | inquote = 0;
|
|---|
| 2969 | continue;
|
|---|
| 2970 | }
|
|---|
| 2971 | } else if (format[inpos] == 0) {
|
|---|
| 2972 | output[outpos++] = 0;
|
|---|
| 2973 | if (outpos > outlen) Overflow = 1;
|
|---|
| 2974 | break; /* normal exit (within a quote) */
|
|---|
| 2975 | } else {
|
|---|
| 2976 | output[outpos++] = format[inpos]; /* copy input */
|
|---|
| 2977 | if (outpos > outlen) {
|
|---|
| 2978 | Overflow = 1;
|
|---|
| 2979 | output[outpos-1] = 0;
|
|---|
| 2980 | break;
|
|---|
| 2981 | }
|
|---|
| 2982 | }
|
|---|
| 2983 | } else if ( (count && (format[inpos] != type))
|
|---|
| 2984 | || ( (count==4 && type =='y') ||
|
|---|
| 2985 | (count==4 && type =='M') ||
|
|---|
| 2986 | (count==4 && type =='d') ||
|
|---|
| 2987 | (count==2 && type =='g') ||
|
|---|
| 2988 | (count==2 && type =='h') ||
|
|---|
| 2989 | (count==2 && type =='H') ||
|
|---|
| 2990 | (count==2 && type =='m') ||
|
|---|
| 2991 | (count==2 && type =='s') ||
|
|---|
| 2992 | (count==2 && type =='t') ) ) {
|
|---|
| 2993 | switch(type)
|
|---|
| 2994 | {
|
|---|
| 2995 | case 'd':
|
|---|
| 2996 | if (count == 4) {
|
|---|
| 2997 | GetLocaleInfoW(locale,
|
|---|
| 2998 | LOCALE_SDAYNAME1 + (xtime->wDayOfWeek +6)%7,
|
|---|
| 2999 | buf, sizeof(buf)/sizeof(WCHAR) );
|
|---|
| 3000 | } else if (count == 3) {
|
|---|
| 3001 | GetLocaleInfoW(locale,
|
|---|
| 3002 | LOCALE_SABBREVDAYNAME1 +
|
|---|
| 3003 | (xtime->wDayOfWeek +6)%7,
|
|---|
| 3004 | buf, sizeof(buf)/sizeof(WCHAR) );
|
|---|
| 3005 | } else {
|
|---|
| 3006 | sprintf( tmp, "%.*d", count, xtime->wDay );
|
|---|
| 3007 | MultiByteToWideChar( CP_ACP, 0, tmp, -1, buf, sizeof(buf)/sizeof(WCHAR) );
|
|---|
| 3008 | }
|
|---|
| 3009 | break;
|
|---|
| 3010 |
|
|---|
| 3011 | case 'M':
|
|---|
| 3012 | if (count == 4) {
|
|---|
| 3013 | GetLocaleInfoW(locale, LOCALE_SMONTHNAME1 +
|
|---|
| 3014 | xtime->wMonth -1, buf,
|
|---|
| 3015 | sizeof(buf)/sizeof(WCHAR) );
|
|---|
| 3016 | } else if (count == 3) {
|
|---|
| 3017 | GetLocaleInfoW(locale, LOCALE_SABBREVMONTHNAME1 +
|
|---|
| 3018 | xtime->wMonth -1, buf,
|
|---|
| 3019 | sizeof(buf)/sizeof(WCHAR) );
|
|---|
| 3020 | } else {
|
|---|
| 3021 | sprintf( tmp, "%.*d", count, xtime->wMonth );
|
|---|
| 3022 | MultiByteToWideChar( CP_ACP, 0, tmp, -1, buf, sizeof(buf)/sizeof(WCHAR) );
|
|---|
| 3023 | }
|
|---|
| 3024 | break;
|
|---|
| 3025 | case 'y':
|
|---|
| 3026 | if (count == 4) {
|
|---|
| 3027 | sprintf( tmp, "%d", xtime->wYear );
|
|---|
| 3028 | } else if (count == 3) {
|
|---|
| 3029 | strcpy( tmp, "yyy" );
|
|---|
| 3030 | } else {
|
|---|
| 3031 | sprintf( tmp, "%.*d", count, xtime->wYear % 100 );
|
|---|
| 3032 | }
|
|---|
| 3033 | MultiByteToWideChar( CP_ACP, 0, tmp, -1, buf, sizeof(buf)/sizeof(WCHAR) );
|
|---|
| 3034 | break;
|
|---|
| 3035 |
|
|---|
| 3036 | case 'g':
|
|---|
| 3037 | if (count == 2) {
|
|---|
| 3038 | FIXME("LOCALE_ICALENDARTYPE unimplemented\n");
|
|---|
| 3039 | strcpy( tmp, "AD" );
|
|---|
| 3040 | } else {
|
|---|
| 3041 | /* Win API sez we copy it verbatim */
|
|---|
| 3042 | strcpy( tmp, "g" );
|
|---|
| 3043 | }
|
|---|
| 3044 | MultiByteToWideChar( CP_ACP, 0, tmp, -1, buf, sizeof(buf)/sizeof(WCHAR) );
|
|---|
| 3045 | break;
|
|---|
| 3046 |
|
|---|
| 3047 | case 'h':
|
|---|
| 3048 | /* hours 1:00-12:00 --- is this right? */
|
|---|
| 3049 | sprintf( tmp, "%.*d", count, (xtime->wHour-1)%12 +1);
|
|---|
| 3050 | MultiByteToWideChar( CP_ACP, 0, tmp, -1, buf, sizeof(buf)/sizeof(WCHAR) );
|
|---|
| 3051 | break;
|
|---|
| 3052 |
|
|---|
| 3053 | case 'H':
|
|---|
| 3054 | sprintf( tmp, "%.*d", count, xtime->wHour );
|
|---|
| 3055 | MultiByteToWideChar( CP_ACP, 0, tmp, -1, buf, sizeof(buf)/sizeof(WCHAR) );
|
|---|
| 3056 | break;
|
|---|
| 3057 |
|
|---|
| 3058 | case 'm':
|
|---|
| 3059 | sprintf( tmp, "%.*d", count, xtime->wMinute );
|
|---|
| 3060 | MultiByteToWideChar( CP_ACP, 0, tmp, -1, buf, sizeof(buf)/sizeof(WCHAR) );
|
|---|
| 3061 | break;
|
|---|
| 3062 |
|
|---|
| 3063 | case 's':
|
|---|
| 3064 | sprintf( tmp, "%.*d", count, xtime->wSecond );
|
|---|
| 3065 | MultiByteToWideChar( CP_ACP, 0, tmp, -1, buf, sizeof(buf)/sizeof(WCHAR) );
|
|---|
| 3066 | break;
|
|---|
| 3067 |
|
|---|
| 3068 | case 't':
|
|---|
| 3069 | GetLocaleInfoW(locale, (xtime->wHour < 12) ?
|
|---|
| 3070 | LOCALE_S1159 : LOCALE_S2359,
|
|---|
| 3071 | buf, sizeof(buf) );
|
|---|
| 3072 | if (count == 1) {
|
|---|
| 3073 | buf[1] = 0;
|
|---|
| 3074 | }
|
|---|
| 3075 | break;
|
|---|
| 3076 | }
|
|---|
| 3077 |
|
|---|
| 3078 | /* no matter what happened, we need to check this next
|
|---|
| 3079 | character the next time we loop through */
|
|---|
| 3080 | inpos--;
|
|---|
| 3081 |
|
|---|
| 3082 | /* cat buf onto the output */
|
|---|
| 3083 | outlen = strlenW(buf);
|
|---|
| 3084 | if (outpos + buflen < outlen) {
|
|---|
| 3085 | strcpyW( output + outpos, buf );
|
|---|
| 3086 | outpos += buflen;
|
|---|
| 3087 | } else {
|
|---|
| 3088 | lstrcpynW( output + outpos, buf, outlen - outpos );
|
|---|
| 3089 | Overflow = 1;
|
|---|
| 3090 | break; /* Abnormal exit */
|
|---|
| 3091 | }
|
|---|
| 3092 |
|
|---|
| 3093 | /* reset the variables we used this time */
|
|---|
| 3094 | count = 0;
|
|---|
| 3095 | type = '\0';
|
|---|
| 3096 | } else if (format[inpos] == 0) {
|
|---|
| 3097 | /* we can't check for this at the beginning, because that
|
|---|
| 3098 | would keep us from printing a format spec that ended the
|
|---|
| 3099 | string */
|
|---|
| 3100 | output[outpos] = 0;
|
|---|
| 3101 | break; /* NORMAL EXIT */
|
|---|
| 3102 | } else if (count) {
|
|---|
| 3103 | /* how we keep track of the middle of a format spec */
|
|---|
| 3104 | count++;
|
|---|
| 3105 | continue;
|
|---|
| 3106 | } else if ( (datevars && (format[inpos]=='d' ||
|
|---|
| 3107 | format[inpos]=='M' ||
|
|---|
| 3108 | format[inpos]=='y' ||
|
|---|
| 3109 | format[inpos]=='g') ) ||
|
|---|
| 3110 | (timevars && (format[inpos]=='H' ||
|
|---|
| 3111 | format[inpos]=='h' ||
|
|---|
| 3112 | format[inpos]=='m' ||
|
|---|
| 3113 | format[inpos]=='s' ||
|
|---|
| 3114 | format[inpos]=='t') ) ) {
|
|---|
| 3115 | type = format[inpos];
|
|---|
| 3116 | count = 1;
|
|---|
| 3117 | continue;
|
|---|
| 3118 | } else if (format[inpos] == '\'') {
|
|---|
| 3119 | inquote = 1;
|
|---|
| 3120 | continue;
|
|---|
| 3121 | } else {
|
|---|
| 3122 | /* unquoted literals */
|
|---|
| 3123 | output[outpos++] = format[inpos];
|
|---|
| 3124 | }
|
|---|
| 3125 | }
|
|---|
| 3126 |
|
|---|
| 3127 | if (Overflow) {
|
|---|
| 3128 | SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|---|
| 3129 | WARN(" buffer overflow\n");
|
|---|
| 3130 | };
|
|---|
| 3131 |
|
|---|
| 3132 | /* final string terminator and sanity check */
|
|---|
| 3133 | outpos++;
|
|---|
| 3134 | if (outpos > outlen-1) outpos = outlen-1;
|
|---|
| 3135 | output[outpos] = '0';
|
|---|
| 3136 |
|
|---|
| 3137 | TRACE(" returning %s\n", debugstr_w(output));
|
|---|
| 3138 |
|
|---|
| 3139 | return (!Overflow) ? outlen : 0;
|
|---|
| 3140 |
|
|---|
| 3141 | }
|
|---|
| 3142 |
|
|---|
| 3143 |
|
|---|
| 3144 | /******************************************************************************
|
|---|
| 3145 | * GetDateFormatA [KERNEL32.310]
|
|---|
| 3146 | * Makes an ASCII string of the date
|
|---|
| 3147 | *
|
|---|
| 3148 | * This function uses format to format the date, or, if format
|
|---|
| 3149 | * is NULL, uses the default for the locale. format is a string
|
|---|
| 3150 | * of literal fields and characters as follows:
|
|---|
| 3151 | *
|
|---|
| 3152 | * - d single-digit (no leading zero) day (of month)
|
|---|
| 3153 | * - dd two-digit day (of month)
|
|---|
| 3154 | * - ddd short day-of-week name
|
|---|
| 3155 | * - dddd long day-of-week name
|
|---|
| 3156 | * - M single-digit month
|
|---|
| 3157 | * - MM two-digit month
|
|---|
| 3158 | * - MMM short month name
|
|---|
| 3159 | * - MMMM full month name
|
|---|
| 3160 | * - y two-digit year, no leading 0
|
|---|
| 3161 | * - yy two-digit year
|
|---|
| 3162 | * - yyyy four-digit year
|
|---|
| 3163 | * - gg era string
|
|---|
| 3164 | *
|
|---|
| 3165 | */
|
|---|
| 3166 | INT WINAPI GetDateFormatA(LCID locale,DWORD flags,
|
|---|
| 3167 | LPSYSTEMTIME xtime,
|
|---|
| 3168 | LPCSTR format, LPSTR date,INT datelen)
|
|---|
| 3169 | {
|
|---|
| 3170 |
|
|---|
| 3171 | char format_buf[40];
|
|---|
| 3172 | LPCSTR thisformat;
|
|---|
| 3173 | SYSTEMTIME t;
|
|---|
| 3174 | LPSYSTEMTIME thistime;
|
|---|
| 3175 | LCID thislocale;
|
|---|
| 3176 | INT ret;
|
|---|
| 3177 | FILETIME ft;
|
|---|
| 3178 | BOOL res;
|
|---|
| 3179 |
|
|---|
| 3180 | TRACE("(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",
|
|---|
| 3181 | locale,flags,xtime,format,date,datelen);
|
|---|
| 3182 |
|
|---|
| 3183 | if (!locale) {
|
|---|
| 3184 | locale = LOCALE_SYSTEM_DEFAULT;
|
|---|
| 3185 | };
|
|---|
| 3186 |
|
|---|
| 3187 | if (locale == LOCALE_SYSTEM_DEFAULT) {
|
|---|
| 3188 | thislocale = GetSystemDefaultLCID();
|
|---|
| 3189 | } else if (locale == LOCALE_USER_DEFAULT) {
|
|---|
| 3190 | thislocale = GetUserDefaultLCID();
|
|---|
| 3191 | } else {
|
|---|
| 3192 | thislocale = locale;
|
|---|
| 3193 | };
|
|---|
| 3194 |
|
|---|
| 3195 | if (xtime == NULL) {
|
|---|
| 3196 | GetSystemTime(&t);
|
|---|
| 3197 | } else {
|
|---|
| 3198 | /* Silently correct wDayOfWeek by tranforming to FileTime and back again*/
|
|---|
| 3199 | res=SystemTimeToFileTime(xtime,&ft);
|
|---|
| 3200 | /* Check year(?)/month and date for range and set ERROR_INVALID_PARAMETER on error*/
|
|---|
| 3201 | /*FIXME: SystemTimeToFileTime doesn't yet do that ckeck*/
|
|---|
| 3202 | if(!res)
|
|---|
| 3203 | {
|
|---|
| 3204 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 3205 | return 0;
|
|---|
| 3206 | }
|
|---|
| 3207 | FileTimeToSystemTime(&ft,&t);
|
|---|
| 3208 |
|
|---|
| 3209 | };
|
|---|
| 3210 | thistime = &t;
|
|---|
| 3211 |
|
|---|
| 3212 | if (format == NULL) {
|
|---|
| 3213 | GetLocaleInfoA(thislocale, ((flags&DATE_LONGDATE)
|
|---|
| 3214 | ? LOCALE_SLONGDATE
|
|---|
| 3215 | : LOCALE_SSHORTDATE),
|
|---|
| 3216 | format_buf, sizeof(format_buf));
|
|---|
| 3217 | thisformat = format_buf;
|
|---|
| 3218 | } else {
|
|---|
| 3219 | thisformat = format;
|
|---|
| 3220 | };
|
|---|
| 3221 |
|
|---|
| 3222 |
|
|---|
| 3223 | ret = OLE_GetFormatA(thislocale, flags, 0, thistime, thisformat,
|
|---|
| 3224 | date, datelen);
|
|---|
| 3225 |
|
|---|
| 3226 |
|
|---|
| 3227 | TRACE(
|
|---|
| 3228 | "GetDateFormatA() returning %d, with data=%s\n",
|
|---|
| 3229 | ret, date);
|
|---|
| 3230 | return ret;
|
|---|
| 3231 | }
|
|---|
| 3232 |
|
|---|
| 3233 | /******************************************************************************
|
|---|
| 3234 | * GetDateFormatW [KERNEL32.311]
|
|---|
| 3235 | * Makes a Unicode string of the date
|
|---|
| 3236 | *
|
|---|
| 3237 | * Acts the same as GetDateFormatA(), except that it's Unicode.
|
|---|
| 3238 | * Accepts & returns sizes as counts of Unicode characters.
|
|---|
| 3239 | *
|
|---|
| 3240 | */
|
|---|
| 3241 | INT WINAPI GetDateFormatW(LCID locale,DWORD flags,
|
|---|
| 3242 | LPSYSTEMTIME xtime,
|
|---|
| 3243 | LPCWSTR format,
|
|---|
| 3244 | LPWSTR date, INT datelen)
|
|---|
| 3245 | {
|
|---|
| 3246 | // convert "format" on passing in into ASCII
|
|---|
| 3247 | LPSTR pszAsciiFormat = UnicodeToAsciiString((LPWSTR) format);
|
|---|
| 3248 | LPSTR pszAsciiDate = (char *)alloca(datelen);
|
|---|
| 3249 |
|
|---|
| 3250 | TRACE("Kernel32-ole2nls: GetDateFormatW(0x%04lx,0x%08lx,%p,%s,%p,%d) not yet complete\n",
|
|---|
| 3251 | locale,flags,xtime,pszAsciiFormat,date,datelen);
|
|---|
| 3252 |
|
|---|
| 3253 | // call ASCII variant
|
|---|
| 3254 | int rc = GetDateFormatA(locale,
|
|---|
| 3255 | flags,
|
|---|
| 3256 | xtime,
|
|---|
| 3257 | pszAsciiFormat,
|
|---|
| 3258 | pszAsciiDate,
|
|---|
| 3259 | datelen); // is in "characters", not bytes
|
|---|
| 3260 |
|
|---|
| 3261 | FreeAsciiString(pszAsciiFormat);
|
|---|
| 3262 |
|
|---|
| 3263 | // convert "date" on returning to UNICODE
|
|---|
| 3264 | if (datelen != 0)
|
|---|
| 3265 | {
|
|---|
| 3266 | // in this case 'rc' holds the number of characters to convert
|
|---|
| 3267 | lstrcpynAtoW(date, pszAsciiDate, rc);
|
|---|
| 3268 | }
|
|---|
| 3269 |
|
|---|
| 3270 | return rc;
|
|---|
| 3271 |
|
|---|
| 3272 | #if PH_OFF
|
|---|
| 3273 | unsigned short datearr[] = {'1','9','9','4','-','1','-','1',0};
|
|---|
| 3274 |
|
|---|
| 3275 | FIXME("STUB (should call OLE_GetFormatW)\n");
|
|---|
| 3276 | lstrcpynW(date, datearr, datelen);
|
|---|
| 3277 | return ( datelen < 9) ? datelen : 9;
|
|---|
| 3278 | #endif
|
|---|
| 3279 | }
|
|---|
| 3280 |
|
|---|
| 3281 | /**************************************************************************
|
|---|
| 3282 | * EnumDateFormatsA (KERNEL32.198)
|
|---|
| 3283 | */
|
|---|
| 3284 | BOOL WINAPI EnumDateFormatsA(
|
|---|
| 3285 | DATEFMT_ENUMPROCA lpDateFmtEnumProc, LCID Locale, DWORD dwFlags)
|
|---|
| 3286 | {
|
|---|
| 3287 | LCID Loc = GetUserDefaultLCID();
|
|---|
| 3288 | if(!lpDateFmtEnumProc)
|
|---|
| 3289 | {
|
|---|
| 3290 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 3291 | return FALSE;
|
|---|
| 3292 | }
|
|---|
| 3293 |
|
|---|
| 3294 | switch( Loc )
|
|---|
| 3295 | {
|
|---|
| 3296 |
|
|---|
| 3297 | case 0x00000407: /* (Loc,"de_DE") */
|
|---|
| 3298 | {
|
|---|
| 3299 | switch(dwFlags)
|
|---|
| 3300 | {
|
|---|
| 3301 | case DATE_SHORTDATE:
|
|---|
| 3302 | if(!(*lpDateFmtEnumProc)("dd.MM.yy")) return TRUE;
|
|---|
| 3303 | if(!(*lpDateFmtEnumProc)("d.M.yyyy")) return TRUE;
|
|---|
| 3304 | if(!(*lpDateFmtEnumProc)("d.MM.yy")) return TRUE;
|
|---|
| 3305 | if(!(*lpDateFmtEnumProc)("d.M.yy")) return TRUE;
|
|---|
| 3306 | return TRUE;
|
|---|
| 3307 | case DATE_LONGDATE:
|
|---|
| 3308 | if(!(*lpDateFmtEnumProc)("dddd,d. MMMM yyyy")) return TRUE;
|
|---|
| 3309 | if(!(*lpDateFmtEnumProc)("d. MMMM yyyy")) return TRUE;
|
|---|
| 3310 | if(!(*lpDateFmtEnumProc)("d. MMM yyyy")) return TRUE;
|
|---|
| 3311 | return TRUE;
|
|---|
| 3312 | default:
|
|---|
| 3313 | FIXME("Unknown date format (%ld)\n", dwFlags);
|
|---|
| 3314 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 3315 | return FALSE;
|
|---|
| 3316 | }
|
|---|
| 3317 | }
|
|---|
| 3318 |
|
|---|
| 3319 | case 0x0000040c: /* (Loc,"fr_FR") */
|
|---|
| 3320 | {
|
|---|
| 3321 | switch(dwFlags)
|
|---|
| 3322 | {
|
|---|
| 3323 | case DATE_SHORTDATE:
|
|---|
| 3324 | if(!(*lpDateFmtEnumProc)("dd/MM/yy")) return TRUE;
|
|---|
| 3325 | if(!(*lpDateFmtEnumProc)("dd.MM.yy")) return TRUE;
|
|---|
| 3326 | if(!(*lpDateFmtEnumProc)("dd-MM-yy")) return TRUE;
|
|---|
| 3327 | if(!(*lpDateFmtEnumProc)("dd/MM/yyyy")) return TRUE;
|
|---|
| 3328 | return TRUE;
|
|---|
| 3329 | case DATE_LONGDATE:
|
|---|
| 3330 | if(!(*lpDateFmtEnumProc)("dddd d MMMM yyyy")) return TRUE;
|
|---|
| 3331 | if(!(*lpDateFmtEnumProc)("d MMM yy")) return TRUE;
|
|---|
| 3332 | if(!(*lpDateFmtEnumProc)("d MMMM yyyy")) return TRUE;
|
|---|
| 3333 | return TRUE;
|
|---|
| 3334 | default:
|
|---|
| 3335 | FIXME("Unknown date format (%ld)\n", dwFlags);
|
|---|
| 3336 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 3337 | return FALSE;
|
|---|
| 3338 | }
|
|---|
| 3339 | }
|
|---|
| 3340 |
|
|---|
| 3341 | case 0x00000c0c: /* (Loc,"fr_CA") */
|
|---|
| 3342 | {
|
|---|
| 3343 | switch(dwFlags)
|
|---|
| 3344 | {
|
|---|
| 3345 | case DATE_SHORTDATE:
|
|---|
| 3346 | if(!(*lpDateFmtEnumProc)("yy-MM-dd")) return TRUE;
|
|---|
| 3347 | if(!(*lpDateFmtEnumProc)("dd-MM-yy")) return TRUE;
|
|---|
| 3348 | if(!(*lpDateFmtEnumProc)("yy MM dd")) return TRUE;
|
|---|
| 3349 | if(!(*lpDateFmtEnumProc)("dd/MM/yy")) return TRUE;
|
|---|
| 3350 | return TRUE;
|
|---|
| 3351 | case DATE_LONGDATE:
|
|---|
| 3352 | if(!(*lpDateFmtEnumProc)("d MMMM, yyyy")) return TRUE;
|
|---|
| 3353 | if(!(*lpDateFmtEnumProc)("d MMM yyyy")) return TRUE;
|
|---|
| 3354 | return TRUE;
|
|---|
| 3355 | default:
|
|---|
| 3356 | FIXME("Unknown date format (%ld)\n", dwFlags);
|
|---|
| 3357 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 3358 | return FALSE;
|
|---|
| 3359 | }
|
|---|
| 3360 | }
|
|---|
| 3361 |
|
|---|
| 3362 | case 0x00000809: /* (Loc,"en_UK") */
|
|---|
| 3363 | {
|
|---|
| 3364 | switch(dwFlags)
|
|---|
| 3365 | {
|
|---|
| 3366 | case DATE_SHORTDATE:
|
|---|
| 3367 | if(!(*lpDateFmtEnumProc)("dd/MM/yy")) return TRUE;
|
|---|
| 3368 | if(!(*lpDateFmtEnumProc)("dd/MM/yyyy")) return TRUE;
|
|---|
| 3369 | if(!(*lpDateFmtEnumProc)("d/M/yy")) return TRUE;
|
|---|
| 3370 | if(!(*lpDateFmtEnumProc)("d.M.yy")) return TRUE;
|
|---|
| 3371 | return TRUE;
|
|---|
| 3372 | case DATE_LONGDATE:
|
|---|
| 3373 | if(!(*lpDateFmtEnumProc)("dd MMMM yyyy")) return TRUE;
|
|---|
| 3374 | if(!(*lpDateFmtEnumProc)("d MMMM yyyy")) return TRUE;
|
|---|
| 3375 | return TRUE;
|
|---|
| 3376 | default:
|
|---|
| 3377 | FIXME("Unknown date format (%ld)\n", dwFlags);
|
|---|
| 3378 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 3379 | return FALSE;
|
|---|
| 3380 | }
|
|---|
| 3381 | }
|
|---|
| 3382 |
|
|---|
| 3383 | case 0x00000c09: /* (Loc,"en_AU") */
|
|---|
| 3384 | {
|
|---|
| 3385 | switch(dwFlags)
|
|---|
| 3386 | {
|
|---|
| 3387 | case DATE_SHORTDATE:
|
|---|
| 3388 | if(!(*lpDateFmtEnumProc)("d/MM/yy")) return TRUE;
|
|---|
| 3389 | if(!(*lpDateFmtEnumProc)("d/M/yy")) return TRUE;
|
|---|
| 3390 | if(!(*lpDateFmtEnumProc)("dd/MM/yy")) return TRUE;
|
|---|
| 3391 | return TRUE;
|
|---|
| 3392 | case DATE_LONGDATE:
|
|---|
| 3393 | if(!(*lpDateFmtEnumProc)("dddd,d MMMM yyyy")) return TRUE;
|
|---|
| 3394 | if(!(*lpDateFmtEnumProc)("d MMMM yyyy")) return TRUE;
|
|---|
| 3395 | return TRUE;
|
|---|
| 3396 | default:
|
|---|
| 3397 | FIXME("Unknown date format (%ld)\n", dwFlags);
|
|---|
| 3398 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 3399 | return FALSE;
|
|---|
| 3400 | }
|
|---|
| 3401 | }
|
|---|
| 3402 |
|
|---|
| 3403 | case 0x00001009: /* (Loc,"en_CA") */
|
|---|
| 3404 | {
|
|---|
| 3405 | switch(dwFlags)
|
|---|
| 3406 | {
|
|---|
| 3407 | case DATE_SHORTDATE:
|
|---|
| 3408 | if(!(*lpDateFmtEnumProc)("dd/MM/yy")) return TRUE;
|
|---|
| 3409 | if(!(*lpDateFmtEnumProc)("d/M/yy")) return TRUE;
|
|---|
| 3410 | if(!(*lpDateFmtEnumProc)("yy-MM-dd")) return TRUE;
|
|---|
| 3411 | if(!(*lpDateFmtEnumProc)("M/dd/yy")) return TRUE;
|
|---|
| 3412 | return TRUE;
|
|---|
| 3413 | case DATE_LONGDATE:
|
|---|
| 3414 | if(!(*lpDateFmtEnumProc)("d-MMM-yy")) return TRUE;
|
|---|
| 3415 | if(!(*lpDateFmtEnumProc)("MMMM d, yyyy")) return TRUE;
|
|---|
| 3416 | return TRUE;
|
|---|
| 3417 | default:
|
|---|
| 3418 | FIXME("Unknown date format (%ld)\n", dwFlags);
|
|---|
| 3419 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 3420 | return FALSE;
|
|---|
| 3421 | }
|
|---|
| 3422 | }
|
|---|
| 3423 |
|
|---|
| 3424 | case 0x00001409: /* (Loc,"en_NZ") */
|
|---|
| 3425 | {
|
|---|
| 3426 | switch(dwFlags)
|
|---|
| 3427 | {
|
|---|
| 3428 | case DATE_SHORTDATE:
|
|---|
| 3429 | if(!(*lpDateFmtEnumProc)("d/MM/yy")) return TRUE;
|
|---|
| 3430 | if(!(*lpDateFmtEnumProc)("dd/MM/yy")) return TRUE;
|
|---|
| 3431 | if(!(*lpDateFmtEnumProc)("d.MM.yy")) return TRUE;
|
|---|
| 3432 | return TRUE;
|
|---|
| 3433 | case DATE_LONGDATE:
|
|---|
| 3434 | if(!(*lpDateFmtEnumProc)("d MMMM yyyy")) return TRUE;
|
|---|
| 3435 | if(!(*lpDateFmtEnumProc)("dddd, d MMMM yyyy")) return TRUE;
|
|---|
| 3436 | return TRUE;
|
|---|
| 3437 | default:
|
|---|
| 3438 | FIXME("Unknown date format (%ld)\n", dwFlags);
|
|---|
| 3439 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 3440 | return FALSE;
|
|---|
| 3441 | }
|
|---|
| 3442 | }
|
|---|
| 3443 |
|
|---|
| 3444 | case 0x00001809: /* (Loc,"en_IE") */
|
|---|
| 3445 | {
|
|---|
| 3446 | switch(dwFlags)
|
|---|
| 3447 | {
|
|---|
| 3448 | case DATE_SHORTDATE:
|
|---|
| 3449 | if(!(*lpDateFmtEnumProc)("dd/MM/yy")) return TRUE;
|
|---|
| 3450 | if(!(*lpDateFmtEnumProc)("d/M/yy")) return TRUE;
|
|---|
| 3451 | if(!(*lpDateFmtEnumProc)("d.M.yy")) return TRUE;
|
|---|
| 3452 | return TRUE;
|
|---|
| 3453 | case DATE_LONGDATE:
|
|---|
| 3454 | if(!(*lpDateFmtEnumProc)("dd MMMM yyyy")) return TRUE;
|
|---|
| 3455 | if(!(*lpDateFmtEnumProc)("d MMMM yyyy")) return TRUE;
|
|---|
| 3456 | return TRUE;
|
|---|
| 3457 | default:
|
|---|
| 3458 | FIXME("Unknown date format (%ld)\n", dwFlags);
|
|---|
| 3459 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 3460 | return FALSE;
|
|---|
| 3461 | }
|
|---|
| 3462 | }
|
|---|
| 3463 |
|
|---|
| 3464 | case 0x00001c09: /* (Loc,"en_ZA") */
|
|---|
| 3465 | {
|
|---|
| 3466 | switch(dwFlags)
|
|---|
| 3467 | {
|
|---|
| 3468 | case DATE_SHORTDATE:
|
|---|
| 3469 | if(!(*lpDateFmtEnumProc)("yy/MM/dd")) return TRUE;
|
|---|
| 3470 | return TRUE;
|
|---|
| 3471 | case DATE_LONGDATE:
|
|---|
| 3472 | if(!(*lpDateFmtEnumProc)("dd MMMM yyyy")) return TRUE;
|
|---|
| 3473 | return TRUE;
|
|---|
| 3474 | default:
|
|---|
| 3475 | FIXME("Unknown date format (%ld)\n", dwFlags);
|
|---|
| 3476 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 3477 | return FALSE;
|
|---|
| 3478 | }
|
|---|
| 3479 | }
|
|---|
| 3480 |
|
|---|
| 3481 | case 0x00002009: /* (Loc,"en_JM") */
|
|---|
| 3482 | {
|
|---|
| 3483 | switch(dwFlags)
|
|---|
| 3484 | {
|
|---|
| 3485 | case DATE_SHORTDATE:
|
|---|
| 3486 | if(!(*lpDateFmtEnumProc)("dd/MM/yyyy")) return TRUE;
|
|---|
| 3487 | return TRUE;
|
|---|
| 3488 | case DATE_LONGDATE:
|
|---|
| 3489 | if(!(*lpDateFmtEnumProc)("dddd,MMMM dd,yyyy")) return TRUE;
|
|---|
| 3490 | if(!(*lpDateFmtEnumProc)("MMMM dd,yyyy")) return TRUE;
|
|---|
| 3491 | if(!(*lpDateFmtEnumProc)("dddd,dd MMMM,yyyy")) return TRUE;
|
|---|
| 3492 | if(!(*lpDateFmtEnumProc)("dd MMMM,yyyy")) return TRUE;
|
|---|
| 3493 | return TRUE;
|
|---|
| 3494 | default:
|
|---|
| 3495 | FIXME("Unknown date format (%ld)\n", dwFlags);
|
|---|
| 3496 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 3497 | return FALSE;
|
|---|
| 3498 | }
|
|---|
| 3499 | }
|
|---|
| 3500 |
|
|---|
| 3501 | case 0x00002809: /* (Loc,"en_BZ") */
|
|---|
| 3502 | case 0x00002c09: /* (Loc,"en_TT") */
|
|---|
| 3503 | {
|
|---|
| 3504 | switch(dwFlags)
|
|---|
| 3505 | {
|
|---|
| 3506 | case DATE_SHORTDATE:
|
|---|
| 3507 | if(!(*lpDateFmtEnumProc)("dd/MM/yyyy")) return TRUE;
|
|---|
| 3508 | return TRUE;
|
|---|
| 3509 | case DATE_LONGDATE:
|
|---|
| 3510 | if(!(*lpDateFmtEnumProc)("dddd,dd MMMM yyyy")) return TRUE;
|
|---|
| 3511 | return TRUE;
|
|---|
| 3512 | default:
|
|---|
| 3513 | FIXME("Unknown date format (%ld)\n", dwFlags);
|
|---|
| 3514 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 3515 | return FALSE;
|
|---|
| 3516 | }
|
|---|
| 3517 | }
|
|---|
| 3518 |
|
|---|
| 3519 | default: /* default to US English "en_US" */
|
|---|
| 3520 | {
|
|---|
| 3521 | switch(dwFlags)
|
|---|
| 3522 | {
|
|---|
| 3523 | case DATE_SHORTDATE:
|
|---|
| 3524 | if(!(*lpDateFmtEnumProc)("M/d/yy")) return TRUE;
|
|---|
| 3525 | if(!(*lpDateFmtEnumProc)("M/d/yyyy")) return TRUE;
|
|---|
| 3526 | if(!(*lpDateFmtEnumProc)("MM/dd/yy")) return TRUE;
|
|---|
| 3527 | if(!(*lpDateFmtEnumProc)("MM/dd/yyyy")) return TRUE;
|
|---|
| 3528 | if(!(*lpDateFmtEnumProc)("yy/MM/dd")) return TRUE;
|
|---|
| 3529 | if(!(*lpDateFmtEnumProc)("dd-MMM-yy")) return TRUE;
|
|---|
| 3530 | return TRUE;
|
|---|
| 3531 | case DATE_LONGDATE:
|
|---|
| 3532 | if(!(*lpDateFmtEnumProc)("dddd, MMMM dd, yyyy")) return TRUE;
|
|---|
| 3533 | if(!(*lpDateFmtEnumProc)("MMMM dd, yyyy")) return TRUE;
|
|---|
| 3534 | if(!(*lpDateFmtEnumProc)("dddd, dd MMMM, yyyy")) return TRUE;
|
|---|
| 3535 | if(!(*lpDateFmtEnumProc)("dd MMMM, yyyy")) return TRUE;
|
|---|
| 3536 | return TRUE;
|
|---|
| 3537 | default:
|
|---|
| 3538 | FIXME("Unknown date format (%ld)\n", dwFlags);
|
|---|
| 3539 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 3540 | return FALSE;
|
|---|
| 3541 | }
|
|---|
| 3542 | }
|
|---|
| 3543 | }
|
|---|
| 3544 | }
|
|---|
| 3545 |
|
|---|
| 3546 | /**************************************************************************
|
|---|
| 3547 | * EnumDateFormatsW (KERNEL32.199)
|
|---|
| 3548 | */
|
|---|
| 3549 | BOOL WINAPI EnumDateFormatsW(
|
|---|
| 3550 | DATEFMT_ENUMPROCW lpDateFmtEnumProc, LCID Locale, DWORD dwFlags)
|
|---|
| 3551 | {
|
|---|
| 3552 | FIXME("(%p, %ld, %ld): stub\n", lpDateFmtEnumProc, Locale, dwFlags);
|
|---|
| 3553 | SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|---|
| 3554 | return FALSE;
|
|---|
| 3555 | }
|
|---|
| 3556 |
|
|---|
| 3557 | /**************************************************************************
|
|---|
| 3558 | * EnumTimeFormatsA (KERNEL32.210)
|
|---|
| 3559 | */
|
|---|
| 3560 | BOOL WINAPI EnumTimeFormatsA(
|
|---|
| 3561 | TIMEFMT_ENUMPROCA lpTimeFmtEnumProc, LCID Locale, DWORD dwFlags)
|
|---|
| 3562 | {
|
|---|
| 3563 | LCID Loc = GetUserDefaultLCID();
|
|---|
| 3564 | if(!lpTimeFmtEnumProc)
|
|---|
| 3565 | {
|
|---|
| 3566 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 3567 | return FALSE;
|
|---|
| 3568 | }
|
|---|
| 3569 | if(dwFlags)
|
|---|
| 3570 | {
|
|---|
| 3571 | FIXME("Unknown time format (%ld)\n", dwFlags);
|
|---|
| 3572 | }
|
|---|
| 3573 |
|
|---|
| 3574 | switch( Loc )
|
|---|
| 3575 | {
|
|---|
| 3576 | case 0x00000407: /* (Loc,"de_DE") */
|
|---|
| 3577 | {
|
|---|
| 3578 | if(!(*lpTimeFmtEnumProc)("HH.mm")) return TRUE;
|
|---|
| 3579 | if(!(*lpTimeFmtEnumProc)("HH:mm:ss")) return TRUE;
|
|---|
| 3580 | if(!(*lpTimeFmtEnumProc)("H:mm:ss")) return TRUE;
|
|---|
| 3581 | if(!(*lpTimeFmtEnumProc)("H.mm")) return TRUE;
|
|---|
| 3582 | if(!(*lpTimeFmtEnumProc)("H.mm'Uhr'")) return TRUE;
|
|---|
| 3583 | return TRUE;
|
|---|
| 3584 | }
|
|---|
| 3585 |
|
|---|
| 3586 | case 0x0000040c: /* (Loc,"fr_FR") */
|
|---|
| 3587 | case 0x00000c0c: /* (Loc,"fr_CA") */
|
|---|
| 3588 | {
|
|---|
| 3589 | if(!(*lpTimeFmtEnumProc)("H:mm")) return TRUE;
|
|---|
| 3590 | if(!(*lpTimeFmtEnumProc)("HH:mm:ss")) return TRUE;
|
|---|
| 3591 | if(!(*lpTimeFmtEnumProc)("H:mm:ss")) return TRUE;
|
|---|
| 3592 | if(!(*lpTimeFmtEnumProc)("HH.mm")) return TRUE;
|
|---|
| 3593 | if(!(*lpTimeFmtEnumProc)("HH'h'mm")) return TRUE;
|
|---|
| 3594 | return TRUE;
|
|---|
| 3595 | }
|
|---|
| 3596 |
|
|---|
| 3597 | case 0x00000809: /* (Loc,"en_UK") */
|
|---|
| 3598 | case 0x00000c09: /* (Loc,"en_AU") */
|
|---|
| 3599 | case 0x00001409: /* (Loc,"en_NZ") */
|
|---|
| 3600 | case 0x00001809: /* (Loc,"en_IE") */
|
|---|
| 3601 | {
|
|---|
| 3602 | if(!(*lpTimeFmtEnumProc)("h:mm:ss tt")) return TRUE;
|
|---|
| 3603 | if(!(*lpTimeFmtEnumProc)("HH:mm:ss")) return TRUE;
|
|---|
| 3604 | if(!(*lpTimeFmtEnumProc)("H:mm:ss")) return TRUE;
|
|---|
| 3605 | return TRUE;
|
|---|
| 3606 | }
|
|---|
| 3607 |
|
|---|
| 3608 | case 0x00001c09: /* (Loc,"en_ZA") */
|
|---|
| 3609 | case 0x00002809: /* (Loc,"en_BZ") */
|
|---|
| 3610 | case 0x00002c09: /* (Loc,"en_TT") */
|
|---|
| 3611 | {
|
|---|
| 3612 | if(!(*lpTimeFmtEnumProc)("h:mm:ss tt")) return TRUE;
|
|---|
| 3613 | if(!(*lpTimeFmtEnumProc)("hh:mm:ss tt")) return TRUE;
|
|---|
| 3614 | return TRUE;
|
|---|
| 3615 | }
|
|---|
| 3616 |
|
|---|
| 3617 | default: /* default to US style "en_US" */
|
|---|
| 3618 | {
|
|---|
| 3619 | if(!(*lpTimeFmtEnumProc)("h:mm:ss tt")) return TRUE;
|
|---|
| 3620 | if(!(*lpTimeFmtEnumProc)("hh:mm:ss tt")) return TRUE;
|
|---|
| 3621 | if(!(*lpTimeFmtEnumProc)("H:mm:ss")) return TRUE;
|
|---|
| 3622 | if(!(*lpTimeFmtEnumProc)("HH:mm:ss")) return TRUE;
|
|---|
| 3623 | return TRUE;
|
|---|
| 3624 | }
|
|---|
| 3625 | }
|
|---|
| 3626 | }
|
|---|
| 3627 |
|
|---|
| 3628 | /**************************************************************************
|
|---|
| 3629 | * EnumTimeFormatsW (KERNEL32.211)
|
|---|
| 3630 | */
|
|---|
| 3631 | BOOL WINAPI EnumTimeFormatsW(
|
|---|
| 3632 | TIMEFMT_ENUMPROCW lpTimeFmtEnumProc, LCID Locale, DWORD dwFlags)
|
|---|
| 3633 | {
|
|---|
| 3634 | FIXME("(%p,%ld,%ld): stub\n", lpTimeFmtEnumProc, Locale, dwFlags);
|
|---|
| 3635 | SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|---|
| 3636 | return FALSE;
|
|---|
| 3637 | }
|
|---|
| 3638 |
|
|---|
| 3639 | /**************************************************************************
|
|---|
| 3640 | * This function is used just locally !
|
|---|
| 3641 | * Description: Inverts a string.
|
|---|
| 3642 | */
|
|---|
| 3643 | static void OLE_InvertString(char* string)
|
|---|
| 3644 | {
|
|---|
| 3645 | char sTmpArray[128];
|
|---|
| 3646 | INT counter, i = 0;
|
|---|
| 3647 |
|
|---|
| 3648 | for (counter = strlen(string); counter > 0; counter--)
|
|---|
| 3649 | {
|
|---|
| 3650 | memcpy(sTmpArray + i, string + counter-1, 1);
|
|---|
| 3651 | i++;
|
|---|
| 3652 | }
|
|---|
| 3653 | memcpy(sTmpArray + i, "\0", 1);
|
|---|
| 3654 | strcpy(string, sTmpArray);
|
|---|
| 3655 | }
|
|---|
| 3656 |
|
|---|
| 3657 | /***************************************************************************************
|
|---|
| 3658 | * This function is used just locally !
|
|---|
| 3659 | * Description: Test if the given string (psNumber) is valid or not.
|
|---|
| 3660 | * The valid characters are the following:
|
|---|
| 3661 | * - Characters '0' through '9'.
|
|---|
| 3662 | * - One decimal point (dot) if the number is a floating-point value.
|
|---|
| 3663 | * - A minus sign in the first character position if the number is
|
|---|
| 3664 | * a negative value.
|
|---|
| 3665 | * If the function succeeds, psBefore/psAfter will point to the string
|
|---|
| 3666 | * on the right/left of the decimal symbol. pbNegative indicates if the
|
|---|
| 3667 | * number is negative.
|
|---|
| 3668 | */
|
|---|
| 3669 | static INT OLE_GetNumberComponents(char* pInput, char* psBefore, char* psAfter, BOOL* pbNegative)
|
|---|
| 3670 | {
|
|---|
| 3671 | char sNumberSet[] = "0123456789";
|
|---|
| 3672 | BOOL bInDecimal = FALSE;
|
|---|
| 3673 |
|
|---|
| 3674 | /* Test if we do have a minus sign */
|
|---|
| 3675 | if ( *pInput == '-' )
|
|---|
| 3676 | {
|
|---|
| 3677 | *pbNegative = TRUE;
|
|---|
| 3678 | pInput++; /* Jump to the next character. */
|
|---|
| 3679 | }
|
|---|
| 3680 |
|
|---|
| 3681 | while(*pInput != '\0')
|
|---|
| 3682 | {
|
|---|
| 3683 | /* Do we have a valid numeric character */
|
|---|
| 3684 | if ( strchr(sNumberSet, *pInput) != NULL )
|
|---|
| 3685 | {
|
|---|
| 3686 | if (bInDecimal == TRUE)
|
|---|
| 3687 | *psAfter++ = *pInput;
|
|---|
| 3688 | else
|
|---|
| 3689 | *psBefore++ = *pInput;
|
|---|
| 3690 | }
|
|---|
| 3691 | else
|
|---|
| 3692 | {
|
|---|
| 3693 | /* Is this a decimal point (dot) */
|
|---|
| 3694 | if ( *pInput == '.' )
|
|---|
| 3695 | {
|
|---|
| 3696 | /* Is it the first time we find it */
|
|---|
| 3697 | if ((bInDecimal == FALSE))
|
|---|
| 3698 | bInDecimal = TRUE;
|
|---|
| 3699 | else
|
|---|
| 3700 | return -1; /* ERROR: Invalid parameter */
|
|---|
| 3701 | }
|
|---|
| 3702 | else
|
|---|
| 3703 | {
|
|---|
| 3704 | /* It's neither a numeric character, nor a decimal point.
|
|---|
| 3705 | * Thus, return an error.
|
|---|
| 3706 | */
|
|---|
| 3707 | return -1;
|
|---|
| 3708 | }
|
|---|
| 3709 | }
|
|---|
| 3710 | pInput++;
|
|---|
| 3711 | }
|
|---|
| 3712 |
|
|---|
| 3713 | /* Add an End of Line character to the output buffers */
|
|---|
| 3714 | *psBefore = '\0';
|
|---|
| 3715 | *psAfter = '\0';
|
|---|
| 3716 |
|
|---|
| 3717 | return 0;
|
|---|
| 3718 | }
|
|---|
| 3719 |
|
|---|
| 3720 | /**************************************************************************
|
|---|
| 3721 | * This function is used just locally !
|
|---|
| 3722 | * Description: A number could be formatted using different numbers
|
|---|
| 3723 | * of "digits in group" (example: 4;3;2;0).
|
|---|
| 3724 | * The first parameter of this function is an array
|
|---|
| 3725 | * containing the rule to be used. It's format is the following:
|
|---|
| 3726 | * |NDG|DG1|DG2|...|0|
|
|---|
| 3727 | * where NDG is the number of used "digits in group" and DG1, DG2,
|
|---|
| 3728 | * are the corresponding "digits in group".
|
|---|
| 3729 | * Thus, this function returns the grouping value in the array
|
|---|
| 3730 | * pointed by the second parameter.
|
|---|
| 3731 | */
|
|---|
| 3732 | static INT OLE_GetGrouping(char* sRule, INT index)
|
|---|
| 3733 | {
|
|---|
| 3734 | char sData[2], sRuleSize[2];
|
|---|
| 3735 | INT nData, nRuleSize;
|
|---|
| 3736 |
|
|---|
| 3737 | memcpy(sRuleSize, sRule, 1);
|
|---|
| 3738 | memcpy(sRuleSize+1, "\0", 1);
|
|---|
| 3739 | nRuleSize = atoi(sRuleSize);
|
|---|
| 3740 |
|
|---|
| 3741 | if (index > 0 && index < nRuleSize)
|
|---|
| 3742 | {
|
|---|
| 3743 | memcpy(sData, sRule+index, 1);
|
|---|
| 3744 | memcpy(sData+1, "\0", 1);
|
|---|
| 3745 | nData = atoi(sData);
|
|---|
| 3746 | }
|
|---|
| 3747 |
|
|---|
| 3748 | else
|
|---|
| 3749 | {
|
|---|
| 3750 | memcpy(sData, sRule+nRuleSize-1, 1);
|
|---|
| 3751 | memcpy(sData+1, "\0", 1);
|
|---|
| 3752 | nData = atoi(sData);
|
|---|
| 3753 | }
|
|---|
| 3754 |
|
|---|
| 3755 | return nData;
|
|---|
| 3756 | }
|
|---|
| 3757 |
|
|---|
| 3758 | /**************************************************************************
|
|---|
| 3759 | * GetNumberFormatA (KERNEL32.355)
|
|---|
| 3760 | */
|
|---|
| 3761 | INT WINAPI GetNumberFormatA(LCID locale, DWORD dwflags,
|
|---|
| 3762 | LPCSTR lpvalue, const NUMBERFMTA * lpFormat,
|
|---|
| 3763 | LPSTR lpNumberStr, int cchNumber)
|
|---|
| 3764 | {
|
|---|
| 3765 | char sNumberDigits[3], sDecimalSymbol[5], sDigitsInGroup[11], sDigitGroupSymbol[5], sILZero[2];
|
|---|
| 3766 | INT nNumberDigits, nNumberDecimal, i, j, nCounter, nStep, nRuleIndex, nGrouping, nDigits, retVal, nLZ;
|
|---|
| 3767 | char sNumber[128], sDestination[128], sDigitsAfterDecimal[10], sDigitsBeforeDecimal[128];
|
|---|
| 3768 | char sRule[10], sSemiColumn[]=";", sBuffer[5], sNegNumber[2];
|
|---|
| 3769 | char *pStr = NULL, *pTmpStr = NULL;
|
|---|
| 3770 | LCID systemDefaultLCID;
|
|---|
| 3771 | BOOL bNegative = FALSE;
|
|---|
| 3772 | enum Operations
|
|---|
| 3773 | {
|
|---|
| 3774 | USE_PARAMETER,
|
|---|
| 3775 | USE_LOCALEINFO,
|
|---|
| 3776 | USE_SYSTEMDEFAULT,
|
|---|
| 3777 | RETURN_ERROR
|
|---|
| 3778 | } used_operation;
|
|---|
| 3779 |
|
|---|
| 3780 | strncpy(sNumber, lpvalue, 128);
|
|---|
| 3781 | sNumber[127] = '\0';
|
|---|
| 3782 |
|
|---|
| 3783 | /* Make sure we have a valid input string, get the number
|
|---|
| 3784 | * of digits before and after the decimal symbol, and check
|
|---|
| 3785 | * if this is a negative number.
|
|---|
| 3786 | */
|
|---|
| 3787 | if ( OLE_GetNumberComponents(sNumber, sDigitsBeforeDecimal, sDigitsAfterDecimal, &bNegative) != -1)
|
|---|
| 3788 | {
|
|---|
| 3789 | nNumberDecimal = strlen(sDigitsBeforeDecimal);
|
|---|
| 3790 | nDigits = strlen(sDigitsAfterDecimal);
|
|---|
| 3791 | }
|
|---|
| 3792 | else
|
|---|
| 3793 | {
|
|---|
| 3794 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 3795 | return 0;
|
|---|
| 3796 | }
|
|---|
| 3797 |
|
|---|
| 3798 | /* Which source will we use to format the string */
|
|---|
| 3799 | used_operation = RETURN_ERROR;
|
|---|
| 3800 | if (lpFormat != NULL)
|
|---|
| 3801 | {
|
|---|
| 3802 | if (dwflags == 0)
|
|---|
| 3803 | used_operation = USE_PARAMETER;
|
|---|
| 3804 | }
|
|---|
| 3805 | else
|
|---|
| 3806 | {
|
|---|
| 3807 | if (dwflags & LOCALE_NOUSEROVERRIDE)
|
|---|
| 3808 | used_operation = USE_LOCALEINFO;
|
|---|
| 3809 | else
|
|---|
| 3810 | used_operation = USE_SYSTEMDEFAULT;
|
|---|
| 3811 | }
|
|---|
| 3812 |
|
|---|
| 3813 | /* Load the fields we need */
|
|---|
| 3814 | switch(used_operation)
|
|---|
| 3815 | {
|
|---|
| 3816 | case USE_LOCALEINFO:
|
|---|
| 3817 | GetLocaleInfoA(locale, LOCALE_IDIGITS, sNumberDigits, sizeof(sNumberDigits));
|
|---|
| 3818 | GetLocaleInfoA(locale, LOCALE_SDECIMAL, sDecimalSymbol, sizeof(sDecimalSymbol));
|
|---|
| 3819 | GetLocaleInfoA(locale, LOCALE_SGROUPING, sDigitsInGroup, sizeof(sDigitsInGroup));
|
|---|
| 3820 | GetLocaleInfoA(locale, LOCALE_STHOUSAND, sDigitGroupSymbol, sizeof(sDigitGroupSymbol));
|
|---|
| 3821 | GetLocaleInfoA(locale, LOCALE_ILZERO, sILZero, sizeof(sILZero));
|
|---|
| 3822 | GetLocaleInfoA(locale, LOCALE_INEGNUMBER, sNegNumber, sizeof(sNegNumber));
|
|---|
| 3823 | break;
|
|---|
| 3824 | case USE_PARAMETER:
|
|---|
| 3825 | sprintf(sNumberDigits, "%d",lpFormat->NumDigits);
|
|---|
| 3826 | strcpy(sDecimalSymbol, lpFormat->lpDecimalSep);
|
|---|
| 3827 | sprintf(sDigitsInGroup, "%d;0",lpFormat->Grouping);
|
|---|
| 3828 | strcpy(sDigitGroupSymbol, lpFormat->lpThousandSep);
|
|---|
| 3829 | sprintf(sILZero, "%d",lpFormat->LeadingZero);
|
|---|
| 3830 | sprintf(sNegNumber, "%d",lpFormat->NegativeOrder);
|
|---|
| 3831 | break;
|
|---|
| 3832 | case USE_SYSTEMDEFAULT:
|
|---|
| 3833 | systemDefaultLCID = GetSystemDefaultLCID();
|
|---|
| 3834 | GetLocaleInfoA(systemDefaultLCID, LOCALE_IDIGITS, sNumberDigits, sizeof(sNumberDigits));
|
|---|
| 3835 | GetLocaleInfoA(systemDefaultLCID, LOCALE_SDECIMAL, sDecimalSymbol, sizeof(sDecimalSymbol));
|
|---|
| 3836 | GetLocaleInfoA(systemDefaultLCID, LOCALE_SGROUPING, sDigitsInGroup, sizeof(sDigitsInGroup));
|
|---|
| 3837 | GetLocaleInfoA(systemDefaultLCID, LOCALE_STHOUSAND, sDigitGroupSymbol, sizeof(sDigitGroupSymbol));
|
|---|
| 3838 | GetLocaleInfoA(systemDefaultLCID, LOCALE_ILZERO, sILZero, sizeof(sILZero));
|
|---|
| 3839 | GetLocaleInfoA(systemDefaultLCID, LOCALE_INEGNUMBER, sNegNumber, sizeof(sNegNumber));
|
|---|
| 3840 | break;
|
|---|
| 3841 | default:
|
|---|
| 3842 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 3843 | return 0;
|
|---|
| 3844 | }
|
|---|
| 3845 |
|
|---|
| 3846 | nNumberDigits = atoi(sNumberDigits);
|
|---|
| 3847 |
|
|---|
| 3848 | /* Remove the ";" */
|
|---|
| 3849 | i=0;
|
|---|
| 3850 | j = 1;
|
|---|
| 3851 | for (nCounter=0; nCounter<strlen(sDigitsInGroup); nCounter++)
|
|---|
| 3852 | {
|
|---|
| 3853 | if ( memcmp(sDigitsInGroup + nCounter, sSemiColumn, 1) != 0 )
|
|---|
| 3854 | {
|
|---|
| 3855 | memcpy(sRule + j, sDigitsInGroup + nCounter, 1);
|
|---|
| 3856 | i++;
|
|---|
| 3857 | j++;
|
|---|
| 3858 | }
|
|---|
| 3859 | }
|
|---|
| 3860 | sprintf(sBuffer, "%d", i);
|
|---|
| 3861 | memcpy(sRule, sBuffer, 1); /* Number of digits in the groups ( used by OLE_GetGrouping() ) */
|
|---|
| 3862 | memcpy(sRule + j, "\0", 1);
|
|---|
| 3863 |
|
|---|
| 3864 | /* First, format the digits before the decimal. */
|
|---|
| 3865 | if ((nNumberDecimal>0) && (atoi(sDigitsBeforeDecimal) != 0))
|
|---|
| 3866 | {
|
|---|
| 3867 | /* Working on an inverted string is easier ! */
|
|---|
| 3868 | OLE_InvertString(sDigitsBeforeDecimal);
|
|---|
| 3869 |
|
|---|
| 3870 | nStep = nCounter = i = j = 0;
|
|---|
| 3871 | nRuleIndex = 1;
|
|---|
| 3872 | nGrouping = OLE_GetGrouping(sRule, nRuleIndex);
|
|---|
| 3873 |
|
|---|
| 3874 | /* Here, we will loop until we reach the end of the string.
|
|---|
| 3875 | * An internal counter (j) is used in order to know when to
|
|---|
| 3876 | * insert the "digit group symbol".
|
|---|
| 3877 | */
|
|---|
| 3878 | while (nNumberDecimal > 0)
|
|---|
| 3879 | {
|
|---|
| 3880 | i = nCounter + nStep;
|
|---|
| 3881 | memcpy(sDestination + i, sDigitsBeforeDecimal + nCounter, 1);
|
|---|
| 3882 | nCounter++;
|
|---|
| 3883 | j++;
|
|---|
| 3884 | if (j >= nGrouping)
|
|---|
| 3885 | {
|
|---|
| 3886 | j = 0;
|
|---|
| 3887 | if (nRuleIndex < sRule[0])
|
|---|
| 3888 | nRuleIndex++;
|
|---|
| 3889 | nGrouping = OLE_GetGrouping(sRule, nRuleIndex);
|
|---|
| 3890 | memcpy(sDestination + i+1, sDigitGroupSymbol, strlen(sDigitGroupSymbol));
|
|---|
| 3891 | nStep+= strlen(sDigitGroupSymbol);
|
|---|
| 3892 | }
|
|---|
| 3893 |
|
|---|
| 3894 | nNumberDecimal--;
|
|---|
| 3895 | }
|
|---|
| 3896 |
|
|---|
| 3897 | memcpy(sDestination + i+1, "\0", 1);
|
|---|
| 3898 | /* Get the string in the right order ! */
|
|---|
| 3899 | OLE_InvertString(sDestination);
|
|---|
| 3900 | }
|
|---|
| 3901 | else
|
|---|
| 3902 | {
|
|---|
| 3903 | nLZ = atoi(sILZero);
|
|---|
| 3904 | if (nLZ != 0)
|
|---|
| 3905 | {
|
|---|
| 3906 | /* Use 0.xxx instead of .xxx */
|
|---|
| 3907 | memcpy(sDestination, "0", 1);
|
|---|
| 3908 | memcpy(sDestination+1, "\0", 1);
|
|---|
| 3909 | }
|
|---|
| 3910 | else
|
|---|
| 3911 | memcpy(sDestination, "\0", 1);
|
|---|
| 3912 |
|
|---|
| 3913 | }
|
|---|
| 3914 |
|
|---|
| 3915 | /* Second, format the digits after the decimal. */
|
|---|
| 3916 | j = 0;
|
|---|
| 3917 | nCounter = nNumberDigits;
|
|---|
| 3918 | if ( (nDigits>0) && (pStr = strstr (sNumber, ".")) )
|
|---|
| 3919 | {
|
|---|
| 3920 | i = strlen(sNumber) - strlen(pStr) + 1;
|
|---|
| 3921 | strncpy ( sDigitsAfterDecimal, sNumber + i, nNumberDigits);
|
|---|
| 3922 | j = strlen(sDigitsAfterDecimal);
|
|---|
| 3923 | if (j < nNumberDigits)
|
|---|
| 3924 | nCounter = nNumberDigits-j;
|
|---|
| 3925 | }
|
|---|
| 3926 | for (i=0;i<nCounter;i++)
|
|---|
| 3927 | memcpy(sDigitsAfterDecimal+i+j, "0", 1);
|
|---|
| 3928 | memcpy(sDigitsAfterDecimal + nNumberDigits, "\0", 1);
|
|---|
| 3929 |
|
|---|
| 3930 | i = strlen(sDestination);
|
|---|
| 3931 | j = strlen(sDigitsAfterDecimal);
|
|---|
| 3932 | /* Finally, construct the resulting formatted string. */
|
|---|
| 3933 |
|
|---|
| 3934 | for (nCounter=0; nCounter<i; nCounter++)
|
|---|
| 3935 | memcpy(sNumber + nCounter, sDestination + nCounter, 1);
|
|---|
| 3936 |
|
|---|
| 3937 | memcpy(sNumber + nCounter, sDecimalSymbol, strlen(sDecimalSymbol));
|
|---|
| 3938 |
|
|---|
| 3939 | for (i=0; i<j; i++)
|
|---|
| 3940 | memcpy(sNumber + nCounter+i+strlen(sDecimalSymbol), sDigitsAfterDecimal + i, 1);
|
|---|
| 3941 | memcpy(sNumber + nCounter+i+strlen(sDecimalSymbol), "\0", 1);
|
|---|
| 3942 |
|
|---|
| 3943 | /* Is it a negative number */
|
|---|
| 3944 | if (bNegative == TRUE)
|
|---|
| 3945 | {
|
|---|
| 3946 | i = atoi(sNegNumber);
|
|---|
| 3947 | pStr = sDestination;
|
|---|
| 3948 | pTmpStr = sNumber;
|
|---|
| 3949 | switch (i)
|
|---|
| 3950 | {
|
|---|
| 3951 | case 0:
|
|---|
| 3952 | *pStr++ = '(';
|
|---|
| 3953 | while (*sNumber != '\0')
|
|---|
| 3954 | *pStr++ = *pTmpStr++;
|
|---|
| 3955 | *pStr++ = ')';
|
|---|
| 3956 | break;
|
|---|
| 3957 | case 1:
|
|---|
| 3958 | *pStr++ = '-';
|
|---|
| 3959 | while (*pTmpStr != '\0')
|
|---|
| 3960 | *pStr++ = *pTmpStr++;
|
|---|
| 3961 | break;
|
|---|
| 3962 | case 2:
|
|---|
| 3963 | *pStr++ = '-';
|
|---|
| 3964 | *pStr++ = ' ';
|
|---|
| 3965 | while (*pTmpStr != '\0')
|
|---|
| 3966 | *pStr++ = *pTmpStr++;
|
|---|
| 3967 | break;
|
|---|
| 3968 | case 3:
|
|---|
| 3969 | while (*pTmpStr != '\0')
|
|---|
| 3970 | *pStr++ = *pTmpStr++;
|
|---|
| 3971 | *pStr++ = '-';
|
|---|
| 3972 | break;
|
|---|
| 3973 | case 4:
|
|---|
| 3974 | while (*pTmpStr != '\0')
|
|---|
| 3975 | *pStr++ = *pTmpStr++;
|
|---|
| 3976 | *pStr++ = ' ';
|
|---|
| 3977 | *pStr++ = '-';
|
|---|
| 3978 | break;
|
|---|
| 3979 | default:
|
|---|
| 3980 | while (*pTmpStr != '\0')
|
|---|
| 3981 | *pStr++ = *pTmpStr++;
|
|---|
| 3982 | break;
|
|---|
| 3983 | }
|
|---|
| 3984 | }
|
|---|
| 3985 | else
|
|---|
| 3986 | strcpy(sDestination, sNumber);
|
|---|
| 3987 |
|
|---|
| 3988 | /* If cchNumber is zero, then returns the number of bytes or characters
|
|---|
| 3989 | * required to hold the formatted number string
|
|---|
| 3990 | */
|
|---|
| 3991 | if (cchNumber==0)
|
|---|
| 3992 | retVal = strlen(sDestination) + 1;
|
|---|
| 3993 | else
|
|---|
| 3994 | {
|
|---|
| 3995 | strncpy (lpNumberStr, sDestination, cchNumber-1);
|
|---|
| 3996 | *(lpNumberStr+cchNumber-1) = '\0'; /* ensure we got a NULL at the end */
|
|---|
| 3997 | retVal = strlen(lpNumberStr);
|
|---|
| 3998 | }
|
|---|
| 3999 |
|
|---|
| 4000 | return retVal;
|
|---|
| 4001 | }
|
|---|
| 4002 |
|
|---|
| 4003 | /**************************************************************************
|
|---|
| 4004 | * GetNumberFormatW (KERNEL32.@)
|
|---|
| 4005 | */
|
|---|
| 4006 | INT WINAPI GetNumberFormatW(LCID locale, DWORD dwflags,
|
|---|
| 4007 | LPCWSTR lpvalue, const NUMBERFMTW * lpFormat,
|
|---|
| 4008 | LPWSTR lpNumberStr, int cchNumber)
|
|---|
| 4009 | {
|
|---|
| 4010 | FIXME("%s: stub, no reformating done\n",debugstr_w(lpvalue));
|
|---|
| 4011 |
|
|---|
| 4012 | lstrcpynW( lpNumberStr, lpvalue, cchNumber );
|
|---|
| 4013 | return cchNumber? strlenW( lpNumberStr ) : 0;
|
|---|
| 4014 | }
|
|---|
| 4015 |
|
|---|
| 4016 | /**************************************************************************
|
|---|
| 4017 | * GetCurrencyFormatA (KERNEL32.302)
|
|---|
| 4018 | */
|
|---|
| 4019 | INT WINAPI GetCurrencyFormatA(LCID locale, DWORD dwflags,
|
|---|
| 4020 | LPCSTR lpvalue, const CURRENCYFMTA * lpFormat,
|
|---|
| 4021 | LPSTR lpCurrencyStr, int cchCurrency)
|
|---|
| 4022 | {
|
|---|
| 4023 | UINT nPosOrder, nNegOrder;
|
|---|
| 4024 | INT retVal;
|
|---|
| 4025 | char sDestination[128], sNegOrder[8], sPosOrder[8], sCurrencySymbol[8];
|
|---|
| 4026 | char *pDestination = sDestination;
|
|---|
| 4027 | char sNumberFormated[128];
|
|---|
| 4028 | char *pNumberFormated = sNumberFormated;
|
|---|
| 4029 | LCID systemDefaultLCID;
|
|---|
| 4030 | BOOL bIsPositive = FALSE, bValidFormat = FALSE;
|
|---|
| 4031 | enum Operations
|
|---|
| 4032 | {
|
|---|
| 4033 | USE_PARAMETER,
|
|---|
| 4034 | USE_LOCALEINFO,
|
|---|
| 4035 | USE_SYSTEMDEFAULT,
|
|---|
| 4036 | RETURN_ERROR
|
|---|
| 4037 | } used_operation;
|
|---|
| 4038 |
|
|---|
| 4039 | NUMBERFMTA numberFmt;
|
|---|
| 4040 |
|
|---|
| 4041 | /* Which source will we use to format the string */
|
|---|
| 4042 | used_operation = RETURN_ERROR;
|
|---|
| 4043 | if (lpFormat != NULL)
|
|---|
| 4044 | {
|
|---|
| 4045 | if (dwflags == 0)
|
|---|
| 4046 | used_operation = USE_PARAMETER;
|
|---|
| 4047 | }
|
|---|
| 4048 | else
|
|---|
| 4049 | {
|
|---|
| 4050 | if (dwflags & LOCALE_NOUSEROVERRIDE)
|
|---|
| 4051 | used_operation = USE_LOCALEINFO;
|
|---|
| 4052 | else
|
|---|
| 4053 | used_operation = USE_SYSTEMDEFAULT;
|
|---|
| 4054 | }
|
|---|
| 4055 |
|
|---|
| 4056 | /* Load the fields we need */
|
|---|
| 4057 | switch(used_operation)
|
|---|
| 4058 | {
|
|---|
| 4059 | case USE_LOCALEINFO:
|
|---|
| 4060 | /* Specific to CURRENCYFMTA*/
|
|---|
| 4061 | GetLocaleInfoA(locale, LOCALE_INEGCURR, sNegOrder, sizeof(sNegOrder));
|
|---|
| 4062 | GetLocaleInfoA(locale, LOCALE_ICURRENCY, sPosOrder, sizeof(sPosOrder));
|
|---|
| 4063 | GetLocaleInfoA(locale, LOCALE_SCURRENCY, sCurrencySymbol, sizeof(sCurrencySymbol));
|
|---|
| 4064 |
|
|---|
| 4065 | nPosOrder = atoi(sPosOrder);
|
|---|
| 4066 | nNegOrder = atoi(sNegOrder);
|
|---|
| 4067 | break;
|
|---|
| 4068 | case USE_PARAMETER:
|
|---|
| 4069 | /* Specific to CURRENCYFMTA*/
|
|---|
| 4070 | nNegOrder = lpFormat->NegativeOrder;
|
|---|
| 4071 | nPosOrder = lpFormat->PositiveOrder;
|
|---|
| 4072 | strcpy(sCurrencySymbol, lpFormat->lpCurrencySymbol);
|
|---|
| 4073 | break;
|
|---|
| 4074 | case USE_SYSTEMDEFAULT:
|
|---|
| 4075 | systemDefaultLCID = GetSystemDefaultLCID();
|
|---|
| 4076 | /* Specific to CURRENCYFMTA*/
|
|---|
| 4077 | GetLocaleInfoA(systemDefaultLCID, LOCALE_INEGCURR, sNegOrder, sizeof(sNegOrder));
|
|---|
| 4078 | GetLocaleInfoA(systemDefaultLCID, LOCALE_ICURRENCY, sPosOrder, sizeof(sPosOrder));
|
|---|
| 4079 | GetLocaleInfoA(systemDefaultLCID, LOCALE_SCURRENCY, sCurrencySymbol, sizeof(sCurrencySymbol));
|
|---|
| 4080 |
|
|---|
| 4081 | nPosOrder = atoi(sPosOrder);
|
|---|
| 4082 | nNegOrder = atoi(sNegOrder);
|
|---|
| 4083 | break;
|
|---|
| 4084 | default:
|
|---|
| 4085 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 4086 | return 0;
|
|---|
| 4087 | }
|
|---|
| 4088 |
|
|---|
| 4089 | /* Construct a temporary number format structure */
|
|---|
| 4090 | if (lpFormat != NULL)
|
|---|
| 4091 | {
|
|---|
| 4092 | numberFmt.NumDigits = lpFormat->NumDigits;
|
|---|
| 4093 | numberFmt.LeadingZero = lpFormat->LeadingZero;
|
|---|
| 4094 | numberFmt.Grouping = lpFormat->Grouping;
|
|---|
| 4095 | numberFmt.NegativeOrder = 0;
|
|---|
| 4096 | numberFmt.lpDecimalSep = lpFormat->lpDecimalSep;
|
|---|
| 4097 | numberFmt.lpThousandSep = lpFormat->lpThousandSep;
|
|---|
| 4098 | bValidFormat = TRUE;
|
|---|
| 4099 | }
|
|---|
| 4100 |
|
|---|
| 4101 | /* Make a call to GetNumberFormatA() */
|
|---|
| 4102 | if (*lpvalue == '-')
|
|---|
| 4103 | {
|
|---|
| 4104 | bIsPositive = FALSE;
|
|---|
| 4105 | retVal = GetNumberFormatA(locale,0,lpvalue+1,(bValidFormat)?&numberFmt:NULL,pNumberFormated,128);
|
|---|
| 4106 | }
|
|---|
| 4107 | else
|
|---|
| 4108 | {
|
|---|
| 4109 | bIsPositive = TRUE;
|
|---|
| 4110 | retVal = GetNumberFormatA(locale,0,lpvalue,(bValidFormat)?&numberFmt:NULL,pNumberFormated,128);
|
|---|
| 4111 | }
|
|---|
| 4112 |
|
|---|
| 4113 | if (retVal == 0)
|
|---|
| 4114 | return 0;
|
|---|
| 4115 |
|
|---|
| 4116 | /* construct the formatted string */
|
|---|
| 4117 | if (bIsPositive)
|
|---|
| 4118 | {
|
|---|
| 4119 | switch (nPosOrder)
|
|---|
| 4120 | {
|
|---|
| 4121 | case 0: /* Prefix, no separation */
|
|---|
| 4122 | strcpy (pDestination, sCurrencySymbol);
|
|---|
| 4123 | strcat (pDestination, pNumberFormated);
|
|---|
| 4124 | break;
|
|---|
| 4125 | case 1: /* Suffix, no separation */
|
|---|
| 4126 | strcpy (pDestination, pNumberFormated);
|
|---|
| 4127 | strcat (pDestination, sCurrencySymbol);
|
|---|
| 4128 | break;
|
|---|
| 4129 | case 2: /* Prefix, 1 char separation */
|
|---|
| 4130 | strcpy (pDestination, sCurrencySymbol);
|
|---|
| 4131 | strcat (pDestination, " ");
|
|---|
| 4132 | strcat (pDestination, pNumberFormated);
|
|---|
| 4133 | break;
|
|---|
| 4134 | case 3: /* Suffix, 1 char separation */
|
|---|
| 4135 | strcpy (pDestination, pNumberFormated);
|
|---|
| 4136 | strcat (pDestination, " ");
|
|---|
| 4137 | strcat (pDestination, sCurrencySymbol);
|
|---|
| 4138 | break;
|
|---|
| 4139 | default:
|
|---|
| 4140 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 4141 | return 0;
|
|---|
| 4142 | }
|
|---|
| 4143 | }
|
|---|
| 4144 | else /* negative number */
|
|---|
| 4145 | {
|
|---|
| 4146 | switch (nNegOrder)
|
|---|
| 4147 | {
|
|---|
| 4148 | case 0: /* format: ($1.1) */
|
|---|
| 4149 | strcpy (pDestination, "(");
|
|---|
| 4150 | strcat (pDestination, sCurrencySymbol);
|
|---|
| 4151 | strcat (pDestination, pNumberFormated);
|
|---|
| 4152 | strcat (pDestination, ")");
|
|---|
| 4153 | break;
|
|---|
| 4154 | case 1: /* format: -$1.1 */
|
|---|
| 4155 | strcpy (pDestination, "-");
|
|---|
| 4156 | strcat (pDestination, sCurrencySymbol);
|
|---|
| 4157 | strcat (pDestination, pNumberFormated);
|
|---|
| 4158 | break;
|
|---|
| 4159 | case 2: /* format: $-1.1 */
|
|---|
| 4160 | strcpy (pDestination, sCurrencySymbol);
|
|---|
| 4161 | strcat (pDestination, "-");
|
|---|
| 4162 | strcat (pDestination, pNumberFormated);
|
|---|
| 4163 | break;
|
|---|
| 4164 | case 3: /* format: $1.1- */
|
|---|
| 4165 | strcpy (pDestination, sCurrencySymbol);
|
|---|
| 4166 | strcat (pDestination, pNumberFormated);
|
|---|
| 4167 | strcat (pDestination, "-");
|
|---|
| 4168 | break;
|
|---|
| 4169 | case 4: /* format: (1.1$) */
|
|---|
| 4170 | strcpy (pDestination, "(");
|
|---|
| 4171 | strcat (pDestination, pNumberFormated);
|
|---|
| 4172 | strcat (pDestination, sCurrencySymbol);
|
|---|
| 4173 | strcat (pDestination, ")");
|
|---|
| 4174 | break;
|
|---|
| 4175 | case 5: /* format: -1.1$ */
|
|---|
| 4176 | strcpy (pDestination, "-");
|
|---|
| 4177 | strcat (pDestination, pNumberFormated);
|
|---|
| 4178 | strcat (pDestination, sCurrencySymbol);
|
|---|
| 4179 | break;
|
|---|
| 4180 | case 6: /* format: 1.1-$ */
|
|---|
| 4181 | strcpy (pDestination, pNumberFormated);
|
|---|
| 4182 | strcat (pDestination, "-");
|
|---|
| 4183 | strcat (pDestination, sCurrencySymbol);
|
|---|
| 4184 | break;
|
|---|
| 4185 | case 7: /* format: 1.1$- */
|
|---|
| 4186 | strcpy (pDestination, pNumberFormated);
|
|---|
| 4187 | strcat (pDestination, sCurrencySymbol);
|
|---|
| 4188 | strcat (pDestination, "-");
|
|---|
| 4189 | break;
|
|---|
| 4190 | case 8: /* format: -1.1 $ */
|
|---|
| 4191 | strcpy (pDestination, "-");
|
|---|
| 4192 | strcat (pDestination, pNumberFormated);
|
|---|
| 4193 | strcat (pDestination, " ");
|
|---|
| 4194 | strcat (pDestination, sCurrencySymbol);
|
|---|
| 4195 | break;
|
|---|
| 4196 | case 9: /* format: -$ 1.1 */
|
|---|
| 4197 | strcpy (pDestination, "-");
|
|---|
| 4198 | strcat (pDestination, sCurrencySymbol);
|
|---|
| 4199 | strcat (pDestination, " ");
|
|---|
| 4200 | strcat (pDestination, pNumberFormated);
|
|---|
| 4201 | break;
|
|---|
| 4202 | case 10: /* format: 1.1 $- */
|
|---|
| 4203 | strcpy (pDestination, pNumberFormated);
|
|---|
| 4204 | strcat (pDestination, " ");
|
|---|
| 4205 | strcat (pDestination, sCurrencySymbol);
|
|---|
| 4206 | strcat (pDestination, "-");
|
|---|
| 4207 | break;
|
|---|
| 4208 | case 11: /* format: $ 1.1- */
|
|---|
| 4209 | strcpy (pDestination, sCurrencySymbol);
|
|---|
| 4210 | strcat (pDestination, " ");
|
|---|
| 4211 | strcat (pDestination, pNumberFormated);
|
|---|
| 4212 | strcat (pDestination, "-");
|
|---|
| 4213 | break;
|
|---|
| 4214 | case 12: /* format: $ -1.1 */
|
|---|
| 4215 | strcpy (pDestination, sCurrencySymbol);
|
|---|
| 4216 | strcat (pDestination, " ");
|
|---|
| 4217 | strcat (pDestination, "-");
|
|---|
| 4218 | strcat (pDestination, pNumberFormated);
|
|---|
| 4219 | break;
|
|---|
| 4220 | case 13: /* format: 1.1- $ */
|
|---|
| 4221 | strcpy (pDestination, pNumberFormated);
|
|---|
| 4222 | strcat (pDestination, "-");
|
|---|
| 4223 | strcat (pDestination, " ");
|
|---|
| 4224 | strcat (pDestination, sCurrencySymbol);
|
|---|
| 4225 | break;
|
|---|
| 4226 | case 14: /* format: ($ 1.1) */
|
|---|
| 4227 | strcpy (pDestination, "(");
|
|---|
| 4228 | strcat (pDestination, sCurrencySymbol);
|
|---|
| 4229 | strcat (pDestination, " ");
|
|---|
| 4230 | strcat (pDestination, pNumberFormated);
|
|---|
| 4231 | strcat (pDestination, ")");
|
|---|
| 4232 | break;
|
|---|
| 4233 | case 15: /* format: (1.1 $) */
|
|---|
| 4234 | strcpy (pDestination, "(");
|
|---|
| 4235 | strcat (pDestination, pNumberFormated);
|
|---|
| 4236 | strcat (pDestination, " ");
|
|---|
| 4237 | strcat (pDestination, sCurrencySymbol);
|
|---|
| 4238 | strcat (pDestination, ")");
|
|---|
| 4239 | break;
|
|---|
| 4240 | default:
|
|---|
| 4241 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 4242 | return 0;
|
|---|
| 4243 | }
|
|---|
| 4244 | }
|
|---|
| 4245 |
|
|---|
| 4246 | if (cchCurrency == 0)
|
|---|
| 4247 | return strlen(pDestination) + 1;
|
|---|
| 4248 |
|
|---|
| 4249 | else
|
|---|
| 4250 | {
|
|---|
| 4251 | strncpy (lpCurrencyStr, pDestination, cchCurrency-1);
|
|---|
| 4252 | *(lpCurrencyStr+cchCurrency-1) = '\0'; /* ensure we got a NULL at the end */
|
|---|
| 4253 | return strlen(lpCurrencyStr);
|
|---|
| 4254 | }
|
|---|
| 4255 | }
|
|---|
| 4256 |
|
|---|
| 4257 | /**************************************************************************
|
|---|
| 4258 | * GetCurrencyFormatW (KERNEL32.303)
|
|---|
| 4259 | */
|
|---|
| 4260 | INT WINAPI GetCurrencyFormatW(LCID locale, DWORD dwflags,
|
|---|
| 4261 | LPCWSTR lpvalue, const CURRENCYFMTW * lpFormat,
|
|---|
| 4262 | LPWSTR lpCurrencyStr, int cchCurrency)
|
|---|
| 4263 | {
|
|---|
| 4264 | FIXME("This API function is NOT implemented !\n");
|
|---|
| 4265 | return 0;
|
|---|
| 4266 | }
|
|---|
| 4267 |
|
|---|
| 4268 | /******************************************************************************
|
|---|
| 4269 | * OLE2NLS_CheckLocale [intern]
|
|---|
| 4270 | */
|
|---|
| 4271 | static LCID OLE2NLS_CheckLocale (LCID locale)
|
|---|
| 4272 | {
|
|---|
| 4273 | if (!locale)
|
|---|
| 4274 | { locale = LOCALE_SYSTEM_DEFAULT;
|
|---|
| 4275 | }
|
|---|
| 4276 |
|
|---|
| 4277 | if (locale == LOCALE_SYSTEM_DEFAULT)
|
|---|
| 4278 | { return GetSystemDefaultLCID();
|
|---|
| 4279 | }
|
|---|
| 4280 | else if (locale == LOCALE_USER_DEFAULT)
|
|---|
| 4281 | { return GetUserDefaultLCID();
|
|---|
| 4282 | }
|
|---|
| 4283 | else
|
|---|
| 4284 | { return locale;
|
|---|
| 4285 | }
|
|---|
| 4286 | }
|
|---|
| 4287 | /******************************************************************************
|
|---|
| 4288 | * GetTimeFormatA [KERNEL32.422]
|
|---|
| 4289 | * Makes an ASCII string of the time
|
|---|
| 4290 | *
|
|---|
| 4291 | * Formats date according to format, or locale default if format is
|
|---|
| 4292 | * NULL. The format consists of literal characters and fields as follows:
|
|---|
| 4293 | *
|
|---|
| 4294 | * h hours with no leading zero (12-hour)
|
|---|
| 4295 | * hh hours with full two digits
|
|---|
| 4296 | * H hours with no leading zero (24-hour)
|
|---|
| 4297 | * HH hours with full two digits
|
|---|
| 4298 | * m minutes with no leading zero
|
|---|
| 4299 | * mm minutes with full two digits
|
|---|
| 4300 | * s seconds with no leading zero
|
|---|
| 4301 | * ss seconds with full two digits
|
|---|
| 4302 | * t time marker (A or P)
|
|---|
| 4303 | * tt time marker (AM, PM)
|
|---|
| 4304 | *
|
|---|
| 4305 | */
|
|---|
| 4306 | INT WINAPI
|
|---|
| 4307 | GetTimeFormatA(LCID locale, /* [in] */
|
|---|
| 4308 | DWORD flags, /* [in] */
|
|---|
| 4309 | LPSYSTEMTIME xtime, /* [in] */
|
|---|
| 4310 | LPCSTR format, /* [in] */
|
|---|
| 4311 | LPSTR timestr, /* [out] */
|
|---|
| 4312 | INT timelen /* [in] */)
|
|---|
| 4313 | { char format_buf[40];
|
|---|
| 4314 | LPCSTR thisformat;
|
|---|
| 4315 | SYSTEMTIME t;
|
|---|
| 4316 | LPSYSTEMTIME thistime;
|
|---|
| 4317 | LCID thislocale=0;
|
|---|
| 4318 | DWORD thisflags=LOCALE_STIMEFORMAT; /* standart timeformat */
|
|---|
| 4319 | INT ret;
|
|---|
| 4320 |
|
|---|
| 4321 | TRACE("GetTimeFormat(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",locale,flags,xtime,format,timestr,timelen);
|
|---|
| 4322 |
|
|---|
| 4323 | thislocale = OLE2NLS_CheckLocale ( locale );
|
|---|
| 4324 |
|
|---|
| 4325 | if (format == NULL)
|
|---|
| 4326 | { if (flags & LOCALE_NOUSEROVERRIDE) /*use system default*/
|
|---|
| 4327 | { thislocale = GetSystemDefaultLCID();
|
|---|
| 4328 | }
|
|---|
| 4329 | GetLocaleInfoA(thislocale, thisflags, format_buf, sizeof(format_buf));
|
|---|
| 4330 | thisformat = format_buf;
|
|---|
| 4331 | }
|
|---|
| 4332 | else
|
|---|
| 4333 | { thisformat = format;
|
|---|
| 4334 | }
|
|---|
| 4335 |
|
|---|
| 4336 | if (xtime == NULL) /* NULL means use the current local time*/
|
|---|
| 4337 | { GetLocalTime(&t);
|
|---|
| 4338 | thistime = &t;
|
|---|
| 4339 | }
|
|---|
| 4340 | else
|
|---|
| 4341 | { thistime = xtime;
|
|---|
| 4342 | /* Check that hour,min and sec is in range */
|
|---|
| 4343 | }
|
|---|
| 4344 | ret = OLE_GetFormatA(thislocale, thisflags, flags, thistime, thisformat,
|
|---|
| 4345 | timestr, timelen);
|
|---|
| 4346 | return ret;
|
|---|
| 4347 | }
|
|---|
| 4348 |
|
|---|
| 4349 |
|
|---|
| 4350 | /******************************************************************************
|
|---|
| 4351 | * GetTimeFormatW [KERNEL32.423]
|
|---|
| 4352 | * Makes a Unicode string of the time
|
|---|
| 4353 | */
|
|---|
| 4354 | INT WINAPI
|
|---|
| 4355 | GetTimeFormatW(LCID locale, /* [in] */
|
|---|
| 4356 | DWORD flags, /* [in] */
|
|---|
| 4357 | LPSYSTEMTIME xtime, /* [in] */
|
|---|
| 4358 | LPCWSTR format, /* [in] */
|
|---|
| 4359 | LPWSTR timestr, /* [out] */
|
|---|
| 4360 | INT timelen /* [in] */)
|
|---|
| 4361 | { WCHAR format_buf[40];
|
|---|
| 4362 | LPCWSTR thisformat;
|
|---|
| 4363 | SYSTEMTIME t;
|
|---|
| 4364 | LPSYSTEMTIME thistime;
|
|---|
| 4365 | LCID thislocale=0;
|
|---|
| 4366 | DWORD thisflags=LOCALE_STIMEFORMAT; /* standart timeformat */
|
|---|
| 4367 | INT ret;
|
|---|
| 4368 |
|
|---|
| 4369 | TRACE("GetTimeFormat(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",locale,flags,
|
|---|
| 4370 | xtime,debugstr_w(format),timestr,timelen);
|
|---|
| 4371 |
|
|---|
| 4372 | thislocale = OLE2NLS_CheckLocale ( locale );
|
|---|
| 4373 |
|
|---|
| 4374 | if (format == NULL)
|
|---|
| 4375 | { if (flags & LOCALE_NOUSEROVERRIDE) /*use system default*/
|
|---|
| 4376 | { thislocale = GetSystemDefaultLCID();
|
|---|
| 4377 | }
|
|---|
| 4378 | GetLocaleInfoW(thislocale, thisflags, format_buf, 40);
|
|---|
| 4379 | thisformat = format_buf;
|
|---|
| 4380 | }
|
|---|
| 4381 | else
|
|---|
| 4382 | { thisformat = format;
|
|---|
| 4383 | }
|
|---|
| 4384 |
|
|---|
| 4385 | if (xtime == NULL) /* NULL means use the current local time*/
|
|---|
| 4386 | { GetLocalTime(&t);
|
|---|
| 4387 | thistime = &t;
|
|---|
| 4388 | }
|
|---|
| 4389 | else
|
|---|
| 4390 | { thistime = xtime;
|
|---|
| 4391 | }
|
|---|
| 4392 |
|
|---|
| 4393 | ret = OLE_GetFormatW(thislocale, thisflags, flags, thistime, thisformat,
|
|---|
| 4394 | timestr, timelen);
|
|---|
| 4395 | return ret;
|
|---|
| 4396 | }
|
|---|
| 4397 |
|
|---|
| 4398 | /******************************************************************************
|
|---|
| 4399 | * EnumCalendarInfoA [KERNEL32.196]
|
|---|
| 4400 | */
|
|---|
| 4401 | BOOL WINAPI EnumCalendarInfoA(
|
|---|
| 4402 | CALINFO_ENUMPROCA calinfoproc,LCID locale,CALID calendar,CALTYPE caltype
|
|---|
| 4403 | ) {
|
|---|
| 4404 | FIXME("(%p,0x%04lx,0x%08lx,0x%08lx),stub!\n",calinfoproc,locale,calendar,caltype);
|
|---|
| 4405 | return FALSE;
|
|---|
| 4406 | }
|
|---|
| 4407 |
|
|---|
| 4408 | #ifdef __WIN32OS2__
|
|---|
| 4409 | /*****************************************************************************
|
|---|
| 4410 | * Name : BOOL WIN32API EnumCalendarInfoW
|
|---|
| 4411 | * Purpose : The EnumCalendarInfoW function enumerates calendar information
|
|---|
| 4412 | * for a specified locale. The CalType parameter specifies the type
|
|---|
| 4413 | * of calendar information to enumerate. The function returns the
|
|---|
| 4414 | * specified calendar information for all applicable calendars for
|
|---|
| 4415 | * the locale, or for a single requested calendar, depending on the
|
|---|
| 4416 | * value of the Calendar parameter.
|
|---|
| 4417 | * The EnumCalendarInfo function enumerates the calendar information
|
|---|
| 4418 | * by calling an application-defined callback function. It passes
|
|---|
| 4419 | * the callback function a pointer to a string buffer containing
|
|---|
| 4420 | * the requested calendar information. This continues until either
|
|---|
| 4421 | * the last applicable calendar is found or the callback function
|
|---|
| 4422 | * returns FALSE.
|
|---|
| 4423 | * Parameters: CALINFO_ENUMPROCW lpCalInfoEnumProc pointer to enumeration
|
|---|
| 4424 | * callback function
|
|---|
| 4425 | * LCID Locale locale whose calendar information is of interest
|
|---|
| 4426 | * CALID Calendar calendar whose information is of interest
|
|---|
| 4427 | * CALTYPE CalType type of calendar information of interest
|
|---|
| 4428 | * Variables :
|
|---|
| 4429 | * Result : If the function succeeds, the return value is nonzero.
|
|---|
| 4430 | * If the function fails, the return value is zero
|
|---|
| 4431 | * Remark :
|
|---|
| 4432 | * Status : UNTESTED STUB
|
|---|
| 4433 | *
|
|---|
| 4434 | * Author : Markus Montkowski [Tha, 1998/05/21 17:46]
|
|---|
| 4435 | *****************************************************************************/
|
|---|
| 4436 |
|
|---|
| 4437 | BOOL WIN32API EnumCalendarInfoW(CALINFO_ENUMPROCW lpCalInfoEnumProc,
|
|---|
| 4438 | LCID Locale,
|
|---|
| 4439 | CALID Calendar,
|
|---|
| 4440 | CALTYPE CalType)
|
|---|
| 4441 | {
|
|---|
| 4442 |
|
|---|
| 4443 | dprintf(("KERNEL32: EnumCalendarInfoW(%08x,%08x,%08x,%08x)not implemented\n",
|
|---|
| 4444 | lpCalInfoEnumProc,
|
|---|
| 4445 | Locale,
|
|---|
| 4446 | Calendar,
|
|---|
| 4447 | CalType
|
|---|
| 4448 | ));
|
|---|
| 4449 |
|
|---|
| 4450 | return (FALSE);
|
|---|
| 4451 | }
|
|---|
| 4452 | #endif
|
|---|