594 const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
595 int got = 0;
596
597 switch (type) {
598 case sun_util_locale_provider_HostLocaleProviderAdapterImpl_CD_FIRSTDAYOFWEEK:
599 got = getLocaleInfoWrapper(langtag, LOCALE_IFIRSTDAYOFWEEK, buf, BUFLEN);
600 break;
601 }
602
603 (*env)->ReleaseStringChars(env, jlangtag, langtag);
604
605 if (got) {
606 return _wtoi(buf);
607 } else {
608 return -1;
609 }
610 }
611
612 int getLocaleInfoWrapper(const jchar *langtag, LCTYPE type, LPWSTR data, int buflen) {
613 if (pGetLocaleInfoEx) {
614 return pGetLocaleInfoEx((LPWSTR)langtag, type, data, buflen);
615 } else {
616 // If we ever wanted to support WinXP, we will need extra module from
617 // MS...
618 // return GetLocaleInfo(DownlevelLocaleNameToLCID(langtag, 0), type, data, buflen);
619 return 0;
620 }
621 }
622
623 int getCalendarInfoWrapper(const jchar *langtag, CALID id, LPCWSTR reserved, CALTYPE type, LPWSTR data, int buflen, LPDWORD val) {
624 if (pGetCalendarInfoEx) {
625 return pGetCalendarInfoEx((LPWSTR)langtag, id, reserved, type, data, buflen, val);
626 } else {
627 // If we ever wanted to support WinXP, we will need extra module from
628 // MS...
629 // return GetCalendarInfo(DownlevelLocaleNameToLCID(langtag, 0), ...);
630 return 0;
631 }
632 }
633
634 jint getCalendarID(const jchar *langtag) {
635 WCHAR type[BUFLEN];
636 int got = getLocaleInfoWrapper(langtag, LOCALE_ICALENDARTYPE, type, BUFLEN);
637
638 if (got) {
639 return _wtoi(type);
640 } else {
641 return 0;
642 }
643 }
644
645 void replaceCalendarArrayElems(JNIEnv *env, jstring jlangtag, jobjectArray jarray, CALTYPE* pCalTypes, int offset, int length) {
|
594 const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
595 int got = 0;
596
597 switch (type) {
598 case sun_util_locale_provider_HostLocaleProviderAdapterImpl_CD_FIRSTDAYOFWEEK:
599 got = getLocaleInfoWrapper(langtag, LOCALE_IFIRSTDAYOFWEEK, buf, BUFLEN);
600 break;
601 }
602
603 (*env)->ReleaseStringChars(env, jlangtag, langtag);
604
605 if (got) {
606 return _wtoi(buf);
607 } else {
608 return -1;
609 }
610 }
611
612 int getLocaleInfoWrapper(const jchar *langtag, LCTYPE type, LPWSTR data, int buflen) {
613 if (pGetLocaleInfoEx) {
614 if (wcscmp(L"und", (LPWSTR)langtag) == 0) {
615 // defaults to "en"
616 return pGetLocaleInfoEx(L"en", type, data, buflen);
617 } else {
618 return pGetLocaleInfoEx((LPWSTR)langtag, type, data, buflen);
619 }
620 } else {
621 // If we ever wanted to support WinXP, we will need extra module from
622 // MS...
623 // return GetLocaleInfo(DownlevelLocaleNameToLCID(langtag, 0), type, data, buflen);
624 return 0;
625 }
626 }
627
628 int getCalendarInfoWrapper(const jchar *langtag, CALID id, LPCWSTR reserved, CALTYPE type, LPWSTR data, int buflen, LPDWORD val) {
629 if (pGetCalendarInfoEx) {
630 if (wcscmp(L"und", (LPWSTR)langtag) == 0) {
631 // defaults to "en"
632 return pGetCalendarInfoEx(L"en", id, reserved, type, data, buflen, val);
633 } else {
634 return pGetCalendarInfoEx((LPWSTR)langtag, id, reserved, type, data, buflen, val);
635 }
636 } else {
637 // If we ever wanted to support WinXP, we will need extra module from
638 // MS...
639 // return GetCalendarInfo(DownlevelLocaleNameToLCID(langtag, 0), ...);
640 return 0;
641 }
642 }
643
644 jint getCalendarID(const jchar *langtag) {
645 WCHAR type[BUFLEN];
646 int got = getLocaleInfoWrapper(langtag, LOCALE_ICALENDARTYPE, type, BUFLEN);
647
648 if (got) {
649 return _wtoi(type);
650 } else {
651 return 0;
652 }
653 }
654
655 void replaceCalendarArrayElems(JNIEnv *env, jstring jlangtag, jobjectArray jarray, CALTYPE* pCalTypes, int offset, int length) {
|