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