From ec139de0db5e4f3b4e6787ea9fd57b5d28b6d7bd Mon Sep 17 00:00:00 2001 From: George Rhoten Date: Sat, 15 Jan 2005 04:46:14 +0000 Subject: [PATCH] ICU-4189 UCONFIG_NO_CONVERSION work. X-SVN-Rev: 17132 --- icu4c/source/i18n/calendar.cpp | 18 +++------------- icu4c/source/i18n/name2uni.cpp | 38 ++++++++++++++++++---------------- 2 files changed, 23 insertions(+), 33 deletions(-) diff --git a/icu4c/source/i18n/calendar.cpp b/icu4c/source/i18n/calendar.cpp index f2ae7445cb6..0fc8bc8edf4 100644 --- a/icu4c/source/i18n/calendar.cpp +++ b/icu4c/source/i18n/calendar.cpp @@ -685,26 +685,14 @@ Calendar::createInstance(TimeZone* zone, const Locale& aLocale, UErrorCode& succ #if !UCONFIG_NO_SERVICE if(u->getDynamicClassID() == UnicodeString::getStaticClassID()) { // It's a unicode string telling us what type of calendar to load ("gregorian", etc) - char tmp[ULOC_FULLNAME_CAPACITY]; const UnicodeString& str = *(UnicodeString*)u; - // Extract a char* out of it.. - int32_t len = str.length(); - int32_t actLen = sizeof(tmp)-1; - if(len > actLen) { - len = actLen; - } - str.extract(0,len,tmp); - tmp[len]=0; -#ifdef U_DEBUG_CALSVC - fprintf(stderr, "Calendar::createInstance(%s), fetched string %s..\n", (const char*)aLocale.getName(), tmp); -#endif - // Create a Locale over this string - Locale l = Locale::createFromName(tmp); + Locale l(""); + LocaleUtility::initLocaleFromName(str, l); #ifdef U_DEBUG_CALSVC - fprintf(stderr, "looking up [%s].. should be %s\n",l.getName(), tmp); + fprintf(stderr, "Calendar::createInstance(%s), looking up [%s]\n", aLocale.getName(), l.getName()); #endif Locale actualLoc2; diff --git a/icu4c/source/i18n/name2uni.cpp b/icu4c/source/i18n/name2uni.cpp index 255a4bc63e6..18d7b18a2c5 100644 --- a/icu4c/source/i18n/name2uni.cpp +++ b/icu4c/source/i18n/name2uni.cpp @@ -18,6 +18,7 @@ #include "name2uni.h" #include "cmemory.h" #include "uprops.h" +#include "uinvchar.h" #include "util.h" U_NAMESPACE_BEGIN @@ -172,7 +173,6 @@ void NameUnicodeTransliterator::handleTransliterate(Replaceable& text, UTransPos } if (c == CLOSE_DELIM) { - int32_t len = name.length(); // Delete trailing space, if any @@ -181,27 +181,29 @@ void NameUnicodeTransliterator::handleTransliterate(Replaceable& text, UTransPos --len; } - name.extract(0, len, cbuf, ""); + if (uprv_isInvariantUString(name.getBuffer(), len)) { + name.extract(0, len, cbuf, maxLen, US_INV); - UErrorCode status = U_ZERO_ERROR; - c = u_charFromName(U_EXTENDED_CHAR_NAME, cbuf, &status); - if (U_SUCCESS(status)) { - // Lookup succeeded + UErrorCode status = U_ZERO_ERROR; + c = u_charFromName(U_EXTENDED_CHAR_NAME, cbuf, &status); + if (U_SUCCESS(status)) { + // Lookup succeeded - // assert(UTF_CHAR_LENGTH(CLOSE_DELIM) == 1); - cursor++; // advance over CLOSE_DELIM + // assert(UTF_CHAR_LENGTH(CLOSE_DELIM) == 1); + cursor++; // advance over CLOSE_DELIM - str.truncate(0); - str.append(c); - text.handleReplaceBetween(openPos, cursor, str); + str.truncate(0); + str.append(c); + text.handleReplaceBetween(openPos, cursor, str); - // Adjust indices for the change in the length of - // the string. Do not assume that str.length() == - // 1, in case of surrogates. - int32_t delta = cursor - openPos - str.length(); - cursor -= delta; - limit -= delta; - // assert(cursor == openPos + str.length()); + // Adjust indices for the change in the length of + // the string. Do not assume that str.length() == + // 1, in case of surrogates. + int32_t delta = cursor - openPos - str.length(); + cursor -= delta; + limit -= delta; + // assert(cursor == openPos + str.length()); + } } // If the lookup failed, we leave things as-is and // still switch to mode 0 and continue.