From 8c9aab5002a7fd6d1a98f8a8d4d861cab9b687b8 Mon Sep 17 00:00:00 2001 From: George Rhoten Date: Wed, 15 Sep 2004 23:44:48 +0000 Subject: [PATCH] ICU-4078 Further separate the default converter from the rest of the API X-SVN-Rev: 16331 --- icu4c/source/i18n/calendar.cpp | 10 +++++----- icu4c/source/i18n/choicfmt.cpp | 4 ++-- icu4c/source/i18n/nfrs.cpp | 2 +- icu4c/source/i18n/olsontz.cpp | 3 ++- icu4c/source/i18n/rbnf.cpp | 2 +- icu4c/source/i18n/smpdtfmt.cpp | 2 +- icu4c/source/i18n/timezone.cpp | 8 +++++--- 7 files changed, 17 insertions(+), 14 deletions(-) diff --git a/icu4c/source/i18n/calendar.cpp b/icu4c/source/i18n/calendar.cpp index 9fe589c9b6f..f75416018a0 100644 --- a/icu4c/source/i18n/calendar.cpp +++ b/icu4c/source/i18n/calendar.cpp @@ -182,7 +182,7 @@ protected: return FALSE; } for(int32_t i=0;gBasicCalendars[i] != NULL;i++) { - UnicodeString ourId(gBasicCalendars[i],""); + UnicodeString ourId(gBasicCalendars[i],-1, US_INV); if(ourId == id) { return TRUE; } @@ -194,7 +194,7 @@ protected: { if (U_SUCCESS(status)) { for(int32_t i=0;gBasicCalendars[i] != NULL;i++) { - UnicodeString id(gBasicCalendars[i],""); + UnicodeString id(gBasicCalendars[i], -1, US_INV); result.put(id, (void*)this, status); } } @@ -223,7 +223,7 @@ protected: if(len > actLen) { len = actLen; } - str.extract(0,len,tmp); + str.extract(0,len,tmp, sizeof(tmp), US_INV); tmp[len]=0; #ifdef U_DEBUG_CALSVC @@ -296,7 +296,7 @@ class DefaultCalendarFactory : public ICUResourceBundleFactory { class CalendarService : public ICULocaleService { public: CalendarService() - : ICULocaleService("Calendar") + : ICULocaleService(UNICODE_STRING_SIMPLE("Calendar")) { UErrorCode status = U_ZERO_ERROR; registerFactory(new DefaultCalendarFactory(), status); @@ -655,7 +655,7 @@ Calendar::createInstance(TimeZone* zone, const Locale& aLocale, UErrorCode& succ if(len > actLen) { len = actLen; } - str.extract(0,len,tmp); + str.extract(0,len,tmp,sizeof(tmp),US_INV); tmp[len]=0; #ifdef U_DEBUG_CALSVC diff --git a/icu4c/source/i18n/choicfmt.cpp b/icu4c/source/i18n/choicfmt.cpp index 645d492ccad..550fa6792a7 100644 --- a/icu4c/source/i18n/choicfmt.cpp +++ b/icu4c/source/i18n/choicfmt.cpp @@ -195,7 +195,7 @@ ChoiceFormat::stod(const UnicodeString& string) char source[256]; char* end; - string.extract(0, string.length(), source, sizeof(source), ""); /* invariant codepage */ + string.extract(0, string.length(), source, sizeof(source), US_INV); /* invariant codepage */ return uprv_strtod(source,&end); } @@ -211,7 +211,7 @@ ChoiceFormat::dtos(double value, char temp[256]; uprv_dtostr(value, temp, 3, TRUE); - string = UnicodeString(temp, ""); /* invariant codepage */ + string = UnicodeString(temp, -1, US_INV); /* invariant codepage */ return string; } diff --git a/icu4c/source/i18n/nfrs.cpp b/icu4c/source/i18n/nfrs.cpp index 54d96798e27..465a21f94aa 100644 --- a/icu4c/source/i18n/nfrs.cpp +++ b/icu4c/source/i18n/nfrs.cpp @@ -154,7 +154,7 @@ NFRuleSet::NFRuleSet(UnicodeString* descriptions, int32_t index, UErrorCode& sta description.remove(0, pos); } } else { - name.setTo("%default"); + name.setTo(UNICODE_STRING_SIMPLE("%default")); } if (description.length() == 0) { diff --git a/icu4c/source/i18n/olsontz.cpp b/icu4c/source/i18n/olsontz.cpp index 3f5170f4b53..c2665dc7888 100644 --- a/icu4c/source/i18n/olsontz.cpp +++ b/icu4c/source/i18n/olsontz.cpp @@ -175,9 +175,10 @@ OlsonTimeZone::OlsonTimeZone(const UResourceBundle* top, // 3, 1, -1, 7200, 0, 9, -31, -1, 7200, 0, 3600 data = ures_getIntVector(r, &len, &ec); if (U_SUCCESS(ec) && len == 11) { + UnicodeString emptyStr; U_DEBUG_TZ_MSG(("zone%s, rule%s: {%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d}", zKey, ures_getKey(r), data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8], data[9], data[10])); - finalZone = new SimpleTimeZone(rawOffset, "", + finalZone = new SimpleTimeZone(rawOffset, emptyStr, (int8_t)data[0], (int8_t)data[1], (int8_t)data[2], data[3] * U_MILLIS_PER_SECOND, (SimpleTimeZone::TimeMode) data[4], diff --git a/icu4c/source/i18n/rbnf.cpp b/icu4c/source/i18n/rbnf.cpp index 5924bd0be97..54c07dd4bc5 100644 --- a/icu4c/source/i18n/rbnf.cpp +++ b/icu4c/source/i18n/rbnf.cpp @@ -416,7 +416,7 @@ RuleBasedNumberFormat::setDefaultRuleSet(const UnicodeString& ruleSetName, UErro if (U_SUCCESS(status)) { if (ruleSetName.isEmpty()) { initDefaultRuleSet(); - } else if (ruleSetName.startsWith("%%")) { + } else if (ruleSetName.startsWith(UNICODE_STRING_SIMPLE("%%"))) { status = U_ILLEGAL_ARGUMENT_ERROR; } else { NFRuleSet* result = findRuleSet(ruleSetName, status); diff --git a/icu4c/source/i18n/smpdtfmt.cpp b/icu4c/source/i18n/smpdtfmt.cpp index efac1616d49..9d79d8e07c8 100644 --- a/icu4c/source/i18n/smpdtfmt.cpp +++ b/icu4c/source/i18n/smpdtfmt.cpp @@ -1397,7 +1397,7 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC // a little more permissive than RFC 822. It will try to do // its best with numbers that aren't strictly 4 digits long. UErrorCode status = U_ZERO_ERROR; - DecimalFormat fmt("+####;-####", status); + DecimalFormat fmt(UNICODE_STRING_SIMPLE("+####;-####"), status); if(U_FAILURE(status)) return -start; fmt.setParseIntegerOnly(TRUE); diff --git a/icu4c/source/i18n/timezone.cpp b/icu4c/source/i18n/timezone.cpp index db7043afa2a..30af52fbf1d 100644 --- a/icu4c/source/i18n/timezone.cpp +++ b/icu4c/source/i18n/timezone.cpp @@ -90,6 +90,8 @@ static char gStrBuf[256]; // Static data and constants static const UChar GMT_ID[] = {0x47, 0x4D, 0x54, 0x00}; /* "GMT" */ +static const UChar Z_STR[] = {0x7A, 0x00}; /* "z" */ +static const UChar ZZZZ_STR[] = {0x7A, 0x7A, 0x7A, 0x7A, 0x00}; /* "zzzz" */ static const int32_t GMT_ID_LENGTH = 3; static const UChar CUSTOM_ID[] = { @@ -252,7 +254,7 @@ static UResourceBundle* getZoneByName(const UResourceBundle* top, const UnicodeS UResourceBundle* TimeZone::loadRule(const UResourceBundle* top, const UnicodeString& ruleid, UResourceBundle* oldbundle, UErrorCode& status) { char key[64]; - ruleid.extract(0, sizeof(key)-1, key, sizeof(key)-1, ""); + ruleid.extract(0, sizeof(key)-1, key, sizeof(key)-1, US_INV); U_DEBUG_TZ_MSG(("loadRule(%s)\n", key)); UResourceBundle *r = ures_getByKey(top, kRULES, oldbundle, &status); U_DEBUG_TZ_MSG(("loadRule(%s) -> kRULES [%s]\n", key, u_errorName(status))); @@ -1080,7 +1082,7 @@ TimeZone::getDisplayName(UBool daylight, EDisplayType style, const Locale& local char buf[128]; fID.extract(0, sizeof(buf)-1, buf, sizeof(buf), ""); #endif - SimpleDateFormat format(style == LONG ? "zzzz" : "z",locale,status); + SimpleDateFormat format(style == LONG ? ZZZZ_STR : Z_STR,locale,status); U_DEBUG_TZ_MSG(("getDisplayName(%s)\n", buf)); if(!U_SUCCESS(status)) { @@ -1105,7 +1107,7 @@ TimeZone::getDisplayName(UBool daylight, EDisplayType style, const Locale& local UCAL_DECEMBER , 31, 0, U_MILLIS_PER_DAY, status) : new SimpleTimeZone(getRawOffset(), getID(tempID)); - format.applyPattern(style == LONG ? "zzzz" : "z"); + format.applyPattern(style == LONG ? ZZZZ_STR : Z_STR); Calendar *myCalendar = (Calendar*)format.getCalendar(); myCalendar->setTimeZone(*tz); // copy