UBool nsResolved = true;
UBool usingFallback = false; char buffer[ULOC_KEYWORDS_CAPACITY] = "";
int32_t count = inLocale.getKeywordValue("numbers", buffer, sizeof(buffer), status); if (U_FAILURE(status) || status == U_STRING_NOT_TERMINATED_WARNING) { // the "numbers" keyword exceeds ULOC_KEYWORDS_CAPACITY; ignore and use default.
count = 0;
status = U_ZERO_ERROR;
} if ( count > 0 ) { // @numbers keyword was specified in the locale
U_ASSERT(count < ULOC_KEYWORDS_CAPACITY);
buffer[count] = '\0'; // Make sure it is null terminated. if ( !uprv_strcmp(buffer,gDefault) || !uprv_strcmp(buffer,gNative) ||
!uprv_strcmp(buffer,gTraditional) || !uprv_strcmp(buffer,gFinance)) {
nsResolved = false;
}
} else {
uprv_strcpy(buffer, gDefault);
nsResolved = false;
}
if (!nsResolved) { // Resolve the numbering system ( default, native, traditional or finance ) into a "real" numbering system
UErrorCode localStatus = U_ZERO_ERROR;
LocalUResourceBundlePointer resource(ures_open(nullptr, inLocale.getName(), &localStatus));
LocalUResourceBundlePointer numberElementsRes(ures_getByKey(resource.getAlias(), gNumberElements, nullptr, &localStatus)); // Don't stomp on the catastrophic failure of OOM. if (localStatus == U_MEMORY_ALLOCATION_ERROR) {
status = U_MEMORY_ALLOCATION_ERROR; return nullptr;
} while (!nsResolved) {
localStatus = U_ZERO_ERROR;
count = 0; const char16_t *nsName = ures_getStringByKeyWithFallback(numberElementsRes.getAlias(), buffer, &count, &localStatus); // Don't stomp on the catastrophic failure of OOM. if (localStatus == U_MEMORY_ALLOCATION_ERROR) {
status = U_MEMORY_ALLOCATION_ERROR; return nullptr;
} if ( count > 0 && count < ULOC_KEYWORDS_CAPACITY ) { // numbering system found
u_UCharsToChars(nsName, buffer, count);
buffer[count] = '\0'; // Make sure it is null terminated.
nsResolved = true;
}
if (!nsResolved) { // Fallback behavior per TR35 - traditional falls back to native, finance and native fall back to default if (!uprv_strcmp(buffer,gNative) || !uprv_strcmp(buffer,gFinance)) {
uprv_strcpy(buffer,gDefault);
} elseif (!uprv_strcmp(buffer,gTraditional)) {
uprv_strcpy(buffer,gNative);
} else { // If we get here we couldn't find even the default numbering system
usingFallback = true;
nsResolved = true;
}
}
}
}
if (usingFallback) {
status = U_USING_FALLBACK_WARNING;
NumberingSystem *ns = new NumberingSystem(); if (ns == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
} return ns;
} else { return NumberingSystem::createInstanceByName(buffer, status);
}
}
if (U_FAILURE(status)) { // Don't stomp on the catastrophic failure of OOM. if (status != U_MEMORY_ALLOCATION_ERROR) {
status = U_UNSUPPORTED_ERROR;
} return nullptr;
}
// TODO: Simple array of UnicodeString objects, based on length of table resource?
LocalPointer<UVector> numsysNames(new UVector(uprv_deleteUObject, nullptr, status), status); if (U_FAILURE(status)) { return;
}
UErrorCode rbstatus = U_ZERO_ERROR;
UResourceBundle *numberingSystemsInfo = ures_openDirect(nullptr, "numberingSystems", &rbstatus);
numberingSystemsInfo =
ures_getByKey(numberingSystemsInfo, "numberingSystems", numberingSystemsInfo, &rbstatus); if (U_FAILURE(rbstatus)) { // Don't stomp on the catastrophic failure of OOM. if (rbstatus == U_MEMORY_ALLOCATION_ERROR) {
status = rbstatus;
} else {
status = U_MISSING_RESOURCE_ERROR;
}
ures_close(numberingSystemsInfo); return;
}
while ( ures_hasNext(numberingSystemsInfo) && U_SUCCESS(status) ) {
LocalUResourceBundlePointer nsCurrent(ures_getNextResource(numberingSystemsInfo, nullptr, &rbstatus)); if (rbstatus == U_MEMORY_ALLOCATION_ERROR) {
status = rbstatus; // we want to report OOM failure back to the caller. break;
} constchar *nsName = ures_getKey(nsCurrent.getAlias());
LocalPointer<UnicodeString> newElem(new UnicodeString(nsName, -1, US_INV), status);
numsysNames->adoptElement(newElem.orphan(), status);
}
ures_close(numberingSystemsInfo); if (U_SUCCESS(status)) {
gNumsysNames = numsysNames.orphan();
}
}
¤ 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.10Bemerkung:
(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.