- // check to see whether we need to titlecase result
- if ( result.length() > 0 && u_islower(result.char32At(0)) && capitalizationBrkIter!= NULL &&
+ // check to see whether we need to titlecase result-- we check the first word (up to the first space),
+ // and only titlecase the result if that first word contains no capital letters
+ UBool needToTitlecase = TRUE;
+ for (int32_t i = 0; needToTitlecase && i < result.length(); i++) {
+ UChar32 c = result.char32At(i);
+ if (u_isupper(c) || u_istitle(c)) {
+ needToTitlecase = FALSE;
+ } else if (u_isspace(c)) {
+ break;
+ }
+ }
+
+ if (needToTitlecase && capitalizationBrkIter!= NULL &&