// TODO: This is copied in both winnmfmt.cpp and windtfmt.cpp, but really should // be factored out into a common helper for both. static UErrorCode GetEquivalentWindowsLocaleName(const Locale& locale, UnicodeString** buffer)
{
UErrorCode status = U_ZERO_ERROR;
// Convert from names like "en_CA" and "de_DE@collation=phonebook" to "en-CA" and "de-DE-u-co-phonebk".
CharString asciiBCP47Tag = ulocimp_toLanguageTag(locale.getName(), false, status);
if (U_SUCCESS(status))
{ // Need it to be UTF-16, not 8-bit // TODO: This seems like a good thing for a helper wchar_t bcp47Tag[LOCALE_NAME_MAX_LENGTH] = {};
int32_t i; for (i = 0; i < UPRV_LENGTHOF(bcp47Tag); i++)
{ if (asciiBCP47Tag[i] == '\0')
{ break;
} else
{ // normally just copy the character
bcp47Tag[i] = static_cast<wchar_t>(asciiBCP47Tag[i]);
}
}
// Ensure it's null terminated if (i < (UPRV_LENGTHOF(bcp47Tag) - 1))
{
bcp47Tag[i] = L'\0';
} else
{ // Ran out of room.
bcp47Tag[UPRV_LENGTHOF(bcp47Tag) - 1] = L'\0';
}
// Note: On Windows versions below 10, there is no support for locale name aliases. // This means that it will fail for locales where ICU has a completely different // name (like ku vs ckb), and it will also not work for alternate sort locale // names like "de-DE-u-co-phonebk".
// TODO: We could add some sort of exception table for cases like ku vs ckb.
int length = ResolveLocaleName(bcp47Tag, windowsLocaleName, UPRV_LENGTHOF(windowsLocaleName));
if (length > 0)
{
*buffer = new UnicodeString(windowsLocaleName);
} else
{
status = U_UNSUPPORTED_ERROR;
}
} return status;
}
// TODO: Range-check timeStyle, dateStyle
Win32DateFormat::Win32DateFormat(DateFormat::EStyle timeStyle, DateFormat::EStyle dateStyle, const Locale &locale, UErrorCode &status)
: DateFormat(), fDateTimeMsg(nullptr), fTimeStyle(timeStyle), fDateStyle(dateStyle), fLocale(locale), fZoneID(), fWindowsLocaleName(nullptr)
{ if (U_SUCCESS(status)) {
GetEquivalentWindowsLocaleName(locale, &fWindowsLocaleName); // Note: In the previous code, it would look up the LCID for the locale, and if // the locale was not recognized then it would get an LCID of 0, which is a // synonym for LOCALE_USER_DEFAULT on Windows. // If the above method fails, then fWindowsLocaleName will remain as nullptr, and // then we will pass nullptr to API GetLocaleInfoEx, which is the same as passing // LOCALE_USER_DEFAULT.
if (zoneID.compare(fZoneID) != 0) {
UnicodeString icuid;
zone.getID(icuid); if (! uprv_getWindowsTimeZoneInfo(tzi, icuid.getBuffer(), icuid.length())) {
UBool found = false;
int32_t ec = TimeZone::countEquivalentIDs(icuid);
for (int z = 0; z < ec; z += 1) {
UnicodeString equiv = TimeZone::getEquivalentID(icuid, z);
found = uprv_getWindowsTimeZoneInfo(tzi, equiv.getBuffer(), equiv.length()); if (found) { break;
}
}
if (! found) {
GetTimeZoneInformation(tzi);
}
}
}
return zoneID;
}
U_NAMESPACE_END
#endif/* #if !UCONFIG_NO_FORMATTING */
#endif// U_PLATFORM_USES_ONLY_WIN32_API
Messung V0.5
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.12Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.