+#if !UCONFIG_NO_BREAK_ITERATION
+ // Apple addition for <rdar://problem/27335144>
+ if (u_islower(res[index].char32At(0)) && capitalizationBrkIter != NULL) {
+ UDisplayContext capitalizationContext = ((const DateFormat*)fmt)->getContext(UDISPCTX_TYPE_CAPITALIZATION, *status);
+ UBool titlecase = FALSE;
+ switch (capitalizationContext) {
+ case UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE:
+ titlecase = TRUE;
+ break;
+ case UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU:
+ titlecase = syms->capitalizeForUsage(capUsageFromSymbolType(type), 0);
+ break;
+ case UDISPCTX_CAPITALIZATION_FOR_STANDALONE:
+ titlecase = syms->capitalizeForUsage(capUsageFromSymbolType(type), 1);
+ break;
+ default:
+ // titlecase = FALSE;
+ break;
+ }
+ if (titlecase) {
+ UnicodeString symbolToModify(res[index]);
+ BreakIterator* capBrkIterToUse = capitalizationBrkIter->clone();
+ if (capBrkIterToUse != NULL) {
+ Locale locale = capBrkIterToUse->getLocale(ULOC_ACTUAL_LOCALE, *status);
+ if (U_SUCCESS(*status)) {
+ symbolToModify.toTitle(capBrkIterToUse, locale, U_TITLECASE_NO_LOWERCASE | U_TITLECASE_NO_BREAK_ADJUSTMENT);
+ delete capBrkIterToUse;
+ return symbolToModify.extract(result, resultLength, *status);
+ }
+ delete capBrkIterToUse;
+ }
+ }
+ }
+#endif