Print this page
Split |
Close |
Expand all |
Collapse all |
--- old/src/windows/native/java/lang/java_props_md.c
+++ new/src/windows/native/java/lang/java_props_md.c
1 1 /*
2 2 * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation. Oracle designates this
8 8 * particular file as subject to the "Classpath" exception as provided
9 9 * by Oracle in the LICENSE file that accompanied this code.
10 10 *
11 11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 14 * version 2 for more details (a copy is included in the LICENSE file that
15 15 * accompanied this code).
16 16 *
17 17 * You should have received a copy of the GNU General Public License version
18 18 * 2 along with this work; if not, write to the Free Software Foundation,
19 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 20 *
21 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 22 * or visit www.oracle.com if you need additional information or have any
23 23 * questions.
24 24 */
25 25
26 26 #include <windows.h>
27 27 #include <shlobj.h>
28 28 #include <objidl.h>
29 29 #include <locale.h>
30 30 #include <sys/types.h>
31 31 #include <sys/timeb.h>
32 32 #include <tchar.h>
33 33
34 34 #include "locale_str.h"
35 35 #include "java_props.h"
36 36
37 37 #ifndef VER_PLATFORM_WIN32_WINDOWS
38 38 #define VER_PLATFORM_WIN32_WINDOWS 1
39 39 #endif
40 40
41 41 #ifndef PROCESSOR_ARCHITECTURE_AMD64
42 42 #define PROCESSOR_ARCHITECTURE_AMD64 9
43 43 #endif
44 44
45 45 typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);
46 46 static void SetupI18nProps(LCID lcid, char** language, char** script, char** country,
47 47 char** variant, char** encoding);
48 48
49 49 #define SHELL_KEY "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"
50 50
51 51 #define PROPSIZE 9 // eight-letter + null terminator
52 52 #define SNAMESIZE 86 // max number of chars for LOCALE_SNAME is 85
53 53
54 54 static char *
55 55 getEncodingInternal(LCID lcid)
56 56 {
57 57 char * ret = malloc(16);
58 58 int codepage;
59 59
60 60 if (GetLocaleInfo(lcid,
61 61 LOCALE_IDEFAULTANSICODEPAGE,
62 62 ret+2, 14) == 0) {
63 63 codepage = 1252;
64 64 } else {
65 65 codepage = atoi(ret+2);
66 66 }
67 67
68 68 switch (codepage) {
69 69 case 0:
70 70 strcpy(ret, "UTF-8");
71 71 break;
72 72 case 874: /* 9:Thai */
73 73 case 932: /* 10:Japanese */
74 74 case 949: /* 12:Korean Extended Wansung */
75 75 case 950: /* 13:Chinese (Taiwan, Hongkong, Macau) */
76 76 case 1361: /* 15:Korean Johab */
77 77 ret[0] = 'M';
78 78 ret[1] = 'S';
79 79 break;
80 80 case 936:
81 81 strcpy(ret, "GBK");
82 82 break;
83 83 case 54936:
84 84 strcpy(ret, "GB18030");
85 85 break;
86 86 default:
87 87 ret[0] = 'C';
88 88 ret[1] = 'p';
89 89 break;
90 90 }
91 91
92 92 //Traditional Chinese Windows should use MS950_HKSCS_XP as the
93 93 //default encoding, if HKSCS patch has been installed.
94 94 // "old" MS950 0xfa41 -> u+e001
95 95 // "new" MS950 0xfa41 -> u+92db
96 96 if (strcmp(ret, "MS950") == 0) {
97 97 TCHAR mbChar[2] = {(char)0xfa, (char)0x41};
98 98 WCHAR unicodeChar;
99 99 MultiByteToWideChar(CP_ACP, 0, mbChar, 2, &unicodeChar, 1);
100 100 if (unicodeChar == 0x92db) {
101 101 strcpy(ret, "MS950_HKSCS_XP");
102 102 }
103 103 } else {
104 104 //SimpChinese Windows should use GB18030 as the default
105 105 //encoding, if gb18030 patch has been installed (on windows
106 106 //2000/XP, (1)Codepage 54936 will be available
107 107 //(2)simsun18030.ttc will exist under system fonts dir )
108 108 if (strcmp(ret, "GBK") == 0 && IsValidCodePage(54936)) {
109 109 char systemPath[MAX_PATH + 1];
110 110 char* gb18030Font = "\\FONTS\\SimSun18030.ttc";
111 111 FILE *f = NULL;
112 112 if (GetWindowsDirectory(systemPath, MAX_PATH + 1) != 0 &&
113 113 strlen(systemPath) + strlen(gb18030Font) < MAX_PATH + 1) {
114 114 strcat(systemPath, "\\FONTS\\SimSun18030.ttc");
115 115 if ((f = fopen(systemPath, "r")) != NULL) {
116 116 fclose(f);
117 117 strcpy(ret, "GB18030");
118 118 }
119 119 }
120 120 }
121 121 }
122 122
123 123 return ret;
124 124 }
125 125
126 126 // Exported entries for AWT
127 127 DllExport const char *
128 128 getEncodingFromLangID(LANGID langID)
129 129 {
130 130 return getEncodingInternal(MAKELCID(langID, SORT_DEFAULT));
131 131 }
132 132
133 133 // Returns BCP47 Language Tag
134 134 DllExport const char *
135 135 getJavaIDFromLangID(LANGID langID)
136 136 {
137 137 char * elems[5]; // lang, script, ctry, variant, encoding
138 138 char * ret = malloc(SNAMESIZE);
139 139 int index;
140 140
141 141 SetupI18nProps(MAKELCID(langID, SORT_DEFAULT),
142 142 &(elems[0]), &(elems[1]), &(elems[2]), &(elems[3]), &(elems[4]));
143 143
144 144 // there always is the "language" tag
145 145 strcpy(ret, elems[0]);
146 146
147 147 // append other elements, if any
148 148 for (index = 1; index < 4; index++) {
149 149 if ((elems[index])[0] != '\0') {
150 150 strcat(ret, "-");
151 151 strcat(ret, elems[index]);
152 152 }
153 153 }
154 154
155 155 for (index = 0; index < 5; index++) {
156 156 free(elems[index]);
157 157 }
158 158
159 159 return ret;
160 160 }
161 161
162 162 /*
163 163 * Code to figure out the user's home directory using the registry
164 164 */
165 165 static WCHAR*
166 166 getHomeFromRegistry()
167 167 {
168 168 HKEY key;
169 169 int rc;
170 170 DWORD type;
171 171 WCHAR *p;
172 172 WCHAR path[MAX_PATH+1];
173 173 int size = MAX_PATH+1;
174 174
175 175 rc = RegOpenKeyEx(HKEY_CURRENT_USER, SHELL_KEY, 0, KEY_READ, &key);
176 176 if (rc != ERROR_SUCCESS) {
177 177 // Shell folder doesn't exist??!!
178 178 return NULL;
179 179 }
180 180
181 181 path[0] = 0;
182 182 rc = RegQueryValueExW(key, L"Desktop", 0, &type, (LPBYTE)path, &size);
183 183 if (rc != ERROR_SUCCESS || type != REG_SZ) {
184 184 return NULL;
185 185 }
186 186 RegCloseKey(key);
187 187 /* Get the parent of Desktop directory */
188 188 p = wcsrchr(path, L'\\');
189 189 if (p == NULL) {
190 190 return NULL;
191 191 }
192 192 *p = L'\0';
193 193 return _wcsdup(path);
194 194 }
195 195
196 196 /*
197 197 * Code to figure out the user's home directory using shell32.dll
198 198 */
199 199 WCHAR*
200 200 getHomeFromShell32()
201 201 {
202 202 HRESULT rc;
203 203 LPITEMIDLIST item_list = 0;
204 204 WCHAR *p;
205 205 WCHAR path[MAX_PATH+1];
206 206 int size = MAX_PATH+1;
207 207
208 208 rc = SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOPDIRECTORY, &item_list);
209 209 if (!SUCCEEDED(rc)) {
210 210 // we can't find the shell folder.
211 211 return NULL;
212 212 }
213 213
214 214 path[0] = 0;
215 215 SHGetPathFromIDListW(item_list, (LPWSTR)path);
216 216
217 217 /* Get the parent of Desktop directory */
218 218 p = wcsrchr(path, L'\\');
219 219 if (p) {
220 220 *p = 0;
221 221 }
222 222
223 223 /*
224 224 * We've been successful. Note that we don't free the memory allocated
225 225 * by ShGetSpecialFolderLocation. We only ever come through here once,
226 226 * and only if the registry lookup failed, so it's just not worth it.
227 227 *
228 228 * We also don't unload the SHELL32 DLL. We've paid the hit for loading
229 229 * it and we may need it again later.
230 230 */
231 231 return _wcsdup(path);
232 232 }
233 233
234 234 static boolean
235 235 haveMMX(void)
236 236 {
237 237 return IsProcessorFeaturePresent(PF_MMX_INSTRUCTIONS_AVAILABLE);
238 238 }
239 239
240 240 static const char *
241 241 cpu_isalist(void)
242 242 {
243 243 SYSTEM_INFO info;
244 244 GetSystemInfo(&info);
245 245 switch (info.wProcessorArchitecture) {
246 246 #ifdef PROCESSOR_ARCHITECTURE_IA64
247 247 case PROCESSOR_ARCHITECTURE_IA64: return "ia64";
248 248 #endif
249 249 #ifdef PROCESSOR_ARCHITECTURE_AMD64
250 250 case PROCESSOR_ARCHITECTURE_AMD64: return "amd64";
251 251 #endif
252 252 case PROCESSOR_ARCHITECTURE_INTEL:
253 253 switch (info.wProcessorLevel) {
254 254 case 6: return haveMMX()
255 255 ? "pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86"
256 256 : "pentium_pro pentium i486 i386 i86";
257 257 case 5: return haveMMX()
258 258 ? "pentium+mmx pentium i486 i386 i86"
259 259 : "pentium i486 i386 i86";
260 260 case 4: return "i486 i386 i86";
261 261 case 3: return "i386 i86";
262 262 }
263 263 }
264 264 return NULL;
265 265 }
266 266
267 267 static void
268 268 SetupI18nProps(LCID lcid, char** language, char** script, char** country,
269 269 char** variant, char** encoding) {
270 270 /* script */
271 271 char tmp[SNAMESIZE];
272 272 *script = malloc(PROPSIZE);
273 273 if (GetLocaleInfo(lcid,
274 274 LOCALE_SNAME, tmp, SNAMESIZE) == 0 ||
275 275 sscanf(tmp, "%*[a-z\\-]%1[A-Z]%[a-z]", *script, &((*script)[1])) == 0 ||
276 276 strlen(*script) != 4) {
277 277 (*script)[0] = '\0';
278 278 }
279 279
280 280 /* country */
281 281 *country = malloc(PROPSIZE);
282 282 if (GetLocaleInfo(lcid,
283 283 LOCALE_SISO3166CTRYNAME, *country, PROPSIZE) == 0 &&
284 284 GetLocaleInfo(lcid,
285 285 LOCALE_SISO3166CTRYNAME2, *country, PROPSIZE) == 0) {
286 286 (*country)[0] = '\0';
287 287 }
288 288
289 289 /* language */
290 290 *language = malloc(PROPSIZE);
291 291 if (GetLocaleInfo(lcid,
292 292 LOCALE_SISO639LANGNAME, *language, PROPSIZE) == 0 &&
293 293 GetLocaleInfo(lcid,
294 294 LOCALE_SISO639LANGNAME2, *language, PROPSIZE) == 0) {
295 295 /* defaults to en_US */
296 296 strcpy(*language, "en");
297 297 strcpy(*country, "US");
298 298 }
299 299
300 300 /* variant */
301 301 *variant = malloc(PROPSIZE);
302 302 (*variant)[0] = '\0';
303 303
304 304 /* handling for Norwegian */
305 305 if (strcmp(*language, "nb") == 0) {
306 306 strcpy(*language, "no");
307 307 strcpy(*country , "NO");
308 308 } else if (strcmp(*language, "nn") == 0) {
309 309 strcpy(*language, "no");
310 310 strcpy(*country , "NO");
311 311 strcpy(*variant, "NY");
312 312 }
313 313
314 314 /* encoding */
315 315 *encoding = getEncodingInternal(lcid);
316 316 }
317 317
318 318 java_props_t *
319 319 GetJavaProperties(JNIEnv* env)
320 320 {
321 321 static java_props_t sprops = {0};
322 322
323 323 OSVERSIONINFOEX ver;
324 324
325 325 if (sprops.user_dir) {
326 326 return &sprops;
327 327 }
328 328
329 329 /* AWT properties */
330 330 sprops.awt_toolkit = "sun.awt.windows.WToolkit";
331 331
332 332 /* tmp dir */
333 333 {
334 334 WCHAR tmpdir[MAX_PATH + 1];
335 335 /* we might want to check that this succeed */
336 336 GetTempPathW(MAX_PATH + 1, tmpdir);
337 337 sprops.tmp_dir = _wcsdup(tmpdir);
338 338 }
339 339
340 340 /* Printing properties */
341 341 sprops.printerJob = "sun.awt.windows.WPrinterJob";
342 342
343 343 /* Java2D properties */
344 344 sprops.graphics_env = "sun.awt.Win32GraphicsEnvironment";
345 345
346 346 { /* This is used only for debugging of font problems. */
347 347 WCHAR *path = _wgetenv(L"JAVA2D_FONTPATH");
348 348 sprops.font_dir = (path != NULL) ? _wcsdup(path) : NULL;
349 349 }
350 350
351 351 /* OS properties */
352 352 {
353 353 char buf[100];
354 354 SYSTEM_INFO si;
355 355 PGNSI pGNSI;
356 356
357 357 ver.dwOSVersionInfoSize = sizeof(ver);
358 358 GetVersionEx((OSVERSIONINFO *) &ver);
359 359
360 360 ZeroMemory(&si, sizeof(SYSTEM_INFO));
361 361 // Call GetNativeSystemInfo if supported or GetSystemInfo otherwise.
362 362 pGNSI = (PGNSI) GetProcAddress(
363 363 GetModuleHandle(TEXT("kernel32.dll")),
364 364 "GetNativeSystemInfo");
365 365 if(NULL != pGNSI)
366 366 pGNSI(&si);
367 367 else
368 368 GetSystemInfo(&si);
369 369
370 370 /*
371 371 * From msdn page on OSVERSIONINFOEX, current as of this
372 372 * writing, decoding of dwMajorVersion and dwMinorVersion.
373 373 *
374 374 * Operating system dwMajorVersion dwMinorVersion
375 375 * ================== ============== ==============
376 376 *
377 377 * Windows 95 4 0
378 378 * Windows 98 4 10
379 379 * Windows ME 4 90
380 380 * Windows 3.51 3 51
381 381 * Windows NT 4.0 4 0
↓ open down ↓ |
381 lines elided |
↑ open up ↑ |
382 382 * Windows 2000 5 0
383 383 * Windows XP 32 bit 5 1
384 384 * Windows Server 2003 family 5 2
385 385 * Windows XP 64 bit 5 2
386 386 * where ((&ver.wServicePackMinor) + 2) = 1
387 387 * and si.wProcessorArchitecture = 9
388 388 * Windows Vista family 6 0 (VER_NT_WORKSTATION)
389 389 * Windows Server 2008 6 0 (!VER_NT_WORKSTATION)
390 390 * Windows 7 6 1 (VER_NT_WORKSTATION)
391 391 * Windows Server 2008 R2 6 1 (!VER_NT_WORKSTATION)
392 + * Windows 8 6 2 (VER_NT_WORKSTATION)
392 393 *
393 394 * This mapping will presumably be augmented as new Windows
394 395 * versions are released.
395 396 */
396 397 switch (ver.dwPlatformId) {
397 398 case VER_PLATFORM_WIN32s:
398 399 sprops.os_name = "Windows 3.1";
399 400 break;
400 401 case VER_PLATFORM_WIN32_WINDOWS:
401 402 if (ver.dwMajorVersion == 4) {
402 403 switch (ver.dwMinorVersion) {
403 404 case 0: sprops.os_name = "Windows 95"; break;
404 405 case 10: sprops.os_name = "Windows 98"; break;
405 406 case 90: sprops.os_name = "Windows Me"; break;
406 407 default: sprops.os_name = "Windows 9X (unknown)"; break;
407 408 }
408 409 } else {
409 410 sprops.os_name = "Windows 9X (unknown)";
410 411 }
411 412 break;
412 413 case VER_PLATFORM_WIN32_NT:
413 414 if (ver.dwMajorVersion <= 4) {
414 415 sprops.os_name = "Windows NT";
415 416 } else if (ver.dwMajorVersion == 5) {
416 417 switch (ver.dwMinorVersion) {
417 418 case 0: sprops.os_name = "Windows 2000"; break;
418 419 case 1: sprops.os_name = "Windows XP"; break;
419 420 case 2:
420 421 /*
421 422 * From MSDN OSVERSIONINFOEX and SYSTEM_INFO documentation:
422 423 *
423 424 * "Because the version numbers for Windows Server 2003
424 425 * and Windows XP 6u4 bit are identical, you must also test
425 426 * whether the wProductType member is VER_NT_WORKSTATION.
426 427 * and si.wProcessorArchitecture is
427 428 * PROCESSOR_ARCHITECTURE_AMD64 (which is 9)
428 429 * If it is, the operating system is Windows XP 64 bit;
429 430 * otherwise, it is Windows Server 2003."
430 431 */
431 432 if(ver.wProductType == VER_NT_WORKSTATION &&
432 433 si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) {
433 434 sprops.os_name = "Windows XP"; /* 64 bit */
434 435 } else {
435 436 sprops.os_name = "Windows 2003";
436 437 }
437 438 break;
↓ open down ↓ |
36 lines elided |
↑ open up ↑ |
438 439 default: sprops.os_name = "Windows NT (unknown)"; break;
439 440 }
440 441 } else if (ver.dwMajorVersion == 6) {
441 442 /*
442 443 * See table in MSDN OSVERSIONINFOEX documentation.
443 444 */
444 445 if (ver.wProductType == VER_NT_WORKSTATION) {
445 446 switch (ver.dwMinorVersion) {
446 447 case 0: sprops.os_name = "Windows Vista"; break;
447 448 case 1: sprops.os_name = "Windows 7"; break;
449 + case 2: sprops.os_name = "Windows 8"; break;
448 450 default: sprops.os_name = "Windows NT (unknown)";
449 451 }
450 452 } else {
451 453 switch (ver.dwMinorVersion) {
452 454 case 0: sprops.os_name = "Windows Server 2008"; break;
453 455 case 1: sprops.os_name = "Windows Server 2008 R2"; break;
454 456 default: sprops.os_name = "Windows NT (unknown)";
455 457 }
456 458 }
457 459 } else {
458 460 sprops.os_name = "Windows NT (unknown)";
459 461 }
460 462 break;
461 463 default:
462 464 sprops.os_name = "Windows (unknown)";
463 465 break;
464 466 }
465 467 sprintf(buf, "%d.%d", ver.dwMajorVersion, ver.dwMinorVersion);
466 468 sprops.os_version = _strdup(buf);
467 469 #if _M_IA64
468 470 sprops.os_arch = "ia64";
469 471 #elif _M_AMD64
470 472 sprops.os_arch = "amd64";
471 473 #elif _X86_
472 474 sprops.os_arch = "x86";
473 475 #else
474 476 sprops.os_arch = "unknown";
475 477 #endif
476 478
477 479 sprops.patch_level = _strdup(ver.szCSDVersion);
478 480
479 481 sprops.desktop = "windows";
480 482 }
481 483
482 484 /* Endianness of platform */
483 485 {
484 486 unsigned int endianTest = 0xff000000;
485 487 if (((char*)(&endianTest))[0] != 0) {
486 488 sprops.cpu_endian = "big";
487 489 } else {
488 490 sprops.cpu_endian = "little";
489 491 }
490 492 }
491 493
492 494 /* CPU ISA list */
493 495 sprops.cpu_isalist = cpu_isalist();
494 496
495 497 /*
496 498 * User name
497 499 * We try to avoid calling GetUserName as it turns out to
498 500 * be surprisingly expensive on NT. It pulls in an extra
499 501 * 100 K of footprint.
500 502 */
501 503 {
502 504 WCHAR *uname = _wgetenv(L"USERNAME");
503 505 if (uname != NULL && wcslen(uname) > 0) {
504 506 sprops.user_name = _wcsdup(uname);
505 507 } else {
506 508 DWORD buflen = 0;
507 509 if (GetUserNameW(NULL, &buflen) == 0 &&
508 510 GetLastError() == ERROR_INSUFFICIENT_BUFFER)
509 511 {
510 512 uname = (WCHAR*)malloc(buflen * sizeof(WCHAR));
511 513 if (uname != NULL && GetUserNameW(uname, &buflen) == 0) {
512 514 free(uname);
513 515 uname = NULL;
514 516 }
515 517 } else {
516 518 uname = NULL;
517 519 }
518 520 sprops.user_name = (uname != NULL) ? uname : L"unknown";
519 521 }
520 522 }
521 523
522 524 /*
523 525 * Home directory/
524 526 *
525 527 * We first look under a standard registry key. If that fails we
526 528 * fall back on using a SHELL32.DLL API. If that fails we use a
527 529 * default value.
528 530 *
529 531 * Note: To save space we want to avoid loading SHELL32.DLL
530 532 * unless really necessary. However if we do load it, we leave it
531 533 * in memory, as it may be needed again later.
532 534 *
533 535 * The normal result is that for a given user name XXX:
534 536 * On multi-user NT, user.home gets set to c:\winnt\profiles\XXX.
535 537 * On multi-user Win95, user.home gets set to c:\windows\profiles\XXX.
536 538 * On single-user Win95, user.home gets set to c:\windows.
537 539 */
538 540 {
539 541 WCHAR *homep = getHomeFromRegistry();
540 542 if (homep == NULL) {
541 543 homep = getHomeFromShell32();
542 544 if (homep == NULL)
543 545 homep = L"C:\\";
544 546 }
545 547 sprops.user_home = _wcsdup(homep);
546 548 }
547 549
548 550 /*
549 551 * user.language
550 552 * user.script, user.country, user.variant (if user's environment specifies them)
551 553 * file.encoding
552 554 * file.encoding.pkg
553 555 */
554 556 {
555 557 /*
556 558 * query the system for the current system default locale
557 559 * (which is a Windows LCID value),
558 560 */
559 561 LCID userDefaultLCID = GetUserDefaultLCID();
560 562 LCID systemDefaultLCID = GetSystemDefaultLCID();
561 563 LCID userDefaultUILang = GetUserDefaultUILanguage();
562 564
563 565 {
564 566 char * display_encoding;
565 567
566 568 // Windows UI Language selection list only cares "language"
567 569 // information of the UI Language. For example, the list
568 570 // just lists "English" but it actually means "en_US", and
569 571 // the user cannot select "en_GB" (if exists) in the list.
570 572 // So, this hack is to use the user LCID region information
571 573 // for the UI Language, if the "language" portion of those
572 574 // two locales are the same.
573 575 if (PRIMARYLANGID(LANGIDFROMLCID(userDefaultLCID)) ==
574 576 PRIMARYLANGID(LANGIDFROMLCID(userDefaultUILang))) {
575 577 userDefaultUILang = userDefaultLCID;
576 578 }
577 579
578 580 SetupI18nProps(userDefaultUILang,
579 581 &sprops.language,
580 582 &sprops.script,
581 583 &sprops.country,
582 584 &sprops.variant,
583 585 &display_encoding);
584 586 SetupI18nProps(userDefaultLCID,
585 587 &sprops.format_language,
586 588 &sprops.format_script,
587 589 &sprops.format_country,
588 590 &sprops.format_variant,
589 591 &sprops.encoding);
590 592 SetupI18nProps(userDefaultUILang,
591 593 &sprops.display_language,
592 594 &sprops.display_script,
593 595 &sprops.display_country,
594 596 &sprops.display_variant,
595 597 &display_encoding);
596 598
597 599 sprops.sun_jnu_encoding = getEncodingInternal(systemDefaultLCID);
598 600 if (LANGIDFROMLCID(userDefaultLCID) == 0x0c04 && ver.dwMajorVersion == 6) {
599 601 // MS claims "Vista has built-in support for HKSCS-2004.
600 602 // All of the HKSCS-2004 characters have Unicode 4.1.
601 603 // PUA code point assignments". But what it really means
602 604 // is that the HKSCS-2004 is ONLY supported in Unicode.
603 605 // Test indicates the MS950 in its zh_HK locale is a
604 606 // "regular" MS950 which does not handle HKSCS-2004 at
605 607 // all. Set encoding to MS950_HKSCS.
606 608 sprops.encoding = "MS950_HKSCS";
607 609 sprops.sun_jnu_encoding = "MS950_HKSCS";
608 610 }
609 611 }
610 612 }
611 613
612 614 sprops.unicode_encoding = "UnicodeLittle";
613 615 /* User TIMEZONE */
614 616 {
615 617 /*
616 618 * We defer setting up timezone until it's actually necessary.
617 619 * Refer to TimeZone.getDefault(). However, the system
618 620 * property is necessary to be able to be set by the command
619 621 * line interface -D. Here temporarily set a null string to
620 622 * timezone.
621 623 */
622 624 sprops.timezone = "";
623 625 }
624 626
625 627 /* Current directory */
626 628 {
627 629 WCHAR buf[MAX_PATH];
628 630 if (GetCurrentDirectoryW(sizeof(buf)/sizeof(WCHAR), buf) != 0)
629 631 sprops.user_dir = _wcsdup(buf);
630 632 }
631 633
632 634 sprops.file_separator = "\\";
633 635 sprops.path_separator = ";";
634 636 sprops.line_separator = "\r\n";
635 637
636 638 return &sprops;
637 639 }
638 640
639 641 jstring
640 642 GetStringPlatform(JNIEnv *env, nchar* wcstr)
641 643 {
642 644 return (*env)->NewString(env, wcstr, wcslen(wcstr));
643 645 }
↓ open down ↓ |
186 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX