ICU-4189 UCONFIG_NO_CONVERSION work.

X-SVN-Rev: 17132
This commit is contained in:
George Rhoten 2005-01-15 04:46:14 +00:00
parent a4f9b34c4a
commit ec139de0db
2 changed files with 23 additions and 33 deletions
icu4c/source/i18n

View file

@ -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;

View file

@ -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.