// all instances of RBBIRuleScanners. BUT this is quite a bit simpler,
// and the time to build these few sets should be small compared to a
// full break iterator build.
- fRuleSets[kRuleSet_rule_char-128] = UnicodeSet(gRuleSet_rule_char_pattern, *rb->fStatus);
+ fRuleSets[kRuleSet_rule_char-128]
+ = UnicodeSet(UnicodeString(gRuleSet_rule_char_pattern), *rb->fStatus);
// fRuleSets[kRuleSet_white_space-128] = [:Pattern_White_Space:]
- fRuleSets[kRuleSet_white_space-128].add(9, 0xd).add(0x20).add(0x85).add(0x200e, 0x200f).add(0x2028, 0x2029);
- fRuleSets[kRuleSet_name_char-128] = UnicodeSet(gRuleSet_name_char_pattern, *rb->fStatus);
- fRuleSets[kRuleSet_name_start_char-128] = UnicodeSet(gRuleSet_name_start_char_pattern, *rb->fStatus);
- fRuleSets[kRuleSet_digit_char-128] = UnicodeSet(gRuleSet_digit_char_pattern, *rb->fStatus);
+ fRuleSets[kRuleSet_white_space-128].
+ add(9, 0xd).add(0x20).add(0x85).add(0x200e, 0x200f).add(0x2028, 0x2029);
+ fRuleSets[kRuleSet_name_char-128]
+ = UnicodeSet(UnicodeString(gRuleSet_name_char_pattern), *rb->fStatus);
+ fRuleSets[kRuleSet_name_start_char-128]
+ = UnicodeSet(UnicodeString(gRuleSet_name_start_char_pattern), *rb->fStatus);
+ fRuleSets[kRuleSet_digit_char-128]
+ = UnicodeSet(UnicodeString(gRuleSet_digit_char_pattern), *rb->fStatus);
if (*rb->fStatus == U_ILLEGAL_ARGUMENT_ERROR) {
// This case happens if ICU's data is missing. UnicodeSet tries to look up property
// names from the init string, can't find them, and claims an illegal argument.
// sets that just happen to contain only one character.
{
n = pushNewNode(RBBINode::setRef);
- findSetFor(fC.fChar, n);
+ findSetFor(UnicodeString(fC.fChar), n);
n->fFirstPos = fScanIndex;
n->fLastPos = fNextIndex;
fRB->fRules.extractBetween(n->fFirstPos, n->fLastPos, n->fText);
// scanned a ".", meaning match any single character.
{
n = pushNewNode(RBBINode::setRef);
- findSetFor(kAny, n);
+ findSetFor(UnicodeString(TRUE, kAny, 3), n);
n->fFirstPos = fScanIndex;
n->fLastPos = fNextIndex;
fRB->fRules.extractBetween(n->fFirstPos, n->fLastPos, n->fText);
if (fRB->fReverseTree == NULL) {
fRB->fReverseTree = pushNewNode(RBBINode::opStar);
RBBINode *operand = pushNewNode(RBBINode::setRef);
- findSetFor(kAny, operand);
+ findSetFor(UnicodeString(TRUE, kAny, 3), operand);
fRB->fReverseTree->fLeftChild = operand;
operand->fParent = fRB->fReverseTree;
fNodeStackPtr -= 2;
*/
#define UNICODE_STRING_SIMPLE(cs) UNICODE_STRING(cs, -1)
+/**
+ * \def UNISTR_FROM_CHAR_EXPLICIT
+ * This can be defined to be empty or "explicit".
+ * If explicit, then the UnicodeString(UChar) and UnicodeString(UChar32)
+ * constructors are marked as explicit, preventing their inadvertent use.
+ * @draft ICU 49
+ */
+#ifndef UNISTR_FROM_CHAR_EXPLICIT
+# if defined(U_COMBINED_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION) || defined(U_I18N_IMPLEMENTATION) || defined(U_IO_IMPLEMENTATION)
+ // Auto-"explicit" in ICU library code.
+# define UNISTR_FROM_CHAR_EXPLICIT explicit
+# else
+ // Empty by default for source code compatibility.
+# define UNISTR_FROM_CHAR_EXPLICIT
+# endif
+#endif
+
+/**
+ * \def UNISTR_FROM_STRING_EXPLICIT
+ * This can be defined to be empty or "explicit".
+ * If explicit, then the UnicodeString(const char *) and UnicodeString(const UChar *)
+ * constructors are marked as explicit, preventing their inadvertent use.
+ *
+ * In particular, this helps prevent accidentally depending on ICU conversion code
+ * by passing a string literal into an API with a const UnicodeString & parameter.
+ * @draft ICU 49
+ */
+#ifndef UNISTR_FROM_STRING_EXPLICIT
+# if defined(U_COMBINED_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION) || defined(U_I18N_IMPLEMENTATION) || defined(U_IO_IMPLEMENTATION)
+ // Auto-"explicit" in ICU library code.
+# define UNISTR_FROM_STRING_EXPLICIT explicit
+# else
+ // Empty by default for source code compatibility.
+# define UNISTR_FROM_STRING_EXPLICIT
+# endif
+#endif
+
/**
* UnicodeString is a string class that stores Unicode characters directly and provides
* similar functionality as the Java String and StringBuffer classes.
/**
* Single UChar (code unit) constructor.
+ *
+ * It is recommended to mark this constructor "explicit" by
+ * <code>-DUNISTR_FROM_CHAR_EXPLICIT=explicit</code>
+ * on the compiler command line or similar.
* @param ch the character to place in the UnicodeString
* @stable ICU 2.0
*/
- UnicodeString(UChar ch);
+ UNISTR_FROM_CHAR_EXPLICIT UnicodeString(UChar ch);
/**
* Single UChar32 (code point) constructor.
+ *
+ * It is recommended to mark this constructor "explicit" by
+ * <code>-DUNISTR_FROM_CHAR_EXPLICIT=explicit</code>
+ * on the compiler command line or similar.
* @param ch the character to place in the UnicodeString
* @stable ICU 2.0
*/
- UnicodeString(UChar32 ch);
+ UNISTR_FROM_CHAR_EXPLICIT UnicodeString(UChar32 ch);
/**
* UChar* constructor.
+ *
+ * It is recommended to mark this constructor "explicit" by
+ * <code>-DUNISTR_FROM_STRING_EXPLICIT=explicit</code>
+ * on the compiler command line or similar.
* @param text The characters to place in the UnicodeString. <TT>text</TT>
* must be NULL (U+0000) terminated.
* @stable ICU 2.0
*/
- UnicodeString(const UChar *text);
+ UNISTR_FROM_STRING_EXPLICIT UnicodeString(const UChar *text);
/**
* UChar* constructor.
/**
* char* constructor.
+ * Uses the default converter (and thus depends on the ICU conversion code)
+ * unless U_CHARSET_IS_UTF8 is set to 1.
+ *
+ * It is recommended to mark this constructor "explicit" by
+ * <code>-DUNISTR_FROM_STRING_EXPLICIT=explicit</code>
+ * on the compiler command line or similar.
* @param codepageData an array of bytes, null-terminated,
* in the platform's default codepage.
* @stable ICU 2.0
*/
- UnicodeString(const char *codepageData);
+ UNISTR_FROM_STRING_EXPLICIT UnicodeString(const char *codepageData);
/**
* char* constructor.
+ * Uses the default converter (and thus depends on the ICU conversion code)
+ * unless U_CHARSET_IS_UTF8 is set to 1.
* @param codepageData an array of bytes in the platform's default codepage.
* @param dataLength The number of bytes in <TT>codepageData</TT>.
* @stable ICU 2.0
c = chars.next(opts, literal, ec);
if (U_FAILURE(ec)) return;
if (c == 0x5D /*']'*/ && !literal) {
- patLocal.append(HYPHEN_RIGHT_BRACE);
+ patLocal.append(HYPHEN_RIGHT_BRACE, 2);
mode = 2;
continue;
}
}
// Look for the matching close delimiter, either :] or }
- int32_t close = pattern.indexOf(posix ? POSIX_CLOSE : PERL_CLOSE, pos);
+ int32_t close;
+ if (posix) {
+ close = pattern.indexOf(POSIX_CLOSE, 2, pos);
+ } else {
+ close = pattern.indexOf(CLOSE_BRACE, pos);
+ }
if (close < 0) {
// Syntax error; close delimiter missing
FAIL(ec);
index--;
break;
}
- int32_t compareResult = col->compare(name, (*HACK_PINYIN_LOOKUP)[index]);
+ int32_t compareResult = col->compare(name, UnicodeString(TRUE, (*HACK_PINYIN_LOOKUP)[index], -1));
if (compareResult < 0) {
index--;
}
// Try to pivot around Latin, our most common script
id = sourceName;
- id.append(LATIN_PIVOT).append(target);
+ id.append(LATIN_PIVOT, -1).append(target);
t = Transliterator::createInstance(id, UTRANS_FORWARD, ec);
if (U_FAILURE(ec) || t == NULL) {
delete t;
Transliterator::_getAvailableSource(s, source);
// Ignore the "Any" source
- if (source.caseCompare(ANY, 0 /*U_FOLD_CASE_DEFAULT*/) == 0) continue;
+ if (source.caseCompare(ANY, 3, 0 /*U_FOLD_CASE_DEFAULT*/) == 0) continue;
int32_t targetCount = Transliterator::_countAvailableTargets(source);
for (int32_t t=0; t<targetCount; ++t) {
Transliterator::_getAvailableVariant(v, source, target, variant);
UnicodeString id;
- TransliteratorIDParser::STVtoID(ANY, target, variant, id);
+ TransliteratorIDParser::STVtoID(UnicodeString(TRUE, ANY, 3), target, variant, id);
ec = U_ZERO_ERROR;
AnyTransliterator* t = new AnyTransliterator(id, target, variant,
targetScript, ec);
delete t;
} else {
Transliterator::_registerInstance(t);
- Transliterator::_registerSpecialInverse(target, NULL_ID, FALSE);
+ Transliterator::_registerSpecialInverse(target, UnicodeString(TRUE, NULL_ID, 4), FALSE);
}
}
}
/*
**********************************************************************
-* Copyright (C) 1999-2008, International Business Machines
+* Copyright (C) 1999-2011, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
* Date Name Description
static const UChar ID_DELIM = 0x003B; /*;*/
static const UChar NEWLINE = 10;
-// Empty string
-static const UChar EMPTY[] = {0}; //""
static const UChar COLON_COLON[] = {0x3A, 0x3A, 0}; //"::"
U_NAMESPACE_BEGIN
CompoundTransliterator::CompoundTransliterator(UVector& list,
UParseError& /*parseError*/,
UErrorCode& status) :
- Transliterator(EMPTY, NULL),
+ Transliterator(UnicodeString(), NULL),
trans(0), numAnonymousRBTs(0)
{
// TODO add code for parseError...currently unused, but
int32_t anonymousRBTs,
UParseError& /*parseError*/,
UErrorCode& status) :
- Transliterator(EMPTY, NULL),
+ Transliterator(UnicodeString(), NULL),
trans(0), numAnonymousRBTs(anonymousRBTs)
{
init(list, UTRANS_FORWARD, FALSE, status);
// If we are a compound RBT and if we have a global
// filter, then emit it at the top.
UnicodeString pat;
- rulesSource.append(COLON_COLON).append(getFilter()->toPattern(pat, escapeUnprintable)).append(ID_DELIM);
+ rulesSource.append(COLON_COLON, 2).append(getFilter()->toPattern(pat, escapeUnprintable)).append(ID_DELIM);
}
for (int32_t i=0; i<count; ++i) {
UnicodeString rule;
// ::BEGIN/::END blocks) are given IDs that begin with
// "%Pass": use toRules() to write all the rules to the output
// (and insert "::Null;" if we have two in a row)
- if (trans[i]->getID().startsWith(PASS_STRING)) {
+ if (trans[i]->getID().startsWith(PASS_STRING, 5)) {
trans[i]->toRules(rule, escapeUnprintable);
- if (numAnonymousRBTs > 1 && i > 0 && trans[i - 1]->getID().startsWith(PASS_STRING))
+ if (numAnonymousRBTs > 1 && i > 0 && trans[i - 1]->getID().startsWith(PASS_STRING, 5))
rule = UNICODE_STRING_SIMPLE("::Null;") + rule;
// we also use toRules() on CompoundTransliterators (which we
(UnicodeString*)fPluralCountToCurrencyUnitPattern->get(pluralCount);
if (currencyPluralPattern == NULL) {
// fall back to "other"
- if (pluralCount.compare(gPluralCountOther)) {
+ if (pluralCount.compare(gPluralCountOther, 5)) {
currencyPluralPattern =
- (UnicodeString*)fPluralCountToCurrencyUnitPattern->get(gPluralCountOther);
+ (UnicodeString*)fPluralCountToCurrencyUnitPattern->get(UnicodeString(TRUE, gPluralCountOther, 5));
}
if (currencyPluralPattern == NULL) {
// no currencyUnitPatterns defined,
pattern->extract(0, pattern->length(), result_1, "UTF-8");
std::cout << "pluralCount: " << pluralCount << "; pattern: " << result_1 << "\n";
#endif
- pattern->findAndReplace(gPart0,
+ pattern->findAndReplace(UnicodeString(TRUE, gPart0, 3),
UnicodeString(numberStylePattern, numberStylePatternLen));
- pattern->findAndReplace(gPart1, gTripleCurrencySign);
+ pattern->findAndReplace(UnicodeString(TRUE, gPart1, 3), UnicodeString(TRUE, gTripleCurrencySign, 3));
if (hasSeparator) {
UnicodeString negPattern(patternChars, ptnLen);
- negPattern.findAndReplace(gPart0,
+ negPattern.findAndReplace(UnicodeString(TRUE, gPart0, 3),
UnicodeString(negNumberStylePattern, negNumberStylePatternLen));
- negPattern.findAndReplace(gPart1, gTripleCurrencySign);
+ negPattern.findAndReplace(UnicodeString(TRUE, gPart1, 3), UnicodeString(TRUE, gTripleCurrencySign, 3));
pattern->append(gNumberPatternSeparator);
pattern->append(negPattern);
}
/*
*******************************************************************************
-* Copyright (C) 1997-2010, International Business Machines Corporation and *
+* Copyright (C) 1997-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*
NumberingSystem* ns = NumberingSystem::createInstance(loc,status);
if (U_SUCCESS(status) && ns->getRadix() == 10 && !ns->isAlgorithmic()) {
nsName = ns->getName();
- UnicodeString *DigitString = new UnicodeString(ns->getDescription());
- setSymbol(kZeroDigitSymbol,DigitString->charAt(0),FALSE);
- setSymbol(kOneDigitSymbol,DigitString->charAt(1),FALSE);
- setSymbol(kTwoDigitSymbol,DigitString->charAt(2),FALSE);
- setSymbol(kThreeDigitSymbol,DigitString->charAt(3),FALSE);
- setSymbol(kFourDigitSymbol,DigitString->charAt(4),FALSE);
- setSymbol(kFiveDigitSymbol,DigitString->charAt(5),FALSE);
- setSymbol(kSixDigitSymbol,DigitString->charAt(6),FALSE);
- setSymbol(kSevenDigitSymbol,DigitString->charAt(7),FALSE);
- setSymbol(kEightDigitSymbol,DigitString->charAt(8),FALSE);
- setSymbol(kNineDigitSymbol,DigitString->charAt(9),FALSE);
- delete DigitString;
+ UnicodeString digitString(ns->getDescription());
+ setSymbol(kZeroDigitSymbol, digitString.tempSubString(0, 1), FALSE);
+ setSymbol(kOneDigitSymbol, digitString.tempSubString(1, 1), FALSE);
+ setSymbol(kTwoDigitSymbol, digitString.tempSubString(2, 1), FALSE);
+ setSymbol(kThreeDigitSymbol, digitString.tempSubString(3, 1), FALSE);
+ setSymbol(kFourDigitSymbol, digitString.tempSubString(4, 1), FALSE);
+ setSymbol(kFiveDigitSymbol, digitString.tempSubString(5, 1), FALSE);
+ setSymbol(kSixDigitSymbol, digitString.tempSubString(6, 1), FALSE);
+ setSymbol(kSevenDigitSymbol, digitString.tempSubString(7, 1), FALSE);
+ setSymbol(kEightDigitSymbol, digitString.tempSubString(8, 1), FALSE);
+ setSymbol(kNineDigitSymbol, digitString.tempSubString(9, 1), FALSE);
} else {
nsName = gLatn;
}
}
if ( U_SUCCESS(localStatus) ) {
- setSymbol((ENumberFormatSymbol)i,sym);
+ setSymbol((ENumberFormatSymbol)i, UnicodeString(TRUE, sym, len));
if ( i == kMonetarySeparatorSymbol ) {
kMonetaryDecimalSet = TRUE;
} else if ( i == kMonetaryGroupingSeparatorSymbol ) {
// Reuse numberElements[0] as a temporary buffer
uprv_getStaticCurrencyName(curriso, locStr, tempStr, internalStatus);
if (U_SUCCESS(internalStatus)) {
- fSymbols[kIntlCurrencySymbol] = curriso;
+ fSymbols[kIntlCurrencySymbol].setTo(curriso, -1);
fSymbols[kCurrencySymbol] = tempStr;
}
/* else use the default values. */
currency = ures_getByIndex(currency, 2, currency, &localStatus);
int32_t currPatternLen = 0;
currPattern = ures_getStringByIndex(currency, (int32_t)0, &currPatternLen, &localStatus);
- UnicodeString decimalSep = ures_getStringByIndex(currency, (int32_t)1, NULL, &localStatus);
- UnicodeString groupingSep = ures_getStringByIndex(currency, (int32_t)2, NULL, &localStatus);
+ UnicodeString decimalSep = ures_getUnicodeStringByIndex(currency, (int32_t)1, &localStatus);
+ UnicodeString groupingSep = ures_getUnicodeStringByIndex(currency, (int32_t)2, &localStatus);
if(U_SUCCESS(localStatus)){
fSymbols[kMonetaryGroupingSeparatorSymbol] = groupingSep;
fSymbols[kMonetarySeparatorSymbol] = decimalSep;
if (localStatus == U_USING_FALLBACK_WARNING || U_SUCCESS(localStatus)) {
localStatus = U_ZERO_ERROR;
for (int32_t i = 0; i < UNUM_CURRENCY_SPACING_COUNT; i++) {
- currencySpcBeforeSym[i] = ures_getStringByKey(dataRes, keywords[i],
- NULL, &localStatus);
+ currencySpcBeforeSym[i] = ures_getUnicodeStringByKey(dataRes, keywords[i], &localStatus);
}
ures_close(dataRes);
}
if (localStatus == U_USING_FALLBACK_WARNING || U_SUCCESS(localStatus)) {
localStatus = U_ZERO_ERROR;
for (int32_t i = 0; i < UNUM_CURRENCY_SPACING_COUNT; i++) {
- currencySpcAfterSym[i] = ures_getStringByKey(dataRes, keywords[i],
- NULL, &localStatus);
+ currencySpcAfterSym[i] = ures_getUnicodeStringByKey(dataRes, keywords[i], &localStatus);
}
ures_close(dataRes);
}
fSymbols[kPlusSignSymbol] = (UChar)0x002b; // '+' plus sign
fSymbols[kMinusSignSymbol] = (UChar)0x2d; // '-' minus sign
fSymbols[kCurrencySymbol] = (UChar)0xa4; // 'OX' currency symbol
- fSymbols[kIntlCurrencySymbol] = INTL_CURRENCY_SYMBOL_STR;
+ fSymbols[kIntlCurrencySymbol].setTo(TRUE, INTL_CURRENCY_SYMBOL_STR, 2);
fSymbols[kMonetarySeparatorSymbol] = (UChar)0x2e; // '.' monetary decimal separator
fSymbols[kExponentialSymbol] = (UChar)0x45; // 'E' exponential
fSymbols[kPerMillSymbol] = (UChar)0x2030; // '%o' per mill
// need it for mix parsing
setupCurrencyAffixPatterns(status);
// expanded affixes for plural names
- if (patternUsed->indexOf(fgTripleCurrencySign) != -1) {
+ if (patternUsed->indexOf(fgTripleCurrencySign, 3, 0) != -1) {
setupCurrencyAffixes(*patternUsed, TRUE, TRUE, status);
}
}
uprv_getStaticCurrencyName(intlCurrencySymbol, loc, currencySymbol, ec);
if (U_SUCCESS(ec)
&& getConstSymbol(DecimalFormatSymbols::kCurrencySymbol) == currencySymbol
- && getConstSymbol(DecimalFormatSymbols::kIntlCurrencySymbol) == intlCurrencySymbol)
+ && getConstSymbol(DecimalFormatSymbols::kIntlCurrencySymbol) == UnicodeString(intlCurrencySymbol))
{
// Trap an error in mapping locale to currency. If we can't
// map, then don't fail and set the currency to "".
}
UnicodeString DecimalFormat::getPadCharacterString() const {
- return fPad;
+ return UnicodeString(fPad);
}
void DecimalFormat::setPadCharacter(const UnicodeString &padChar) {
affix += UnicodeString(s, len);
handler.addAttribute(kCurrencyField, beginIdx, affix.length());
} else if(intl) {
- affix += currencyUChars;
+ affix.append(currencyUChars, -1);
handler.addAttribute(kCurrencyField, beginIdx, affix.length());
} else {
int32_t len;
// return.
if (fCurrencyChoice == NULL) {
// TODO Replace double-check with proper thread-safe code
- ChoiceFormat* fmt = new ChoiceFormat(s, ec);
+ ChoiceFormat* fmt = new ChoiceFormat(UnicodeString(s), ec);
if (U_SUCCESS(ec)) {
umtx_lock(NULL);
if (fCurrencyChoice == NULL) {
} else {
// We only arrive here if the currency choice
// format in the locale data is INVALID.
- affix += currencyUChars;
+ affix.append(currencyUChars, -1);
handler.addAttribute(kCurrencyField, beginIdx, affix.length());
}
}
if (fAffixPatternsForCurrency == NULL) {
setupCurrencyAffixPatterns(status);
}
- if (pattern.indexOf(fgTripleCurrencySign) != -1) {
+ if (pattern.indexOf(fgTripleCurrencySign, 3, 0) != -1) {
// only setup the affixes of the current pattern.
setupCurrencyAffixes(pattern, TRUE, FALSE, status);
}
void DecimalFormat::setCurrency(const UChar* theCurrency, UErrorCode& ec) {
// set the currency before compute affixes to get the right currency names
NumberFormat::setCurrency(theCurrency, ec);
- if (fFormatPattern.indexOf(fgTripleCurrencySign) != -1) {
+ if (fFormatPattern.indexOf(fgTripleCurrencySign, 3, 0) != -1) {
UnicodeString savedPtn = fFormatPattern;
setupCurrencyAffixes(fFormatPattern, TRUE, TRUE, ec);
UParseError parseErr;
if ( timeSkeleton.length() != 0 ) {
if ( dateSkeleton.length() == 0 ) {
// prefix with yMd
- timeSkeleton.insert(0, gDateFormatSkeleton[DateFormat::kShort]);
+ timeSkeleton.insert(0, gDateFormatSkeleton[DateFormat::kShort], -1);
UnicodeString pattern = fDtpng->getBestPattern(timeSkeleton, status);
if ( U_FAILURE(status) ) {
return;
// done
} else if ( dateSkeleton.length() == 0 ) {
// prefix with yMd
- timeSkeleton.insert(0, gDateFormatSkeleton[DateFormat::kShort]);
+ timeSkeleton.insert(0, gDateFormatSkeleton[DateFormat::kShort], -1);
UnicodeString pattern = fDtpng->getBestPattern(timeSkeleton, status);
if ( U_FAILURE(status) ) {
return;
continue;
}
- const UChar* pattern;
const char* key;
- int32_t ptLength;
int32_t ptnNum = ures_getSize(intervalPatterns.getAlias());
int32_t ptnIndex;
for ( ptnIndex = 0; ptnIndex < ptnNum; ++ptnIndex ) {
- pattern = ures_getNextString(intervalPatterns.getAlias(), &ptLength, &key,
- &status);
+ UnicodeString pattern =
+ ures_getNextUnicodeString(intervalPatterns.getAlias(), &key, &status);
if ( U_FAILURE(status) ) {
break;
}
const UnicodeString* inputSkeleton = &skeleton;
UnicodeString copySkeleton;
if ( skeleton.indexOf(CHAR_Z) != -1 ) {
- UChar zstr[2];
- UChar vstr[2];
- zstr[0]=CHAR_Z;
- vstr[0]=CHAR_V;
- zstr[1]=0;
- vstr[1]=0;
copySkeleton = skeleton;
- copySkeleton.findAndReplace(zstr, vstr);
+ copySkeleton.findAndReplace(UnicodeString(CHAR_Z), UnicodeString(CHAR_V));
inputSkeleton = ©Skeleton;
replaceZWithV = true;
}
/*
**********************************************************************
-* Copyright (c) 2001-2006, International Business Machines
+* Copyright (c) 2001-2011, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
* Date Name Description
static const UChar PERLPRE[] = {92,120,123,0}; // "\\x{"
static const UChar SEMI[] = {59,0}; // ";"
static const UChar RBRACE[] = {125,0}; // "}"
-static const UChar EMPTY[] = {0}; // ""
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(EscapeTransliterator)
*/
static Transliterator* _createEscUnicode(const UnicodeString& ID, Transliterator::Token /*context*/) {
// Unicode: "U+10FFFF" hex, min=4, max=6
- return new EscapeTransliterator(ID, UNIPRE, EMPTY, 16, 4, TRUE, NULL);
+ return new EscapeTransliterator(ID, UnicodeString(TRUE, UNIPRE, 2), UnicodeString(), 16, 4, TRUE, NULL);
}
static Transliterator* _createEscJava(const UnicodeString& ID, Transliterator::Token /*context*/) {
// Java: "\\uFFFF" hex, min=4, max=4
- return new EscapeTransliterator(ID, BS_u, EMPTY, 16, 4, FALSE, NULL);
+ return new EscapeTransliterator(ID, UnicodeString(TRUE, BS_u, 2), UnicodeString(), 16, 4, FALSE, NULL);
}
static Transliterator* _createEscC(const UnicodeString& ID, Transliterator::Token /*context*/) {
// C: "\\uFFFF" hex, min=4, max=4; \\U0010FFFF hex, min=8, max=8
- return new EscapeTransliterator(ID, BS_u, EMPTY, 16, 4, TRUE,
- new EscapeTransliterator(EMPTY, BS_U, EMPTY, 16, 8, TRUE, NULL));
+ return new EscapeTransliterator(ID, UnicodeString(TRUE, BS_u, 2), UnicodeString(), 16, 4, TRUE,
+ new EscapeTransliterator(UnicodeString(), UnicodeString(TRUE, BS_U, 2), UnicodeString(), 16, 8, TRUE, NULL));
}
static Transliterator* _createEscXML(const UnicodeString& ID, Transliterator::Token /*context*/) {
// XML: "" hex, min=1, max=6
- return new EscapeTransliterator(ID, XMLPRE, SEMI, 16, 1, TRUE, NULL);
+ return new EscapeTransliterator(ID, UnicodeString(TRUE, XMLPRE, 3), UnicodeString(SEMI[0]), 16, 1, TRUE, NULL);
}
static Transliterator* _createEscXML10(const UnicodeString& ID, Transliterator::Token /*context*/) {
// XML10: "&1114111;" dec, min=1, max=7 (not really "Any-Hex")
- return new EscapeTransliterator(ID, XML10PRE, SEMI, 10, 1, TRUE, NULL);
+ return new EscapeTransliterator(ID, UnicodeString(TRUE, XML10PRE, 2), UnicodeString(SEMI[0]), 10, 1, TRUE, NULL);
}
static Transliterator* _createEscPerl(const UnicodeString& ID, Transliterator::Token /*context*/) {
// Perl: "\\x{263A}" hex, min=1, max=6
- return new EscapeTransliterator(ID, PERLPRE, RBRACE, 16, 1, TRUE, NULL);
+ return new EscapeTransliterator(ID, UnicodeString(TRUE, PERLPRE, 3), UnicodeString(RBRACE[0]), 16, 1, TRUE, NULL);
}
/**
/*
**********************************************************************
-* Copyright (c) 2002-2008, International Business Machines Corporation
+* Copyright (c) 2002-2011, International Business Machines Corporation
* and others. All Rights Reserved.
**********************************************************************
* Date Name Description
rule.truncate(0);
rule.append(AMPERSAND);
rule.append(translit->getID());
- rule.append(OPEN);
+ rule.append(OPEN, 2);
rule.append(replacer->toReplacer()->toReplacerPattern(str, escapeUnprintable));
- rule.append(CLOSE);
+ rule.append(CLOSE, 2);
return rule;
}
static UnicodeString& itos(int32_t i, UnicodeString& appendTo) {
UChar temp[16];
uprv_itou(temp,16,i,10,0); // 10 == radix
- appendTo.append(temp);
+ appendTo.append(temp, -1);
return appendTo;
}
status = U_PARSE_ERROR;
}
- fIsPublic = name.indexOf(gPercentPercent) != 0;
+ fIsPublic = name.indexOf(gPercentPercent, 2, 0) != 0;
// all of the other members of NFRuleSet are initialized
// by parseRules()
// followed by the regular rules...
for (uint32_t i = 0; i < rules.size(); i++) {
- result.append(gFourSpaces);
+ result.append(gFourSpaces, 4);
rules[i]->_appendRuleText(result);
result.append(gLineFeed);
}
// followed by the special rules (if they exist)
if (negativeNumberRule) {
- result.append(gFourSpaces);
+ result.append(gFourSpaces, 4);
negativeNumberRule->_appendRuleText(result);
result.append(gLineFeed);
}
{
for (uint32_t i = 0; i < 3; ++i) {
if (fractionRules[i]) {
- result.append(gFourSpaces);
+ result.append(gFourSpaces, 4);
fractionRules[i]->_appendRuleText(result);
result.append(gLineFeed);
}
static const UChar gEqualPercent[] = {0x3D, 0x25, 0}; /* "=%" */
static const UChar gEqualHash[] = {0x3D, 0x23, 0}; /* "=#" */
static const UChar gEqualZero[] = {0x3D, 0x30, 0}; /* "=0" */
-static const UChar gEmptyString[] = {0}; /* "" */
static const UChar gGreaterGreaterGreater[] = {0x3E, 0x3E, 0x3E, 0}; /* ">>>" */
static const UChar * const tokenStrings[] = {
// check first to see if the rule descriptor matches the token
// for one of the special rules. If it does, set the base
// value to the correct identfier value
- if (descriptor == gMinusX) {
+ if (0 == descriptor.compare(gMinusX, 2)) {
setType(kNegativeNumberRule);
}
- else if (descriptor == gXDotX) {
+ else if (0 == descriptor.compare(gXDotX, 3)) {
setType(kImproperFractionRule);
}
- else if (descriptor == gZeroDotX) {
+ else if (0 == descriptor.compare(gZeroDotX, 3)) {
setType(kProperFractionRule);
}
- else if (descriptor == gXDotZero) {
+ else if (0 == descriptor.compare(gXDotZero, 3)) {
setType(kMasterRule);
}
// at the end of the rule text
if (subStart == -1) {
return NFSubstitution::makeSubstitution(ruleText.length(), this, predecessor,
- ruleSet, rbnf, gEmptyString, status);
+ ruleSet, rbnf, UnicodeString(), status);
}
// special-case the ">>>" token, since searching for the > at the
// end will actually find the > in the middle
- if (ruleText.indexOf(gGreaterGreaterGreater) == subStart) {
+ if (ruleText.indexOf(gGreaterGreaterGreater, 3, 0) == subStart) {
subEnd = subStart + 2;
// otherwise the substitution token ends with the same character
// at the end of the rule
if (subEnd == -1) {
return NFSubstitution::makeSubstitution(ruleText.length(), this, predecessor,
- ruleSet, rbnf, gEmptyString, status);
+ ruleSet, rbnf, UnicodeString(), status);
}
// if we get here, we have a real substitution token (or at least
NFRule::_appendRuleText(UnicodeString& result) const
{
switch (getType()) {
- case kNegativeNumberRule: result.append(gMinusX); break;
- case kImproperFractionRule: result.append(gXDotX); break;
- case kProperFractionRule: result.append(gZeroDotX); break;
- case kMasterRule: result.append(gXDotZero); break;
+ case kNegativeNumberRule: result.append(gMinusX, 2); break;
+ case kImproperFractionRule: result.append(gXDotX, 3); break;
+ case kProperFractionRule: result.append(gZeroDotX, 3); break;
+ case kMasterRule: result.append(gXDotZero, 3); break;
default:
// for a normal rule, write out its base value, and if the radix is
// something other than 10, write out the radix (with the preceding
// if the rule text begins with a space, write an apostrophe
// (whitespace after the rule descriptor is ignored; the
// apostrophe is used to make the whitespace significant)
- if (ruleText.startsWith(gSpace) && sub1->getPos() != 0) {
+ if (ruleText.charAt(0) == gSpace && sub1->getPos() != 0) {
result.append(gTick);
}
/*
******************************************************************************
-* Copyright (C) 1997-2010, International Business Machines
+* Copyright (C) 1997-2011, International Business Machines
* Corporation and others. All Rights Reserved.
******************************************************************************
* file name: nfsubs.cpp
UErrorCode& status)
: NFSubstitution(_pos, _ruleSet, formatter, description, status)
{
- if (description == gEqualsEquals) {
+ if (0 == description.compare(gEqualsEquals, 2)) {
// throw new IllegalArgumentException("== is not a legal token");
status = U_PARSE_ERROR;
}
status = U_PARSE_ERROR;
}
- if (description == gGreaterGreaterGreaterThan) {
+ if (0 == description.compare(gGreaterGreaterGreaterThan, 3)) {
// the >>> token doesn't alter how this substituion calculates the
// values it uses for formatting and parsing, but it changes
// what's done with that value after it's obtained: >>> short-
{
// akk, ruleSet can change in superclass constructor
- if (description == gGreaterGreaterThan ||
- description == gGreaterGreaterGreaterThan ||
+ if (0 == description.compare(gGreaterGreaterThan, 2) ||
+ 0 == description.compare(gGreaterGreaterGreaterThan, 3) ||
_ruleSet == getRuleSet()) {
byDigits = TRUE;
- if (description == gGreaterGreaterGreaterThan) {
+ if (0 == description.compare(gGreaterGreaterGreaterThan, 3)) {
useSpaces = FALSE;
}
} else {
// replace single currency sign in the pattern with double currency sign
// if the style is UNUM_CURRENCY_ISO
if (style == UNUM_CURRENCY_ISO) {
- pattern.findAndReplace(gSingleCurrencySign, gDoubleCurrencySign);
+ pattern.findAndReplace(UnicodeString(TRUE, gSingleCurrencySign, 1),
+ UnicodeString(TRUE, gDoubleCurrencySign, 2));
}
// "new DecimalFormat()" does not adopt the symbols if its memory allocation fails.
/*
*******************************************************************************
-* Copyright (C) 2010, International Business Machines Corporation and
+* Copyright (C) 2010-2011, International Business Machines Corporation and
* others. All Rights Reserved.
*******************************************************************************
*
NumberingSystem* U_EXPORT2
NumberingSystem::createInstanceByName(const char *name, UErrorCode& status) {
-
- UResourceBundle *numberingSystemsInfo = NULL;
- UResourceBundle *nsTop, *nsCurrent;
- const UChar* description = NULL;
- int32_t radix = 10;
- int32_t algorithmic = 0;
- int32_t len;
-
- numberingSystemsInfo = ures_openDirect(NULL,gNumberingSystems, &status);
- nsCurrent = ures_getByKey(numberingSystemsInfo,gNumberingSystems,NULL,&status);
- nsTop = ures_getByKey(nsCurrent,name,NULL,&status);
- description = ures_getStringByKey(nsTop,gDesc,&len,&status);
-
- ures_getByKey(nsTop,gRadix,nsCurrent,&status);
- radix = ures_getInt(nsCurrent,&status);
-
- ures_getByKey(nsTop,gAlgorithmic,nsCurrent,&status);
- algorithmic = ures_getInt(nsCurrent,&status);
-
- UBool isAlgorithmic = ( algorithmic == 1 );
- UnicodeString nsd;
- nsd.setTo(description);
-
- ures_close(nsCurrent);
- ures_close(nsTop);
- ures_close(numberingSystemsInfo);
-
- if (U_FAILURE(status)) {
- status = U_UNSUPPORTED_ERROR;
- return NULL;
- }
-
- NumberingSystem* ns = NumberingSystem::createInstance(radix,isAlgorithmic,nsd,status);
- ns->setName(name);
- return ns;
+ UResourceBundle *numberingSystemsInfo = NULL;
+ UResourceBundle *nsTop, *nsCurrent;
+ int32_t radix = 10;
+ int32_t algorithmic = 0;
+
+ numberingSystemsInfo = ures_openDirect(NULL,gNumberingSystems, &status);
+ nsCurrent = ures_getByKey(numberingSystemsInfo,gNumberingSystems,NULL,&status);
+ nsTop = ures_getByKey(nsCurrent,name,NULL,&status);
+ UnicodeString nsd = ures_getUnicodeStringByKey(nsTop,gDesc,&status);
+
+ ures_getByKey(nsTop,gRadix,nsCurrent,&status);
+ radix = ures_getInt(nsCurrent,&status);
+
+ ures_getByKey(nsTop,gAlgorithmic,nsCurrent,&status);
+ algorithmic = ures_getInt(nsCurrent,&status);
+
+ UBool isAlgorithmic = ( algorithmic == 1 );
+
+ ures_close(nsCurrent);
+ ures_close(nsTop);
+ ures_close(numberingSystemsInfo);
+
+ if (U_FAILURE(status)) {
+ status = U_UNSUPPORTED_ERROR;
+ return NULL;
+ }
+
+ NumberingSystem* ns = NumberingSystem::createInstance(radix,isAlgorithmic,nsd,status);
+ ns->setName(name);
+ return ns;
}
/**
PluralRules* U_EXPORT2
PluralRules::createDefaultRules(UErrorCode& status) {
- return createRules(PLURAL_DEFAULT_RULE, status);
+ return createRules(UnicodeString(TRUE, PLURAL_DEFAULT_RULE, -1), status);
}
PluralRules* U_EXPORT2
UnicodeString
PluralRules::select(int32_t number) const {
if (mRules == NULL) {
- return PLURAL_DEFAULT_RULE;
+ return UnicodeString(TRUE, PLURAL_DEFAULT_RULE, -1);
}
else {
return mRules->select(number);
UnicodeString
PluralRules::select(double number) const {
if (mRules == NULL) {
- return PLURAL_DEFAULT_RULE;
+ return UnicodeString(TRUE, PLURAL_DEFAULT_RULE, -1);
}
else {
return mRules->select(number);
UBool
PluralRules::isKeyword(const UnicodeString& keyword) const {
- if ( keyword == PLURAL_KEYWORD_OTHER ) {
+ if (0 == keyword.compare(PLURAL_KEYWORD_OTHER, 5)) {
return true;
}
else {
UnicodeString
PluralRules::getKeywordOther() const {
- return PLURAL_KEYWORD_OTHER;
+ return UnicodeString(TRUE, PLURAL_KEYWORD_OTHER, 5);
}
UBool
}
rc = rc->next;
}
- if (keyword == PLURAL_KEYWORD_OTHER) {
+ if (0 == keyword.compare(PLURAL_KEYWORD_OTHER, 5)) {
return n;
}
}
RuleChain* rc = mRules;
while (rc != NULL) {
if (rc->ruleHeader != NULL) {
- if (otherIndex == -1 && rc->keyword == PLURAL_KEYWORD_OTHER) {
+ if (otherIndex == -1 && 0 == rc->keyword.compare(PLURAL_KEYWORD_OTHER, 5)) {
otherIndex = maxIndex;
}
++maxIndex;
return next->select(number);
}
else {
- return PLURAL_KEYWORD_OTHER;
+ return UnicodeString(TRUE, PLURAL_KEYWORD_OTHER, 5);
}
}
}
}
if ( (andRule=andRule->next) != NULL) {
- result += PK_AND;
+ result.append(PK_AND, 3);
}
}
if ( (orRule = orRule->next) != NULL ) {
- result += PK_OR;
+ result.append(PK_OR, 2);
}
}
}
}
if ( keyType==tNumber) {
}
- else if (token==PK_VAR_N) {
+ else if (0 == token.compare(PK_VAR_N, 1)) {
keyType = tVariableN;
}
- else if (token==PK_IS) {
+ else if (0 == token.compare(PK_IS, 2)) {
keyType = tIs;
}
- else if (token==PK_AND) {
+ else if (0 == token.compare(PK_AND, 3)) {
keyType = tAnd;
}
- else if (token==PK_IN) {
+ else if (0 == token.compare(PK_IN, 2)) {
keyType = tIn;
}
- else if (token==PK_WITHIN) {
+ else if (0 == token.compare(PK_WITHIN, 6)) {
keyType = tWithin;
}
- else if (token==PK_NOT) {
+ else if (0 == token.compare(PK_NOT, 3)) {
keyType = tNot;
}
- else if (token==PK_MOD) {
+ else if (0 == token.compare(PK_MOD, 3)) {
keyType = tMod;
}
- else if (token==PK_OR) {
+ else if (0 == token.compare(PK_OR, 2)) {
keyType = tOr;
}
else if ( isValidKeyword(token) ) {
if (U_FAILURE(status)) {
return;
}
- if (node->keyword == PLURAL_KEYWORD_OTHER) {
+ if (0 == node->keyword.compare(PLURAL_KEYWORD_OTHER, 5)) {
addKeywordOther= FALSE;
}
node=node->next;
// TODO: read localization info from resource
LocalizationInfo* locinfo = NULL;
- int32_t len = 0;
UResourceBundle* nfrb = ures_open(U_ICUDATA_RBNF, locale.getName(), &status);
if (U_SUCCESS(status)) {
setLocaleIDs(ures_getLocaleByType(nfrb, ULOC_VALID_LOCALE, &status),
ures_close(nfrb);
return;
}
-
+
UnicodeString desc;
while (ures_hasNext(ruleSets)) {
- const UChar* currentString = ures_getNextString(ruleSets,&len,NULL,&status);
- desc.append(currentString);
+ desc.append(ures_getNextUnicodeString(ruleSets,NULL,&status));
}
UParseError perror;
-
init (desc, locinfo, perror, status);
{
// return format((int64_t)number, ruleSetName, toAppendTo, pos, status);
if (U_SUCCESS(status)) {
- if (ruleSetName.indexOf(gPercentPercent) == 0) {
+ if (ruleSetName.indexOf(gPercentPercent, 2, 0) == 0) {
// throw new IllegalArgumentException("Can't use internal rule set");
status = U_ILLEGAL_ARGUMENT_ERROR;
} else {
UErrorCode& status) const
{
if (U_SUCCESS(status)) {
- if (ruleSetName.indexOf(gPercentPercent) == 0) {
+ if (ruleSetName.indexOf(gPercentPercent, 2, 0) == 0) {
// throw new IllegalArgumentException("Can't use internal rule set");
status = U_ILLEGAL_ARGUMENT_ERROR;
} else {
UErrorCode& status) const
{
if (U_SUCCESS(status)) {
- if (ruleSetName.indexOf(gPercentPercent) == 0) {
+ if (ruleSetName.indexOf(gPercentPercent, 2, 0) == 0) {
// throw new IllegalArgumentException("Can't use internal rule set");
status = U_ILLEGAL_ARGUMENT_ERROR;
} else {
// is, pull them out into our temporary holding place for them,
// and delete them from the description before the real desciption-
// parsing code sees them
- int32_t lp = description.indexOf(gLenientParse);
+ int32_t lp = description.indexOf(gLenientParse, -1, 0);
if (lp != -1) {
// we've got to make sure we're not in the middle of a rule
// (where "%%lenient-parse" would actually get treated as
// locate the beginning and end of the actual collation
// rules (there may be whitespace between the name and
// the first token in the description)
- int lpEnd = description.indexOf(gSemiPercent, lp);
+ int lpEnd = description.indexOf(gSemiPercent, 2, lp);
if (lpEnd == -1) {
lpEnd = description.length() - 1;
// rule sets (";%" marks the end of one rule set and the beginning
// of the next)
int numRuleSets = 0;
- for (int32_t p = description.indexOf(gSemiPercent); p != -1; p = description.indexOf(gSemiPercent, p)) {
+ for (int32_t p = description.indexOf(gSemiPercent, 2, 0); p != -1; p = description.indexOf(gSemiPercent, 2, p)) {
++numRuleSets;
++p;
}
{
int curRuleSet = 0;
int32_t start = 0;
- for (int32_t p = description.indexOf(gSemiPercent); p != -1; p = description.indexOf(gSemiPercent, start)) {
+ for (int32_t p = description.indexOf(gSemiPercent, 2, 0); p != -1; p = description.indexOf(gSemiPercent, 2, start)) {
ruleSetDescriptions[curRuleSet].setTo(description, start, p + 1 - start);
ruleSets[curRuleSet] = new NFRuleSet(ruleSetDescriptions, curRuleSet, status);
if (ruleSets[curRuleSet] == 0) {
int32_t RuleHalf::parse(const UnicodeString& rule, int32_t pos, int32_t limit, UErrorCode& status) {
int32_t start = pos;
text.truncate(0);
- pos = parseSection(rule, pos, limit, text, ILLEGAL_TOP, FALSE, status);
+ pos = parseSection(rule, pos, limit, text, UnicodeString(TRUE, ILLEGAL_TOP, -1), FALSE, status);
if (cursorOffset > 0 && cursor != cursorOffsetPos) {
return syntaxError(U_MISPLACED_CURSOR_OFFSET, rule, start, status);
int32_t segmentNumber = nextSegmentNumber++; // 1-based
// Parse the segment
- pos = parseSection(rule, pos, limit, buf, ILLEGAL_SEG, TRUE, status);
+ pos = parseSection(rule, pos, limit, buf, UnicodeString(TRUE, ILLEGAL_SEG, -1), TRUE, status);
// After parsing a segment, the relevant characters are
// in buf, starting at offset bufSegStart. Extract them
int32_t bufSegStart = buf.length();
// Parse the segment
- pos = parseSection(rule, iref, limit, buf, ILLEGAL_FUNC, TRUE, status);
+ pos = parseSection(rule, iref, limit, buf, UnicodeString(TRUE, ILLEGAL_FUNC, -1), TRUE, status);
// After parsing a segment, the relevant characters are
// in buf, starting at offset bufSegStart.
*/
UBool TransliteratorParser::resemblesPragma(const UnicodeString& rule, int32_t pos, int32_t limit) {
// Must start with /use\s/i
- return ICU_Utility::parsePattern(rule, pos, limit, PRAGMA_USE, NULL) >= 0;
+ return ICU_Utility::parsePattern(rule, pos, limit, UnicodeString(TRUE, PRAGMA_USE, 4), NULL) >= 0;
}
/**
// use maximum backup 16;
// use nfd rules;
// use nfc rules;
- int p = ICU_Utility::parsePattern(rule, pos, limit, PRAGMA_VARIABLE_RANGE, array);
+ int p = ICU_Utility::parsePattern(rule, pos, limit, UnicodeString(TRUE, PRAGMA_VARIABLE_RANGE, -1), array);
if (p >= 0) {
setVariableRange(array[0], array[1], status);
return p;
}
- p = ICU_Utility::parsePattern(rule, pos, limit, PRAGMA_MAXIMUM_BACKUP, array);
+ p = ICU_Utility::parsePattern(rule, pos, limit, UnicodeString(TRUE, PRAGMA_MAXIMUM_BACKUP, -1), array);
if (p >= 0) {
pragmaMaximumBackup(array[0]);
return p;
}
- p = ICU_Utility::parsePattern(rule, pos, limit, PRAGMA_NFD_RULES, NULL);
+ p = ICU_Utility::parsePattern(rule, pos, limit, UnicodeString(TRUE, PRAGMA_NFD_RULES, -1), NULL);
if (p >= 0) {
pragmaNormalizeRules(UNORM_NFD);
return p;
}
- p = ICU_Utility::parsePattern(rule, pos, limit, PRAGMA_NFC_RULES, NULL);
+ p = ICU_Utility::parsePattern(rule, pos, limit, UnicodeString(TRUE, PRAGMA_NFC_RULES, -1), NULL);
if (p >= 0) {
pragmaNormalizeRules(UNORM_NFC);
return p;
*/
UChar TransliteratorParser::getDotStandIn(UErrorCode& status) {
if (dotStandIn == (UChar) -1) {
- UnicodeSet* tempus = new UnicodeSet(DOT_SET, status);
+ UnicodeSet* tempus = new UnicodeSet(UnicodeString(TRUE, DOT_SET, -1), status);
// Null pointer check.
if (tempus == NULL) {
status = U_MEMORY_ALLOCATION_ERROR;
/*
**********************************************************************
- * Copyright (C) 1999-2008, International Business Machines
+ * Copyright (C) 1999-2011, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
* Date Name Description
rule.append((UChar)36/*$*/);
}
- ICU_Utility::appendToRule(rule, FORWARD_OP, TRUE, escapeUnprintable, quoteBuf);
+ ICU_Utility::appendToRule(rule, UnicodeString(TRUE, FORWARD_OP, 3), TRUE, escapeUnprintable, quoteBuf);
// Emit the output pattern
/*
**********************************************************************
-* Copyright (c) 2001-2008, International Business Machines
+* Copyright (c) 2001-2011, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
* Date Name Description
*/
void RemoveTransliterator::registerIDs() {
- Transliterator::_registerFactory(::CURR_ID, RemoveTransliterator_create, integerToken(0));
+ Transliterator::_registerFactory(UnicodeString(TRUE, ::CURR_ID, -1),
+ RemoveTransliterator_create, integerToken(0));
Transliterator::_registerSpecialInverse(UNICODE_STRING_SIMPLE("Remove"),
UNICODE_STRING_SIMPLE("Null"), FALSE);
}
-RemoveTransliterator::RemoveTransliterator() : Transliterator(::CURR_ID, 0) {}
+RemoveTransliterator::RemoveTransliterator() : Transliterator(UnicodeString(TRUE, ::CURR_ID, -1), 0) {}
RemoveTransliterator::~RemoveTransliterator() {}
/*
*******************************************************************************
- * Copyright (C) 1997-2010, International Business Machines Corporation and
+ * Copyright (C) 1997-2011, International Business Machines Corporation and
* others. All Rights Reserved.
*******************************************************************************
*
return;
}
// For now, use ID + "(DST)" as the name
- dstRule = new AnnualTimeZoneRule(tzid+DST_STR, getRawOffset(), getDSTSavings(),
+ dstRule = new AnnualTimeZoneRule(tzid+UnicodeString(DST_STR), getRawOffset(), getDSTSavings(),
dtRule, startYear, AnnualTimeZoneRule::MAX_YEAR);
// Check for Null pointer
return;
}
// For now, use ID + "(STD)" as the name
- stdRule = new AnnualTimeZoneRule(tzid+STD_STR, getRawOffset(), 0,
+ stdRule = new AnnualTimeZoneRule(tzid+UnicodeString(STD_STR), getRawOffset(), 0,
dtRule, startYear, AnnualTimeZoneRule::MAX_YEAR);
//Check for Null pointer
// Create a TimeZoneRule for initial time
if (firstStdStart < firstDstStart) {
- initialRule = new InitialTimeZoneRule(tzid+DST_STR, getRawOffset(), dstRule->getDSTSavings());
+ initialRule = new InitialTimeZoneRule(tzid+UnicodeString(DST_STR), getRawOffset(), dstRule->getDSTSavings());
firstTransition = new TimeZoneTransition(firstStdStart, *initialRule, *stdRule);
} else {
- initialRule = new InitialTimeZoneRule(tzid+STD_STR, getRawOffset(), 0);
+ initialRule = new InitialTimeZoneRule(tzid+UnicodeString(STD_STR), getRawOffset(), 0);
firstTransition = new TimeZoneTransition(firstDstStart, *initialRule, *dstRule);
}
// Check for null pointers.
void
SimpleDateFormat::formatGMTDefault(NumberFormat *currentNumberFormat,UnicodeString &appendTo, int32_t offset) const {
if (offset < 0) {
- appendTo += gGmtMinus;
+ appendTo.append(gGmtMinus, 4);
offset = -offset; // suppress the '-' sign for text display.
}else{
- appendTo += gGmtPlus;
+ appendTo.append(gGmtPlus, 4);
}
offset /= U_MILLIS_PER_SECOND; // now in seconds
DecimalFormat* df = NULL;
if (!allowNegative && (df = dynamic_cast<DecimalFormat*>(fmt)) != NULL) {
df->getNegativePrefix(oldPrefix);
- df->setNegativePrefix(SUPPRESS_NEGATIVE_PREFIX);
+ df->setNegativePrefix(UnicodeString(TRUE, SUPPRESS_NEGATIVE_PREFIX, -1));
}
int32_t oldPos = pos.getIndex();
fmt->parse(text, number, pos);
SimpleDateFormat::toLocalizedPattern(UnicodeString& result,
UErrorCode& status) const
{
- translatePattern(fPattern, result, DateFormatSymbols::getPatternUChars(), fSymbols->fLocalPatternChars, status);
+ translatePattern(fPattern, result,
+ UnicodeString(DateFormatSymbols::getPatternUChars()),
+ fSymbols->fLocalPatternChars, status);
return result;
}
SimpleDateFormat::applyLocalizedPattern(const UnicodeString& pattern,
UErrorCode &status)
{
- translatePattern(pattern, fPattern, fSymbols->fLocalPatternChars, DateFormatSymbols::getPatternUChars(), status);
+ translatePattern(pattern, fPattern,
+ fSymbols->fLocalPatternChars,
+ UnicodeString(DateFormatSymbols::getPatternUChars()), status);
}
//----------------------------------------------------------------------
/*
**********************************************************************
-* Copyright (c) 2001-2004, International Business Machines Corporation
+* Copyright (c) 2001-2011, International Business Machines Corporation
* and others. All Rights Reserved.
**********************************************************************
* Date Name Description
U_NAMESPACE_BEGIN
-static const UChar EMPTY[] = { 0 }; // empty string: ""
-
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(StringMatcher)
StringMatcher::StringMatcher(const UnicodeString& theString,
}
}
- text.handleReplaceBetween(start, limit, EMPTY); // delete original text
+ text.handleReplaceBetween(start, limit, UnicodeString()); // delete original text
return outLen;
}
/*
**********************************************************************
-* Copyright (c) 2002-2004, International Business Machines Corporation
+* Copyright (c) 2002-2011, International Business Machines Corporation
* and others. All Rights Reserved.
**********************************************************************
* Date Name Description
U_NAMESPACE_BEGIN
-static const UChar EMPTY[] = { 0 }; // empty string: ""
-
UnicodeReplacer::~UnicodeReplacer() {}
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(StringReplacer)
// Copy new text to start, and delete it
text.copy(destStart, destLimit, start);
- text.handleReplaceBetween(tempStart + outLen, destLimit + outLen, EMPTY);
+ text.handleReplaceBetween(tempStart + outLen, destLimit + outLen, UnicodeString());
// Delete the old text (the key)
- text.handleReplaceBetween(start + outLen, limit + outLen, EMPTY);
+ text.handleReplaceBetween(start + outLen, limit + outLen, UnicodeString());
}
if (hasCursor) {
}
if (result == 0) {
U_DEBUG_TZ_MSG(("failed to load time zone with id - falling to Etc/Unknown(GMT)"));
- result = new SimpleTimeZone(0, UNKNOWN_ZONE_ID);
+ result = new SimpleTimeZone(0, UnicodeString(TRUE, UNKNOWN_ZONE_ID, UNKNOWN_ZONE_ID_LENGTH));
}
return result;
}
} else {
int32_t numEntries = 0;
for (int32_t i = 0; i < size; i++) {
- const UChar *id = ures_getStringByIndex(res, i, NULL, &ec);
+ UnicodeString id = ures_getUnicodeStringByIndex(res, i, &ec);
if (U_FAILURE(ec)) {
break;
}
- if (u_strcmp(id, UNKNOWN_ZONE_ID) == 0) {
+ if (0 == id.compare(UNKNOWN_ZONE_ID, UNKNOWN_ZONE_ID_LENGTH)) {
// exclude Etc/Unknown
continue;
}
if (U_FAILURE(ec)) {
break;
}
- if (canonicalID.compare(id, -1) != 0) {
+ if (canonicalID != id) {
// exclude aliases
continue;
}
res = ures_getByKey(res, kNAMES, res, &ec); // dereference Zones section
for (int32_t i = 0; i < baseLen; i++) {
int32_t zidx = baseMap[i];
- const UChar *id = ures_getStringByIndex(res, zidx, NULL, &ec);
+ UnicodeString id = ures_getUnicodeStringByIndex(res, zidx, &ec);
if (U_FAILURE(ec)) {
break;
}
#endif
// select the proper format string
- UnicodeString pat;
+ const UChar* patUChars;
switch(style){
case LONG:
- pat = ZZZZ_STR;
+ patUChars = ZZZZ_STR;
break;
case SHORT_GENERIC:
- pat = V_STR;
+ patUChars = V_STR;
break;
case LONG_GENERIC:
- pat = VVVV_STR;
+ patUChars = VVVV_STR;
break;
case SHORT_GMT:
- pat = Z_UC_STR;
+ patUChars = Z_UC_STR;
break;
case LONG_GMT:
- pat = ZZZZ_UC_STR;
+ patUChars = ZZZZ_UC_STR;
break;
case SHORT_COMMONLY_USED:
- //pat = V_UC_STR;
- pat = Z_STR;
+ //patUChars = V_UC_STR;
+ patUChars = Z_STR;
break;
case GENERIC_LOCATION:
- pat = VVVV_UC_STR;
+ patUChars = VVVV_UC_STR;
break;
default: // SHORT
- //pat = Z_STR;
- pat = V_UC_STR;
+ //patUChars = Z_STR;
+ patUChars = V_UC_STR;
break;
}
+ UnicodeString pat(TRUE, patUChars, -1);
SimpleDateFormat format(pat, locale, status);
U_DEBUG_TZ_MSG(("getDisplayName(%s)\n", buf));
idUppercase.toUpper();
if (id.length() > GMT_ID_LENGTH &&
- idUppercase.startsWith(GMT_ID))
+ idUppercase.startsWith(GMT_ID, GMT_ID_LENGTH))
{
ParsePosition pos(GMT_ID_LENGTH);
sign = 1;
TimeZone::formatCustomID(int32_t hour, int32_t min, int32_t sec,
UBool negative, UnicodeString& id) {
// Create time zone ID - GMT[+|-]hhmm[ss]
- id.setTo(GMT_ID);
+ id.setTo(GMT_ID, GMT_ID_LENGTH);
if (hour | min | sec) {
if (negative) {
id += (UChar)MINUS;
*/
if (withNumberFormat == false && longestParseDistance != 0) {
// set the number using plurrual count
- if ( *countOfLongestMatch == PLURAL_COUNT_ZERO ) {
+ if (0 == countOfLongestMatch->compare(PLURAL_COUNT_ZERO, 4)) {
resultNumber = 0;
- } else if ( *countOfLongestMatch == PLURAL_COUNT_ONE ) {
+ } else if (0 == countOfLongestMatch->compare(PLURAL_COUNT_ONE, 3)) {
resultNumber = 1;
- } else if ( *countOfLongestMatch == PLURAL_COUNT_TWO ) {
+ } else if (0 == countOfLongestMatch->compare(PLURAL_COUNT_TWO, 3)) {
resultNumber = 2;
} else {
// should not happen.
}
}
int32_t count = ures_getSize(countsToPatternRB);
- const UChar* pattern;
const char* pluralCount;
- int32_t ptLength;
for ( int32_t pluralIndex = 0; pluralIndex < count; ++pluralIndex) {
// resource of count to pattern
- pattern = ures_getNextString(countsToPatternRB, &ptLength,
- &pluralCount, &status);
+ UnicodeString pattern =
+ ures_getNextUnicodeString(countsToPatternRB, &pluralCount, &status);
if (U_FAILURE(status)) {
continue;
}
pattern = ures_getStringByKeyWithFallback(countsToPatternRB, searchPluralCount, &ptLength, &status);
if (U_SUCCESS(status)) {
//found
- MessageFormat* messageFormat = new MessageFormat(pattern, fLocale, err);
+ MessageFormat* messageFormat = new MessageFormat(UnicodeString(TRUE, pattern, ptLength), fLocale, err);
if (U_SUCCESS(err)) {
if (fNumberFormat != NULL) {
messageFormat->setFormat(0, *fNumberFormat);
if ( uprv_strcmp(searchPluralCount, gPluralCountOther) == 0 ) {
// set default fall back the same as the resource in root
MessageFormat* messageFormat = NULL;
+ const UChar *pattern = NULL;
if ( srcTimeUnitField == TimeUnit::UTIMEUNIT_SECOND ) {
- messageFormat = new MessageFormat(DEFAULT_PATTERN_FOR_SECOND, fLocale, err);
+ pattern = DEFAULT_PATTERN_FOR_SECOND;
} else if ( srcTimeUnitField == TimeUnit::UTIMEUNIT_MINUTE ) {
- messageFormat = new MessageFormat(DEFAULT_PATTERN_FOR_MINUTE, fLocale, err);
+ pattern = DEFAULT_PATTERN_FOR_MINUTE;
} else if ( srcTimeUnitField == TimeUnit::UTIMEUNIT_HOUR ) {
- messageFormat = new MessageFormat(DEFAULT_PATTERN_FOR_HOUR, fLocale, err);
+ pattern = DEFAULT_PATTERN_FOR_HOUR;
} else if ( srcTimeUnitField == TimeUnit::UTIMEUNIT_WEEK ) {
- messageFormat = new MessageFormat(DEFAULT_PATTERN_FOR_WEEK, fLocale, err);
+ pattern = DEFAULT_PATTERN_FOR_WEEK;
} else if ( srcTimeUnitField == TimeUnit::UTIMEUNIT_DAY ) {
- messageFormat = new MessageFormat(DEFAULT_PATTERN_FOR_DAY, fLocale, err);
+ pattern = DEFAULT_PATTERN_FOR_DAY;
} else if ( srcTimeUnitField == TimeUnit::UTIMEUNIT_MONTH ) {
- messageFormat = new MessageFormat(DEFAULT_PATTERN_FOR_MONTH, fLocale, err);
+ pattern = DEFAULT_PATTERN_FOR_MONTH;
} else if ( srcTimeUnitField == TimeUnit::UTIMEUNIT_YEAR ) {
- messageFormat = new MessageFormat(DEFAULT_PATTERN_FOR_YEAR, fLocale, err);
+ pattern = DEFAULT_PATTERN_FOR_YEAR;
+ }
+ if (pattern != NULL) {
+ messageFormat = new MessageFormat(UnicodeString(TRUE, pattern, -1), fLocale, err);
}
if (U_SUCCESS(err)) {
if (fNumberFormat != NULL && messageFormat != NULL) {
// MUTEX. Avoids function call when registry is initialized.
#define HAVE_REGISTRY(status) (registry!=0 || initializeRegistry(status))
-// Empty string
-static const UChar EMPTY[] = {0}; //""
-
U_NAMESPACE_BEGIN
UOBJECT_DEFINE_ABSTRACT_RTTI_IMPLEMENTATION(Transliterator)
int32_t rs = rollbackStart + delta - (index.limit - passStart);
// Delete the partially transliterated text
- text.handleReplaceBetween(passStart, index.limit, EMPTY);
+ text.handleReplaceBetween(passStart, index.limit, UnicodeString());
// Copy the rollback text back
text.copy(rs, rs + uncommittedLength, passStart);
globalLimit += totalDelta;
// Delete the rollback copy
- text.handleReplaceBetween(rollbackOrigin, rollbackOrigin + runLength, EMPTY);
+ text.handleReplaceBetween(rollbackOrigin, rollbackOrigin + runLength, UnicodeString());
// Move start past committed text
index.start = passStart;
}
if (!parser.dataVector.isEmpty()) {
TransliterationRuleData* data = (TransliterationRuleData*)parser.dataVector.orphanElementAt(0);
- RuleBasedTransliterator* temprbt = new RuleBasedTransliterator(UnicodeString(CompoundTransliterator::PASS_STRING) + (passNumber++),
+ // TODO: Should passNumber be turned into a decimal-string representation (1 -> "1")?
+ RuleBasedTransliterator* temprbt = new RuleBasedTransliterator(UnicodeString(CompoundTransliterator::PASS_STRING) + UnicodeString(passNumber++),
data, TRUE);
// Check if NULL before adding it to transliterators to avoid future usage of NULL pointer.
if (temprbt == NULL) {
//static const UChar VARIANT_SEP = 0x002F; // '/'
// String constants
-static const UChar NO_VARIANT[] = { 0 }; // empty string
static const UChar ANY[] = { 65, 110, 121, 0 }; // Any
+// empty string
+#define NO_VARIANT UnicodeString()
+
/**
* Resource bundle key for the RuleBasedTransliterator rule.
*/
UnicodeString ID;
UnicodeString s(source);
if (s.length() == 0) {
- s = ANY;
+ s.setTo(TRUE, ANY, 3);
}
TransliteratorIDParser::STVtoID(source, target, variant, ID);
registerEntry(ID, s, target, variant, adopted, visible);
variants->addElement(tempus, status);
}
} else {
- tempus = new UnicodeString(NO_VARIANT) ;
+ tempus = new UnicodeString(); // = NO_VARIANT
if (tempus != NULL) {
variants->insertElementAt(tempus, 0, status);
}
// but must be consistent and documented.
if (pass == 0) {
utag.append(direction == UTRANS_FORWARD ?
- TRANSLITERATE_TO : TRANSLITERATE_FROM);
+ TRANSLITERATE_TO : TRANSLITERATE_FROM, -1);
} else {
- utag.append(TRANSLITERATE);
+ utag.append(TRANSLITERATE, -1);
}
UnicodeString s(specToFind.get());
utag.append(s.toUpper(""));
}
int32_t passNumber = 1;
for (int32_t i = 0; U_SUCCESS(status) && i < entry->u.dataVector->size(); i++) {
- Transliterator* t = new RuleBasedTransliterator(UnicodeString(CompoundTransliterator::PASS_STRING) + (passNumber++),
+ // TODO: Should passNumber be turned into a decimal-string representation (1 -> "1")?
+ Transliterator* t = new RuleBasedTransliterator(UnicodeString(CompoundTransliterator::PASS_STRING) + UnicodeString(passNumber++),
(TransliterationRuleData*)(entry->u.dataVector->elementAt(i)), FALSE);
if (t == 0)
status = U_MEMORY_ALLOCATION_ERROR;
Transliterator* TransliteratorIDParser::SingleID::createInstance() {
Transliterator* t;
if (basicID.length() == 0) {
- t = createBasicInstance(ANY_NULL, &canonID);
+ t = createBasicInstance(UnicodeString(TRUE, ANY_NULL, 8), &canonID);
} else {
t = createBasicInstance(basicID, &canonID);
}
// An empty list is equivalent to a NULL transliterator.
if (tlist.size() == 0) {
- t = createBasicInstance(ANY_NULL, NULL);
+ t = createBasicInstance(UnicodeString(TRUE, ANY_NULL, 8), NULL);
if (t == NULL) {
// Should never happen
ec = U_INTERNAL_TRANSLITERATOR_ERROR;
UnicodeString& target,
UnicodeString& variant,
UBool& isSourcePresent) {
- source = ANY;
+ source.setTo(ANY, 3);
target.truncate(0);
variant.truncate(0);
UnicodeString& id) {
id = source;
if (id.length() == 0) {
- id = ANY;
+ id.setTo(ANY, 3);
}
id.append(TARGET_SEP).append(target);
if (variant.length() != 0) {
// Empty source or target defaults to ANY
UBool sawSource = TRUE;
if (source.length() == 0) {
- source = ANY;
+ source.setTo(ANY, 3);
sawSource = FALSE;
}
if (target.length() == 0) {
- target = ANY;
+ target.setTo(ANY, 3);
}
return new Specs(source, target, variant, sawSource, filter);
*/
TransliteratorIDParser::SingleID*
TransliteratorIDParser::specsToSpecialInverse(const Specs& specs, UErrorCode &status) {
- if (0!=specs.source.caseCompare(ANY, U_FOLD_CASE_DEFAULT)) {
+ if (0!=specs.source.caseCompare(ANY, 3, U_FOLD_CASE_DEFAULT)) {
return NULL;
}
init(status);
buf.append(specs.filter);
}
if (specs.sawSource) {
- buf.append(ANY).append(TARGET_SEP);
+ buf.append(ANY, 3).append(TARGET_SEP);
}
buf.append(*inverseTarget);
- UnicodeString basicID(ANY);
+ UnicodeString basicID(TRUE, ANY, 3);
basicID.append(TARGET_SEP).append(*inverseTarget);
if (specs.variant.length() != 0) {
/*
*******************************************************************************
-* Copyright (C) 2011, International Business Machines Corporation and *
-* others. All Rights Reserved. *
+* Copyright (C) 2011, International Business Machines Corporation and
+* others. All Rights Reserved.
*******************************************************************************
*/
PartialLocationKey *p = (PartialLocationKey *)key.pointer;
UnicodeString str(p->tzID);
str.append((UChar)0x26)
- .append(p->mzID)
+ .append(p->mzID, -1)
.append((UChar)0x23)
.append((UChar)(p->isLong ? 0x4C : 0x53));
return str.hashCode();
if (U_SUCCESS(tmpsts)) {
const UChar *regionPattern = ures_getStringByKeyWithFallback(zoneStrings, gRegionFormatTag, NULL, &tmpsts);
if (U_SUCCESS(tmpsts) && u_strlen(regionPattern) > 0) {
- rpat.setTo(regionPattern);
+ rpat.setTo(regionPattern, -1);
}
tmpsts = U_ZERO_ERROR;
const UChar *fallbackRegionPattern = ures_getStringByKeyWithFallback(zoneStrings, gFallbackRegionFormatTag, NULL, &tmpsts);
if (U_SUCCESS(tmpsts) && u_strlen(fallbackRegionPattern) > 0) {
- frpat.setTo(fallbackRegionPattern);
+ frpat.setTo(fallbackRegionPattern, -1);
}
tmpsts = U_ZERO_ERROR;
const UChar *fallbackPattern = ures_getStringByKeyWithFallback(zoneStrings, gFallbackFormatTag, NULL, &tmpsts);
if (U_SUCCESS(tmpsts) && u_strlen(fallbackPattern) > 0) {
- fpat.setTo(fallbackPattern);
+ fpat.setTo(fallbackPattern, -1);
}
}
ures_close(zoneStrings);
const UnicodeString*
MetaZoneIDsEnumeration::snext(UErrorCode& status) {
if (U_SUCCESS(status) && fMetaZoneIDs != NULL && fPos < fLen) {
- unistr.setTo((const UChar*)fMetaZoneIDs->elementAt(fPos++));
+ unistr.setTo((const UChar*)fMetaZoneIDs->elementAt(fPos++), -1);
return &unistr;
}
return NULL;
}
}
if (isChoice) {
- ChoiceFormat fmt(s, ec2);
+ ChoiceFormat fmt(UnicodeString(TRUE, s, len), ec2);
int32_t fmt_count;
fmt.getFormats(fmt_count);
*total_currency_symbol_count += fmt_count;
}
}
if (isChoice) {
- ChoiceFormat fmt(s, ec2);
+ ChoiceFormat fmt(UnicodeString(TRUE, s, len), ec2);
int32_t fmt_count;
const UnicodeString* formats = fmt.getFormats(fmt_count);
for (int i = 0; i < fmt_count; ++i) {
// arbitrary value; pick something != 1; more common.
result.truncate(0);
if (isChoiceFormat) {
- ChoiceFormat f(currname, ec);
+ ChoiceFormat f(UnicodeString(TRUE, currname, len), ec);
if (U_SUCCESS(ec)) {
f.format(2.0, result);
} else {
- result = iso;
+ result.setTo(iso, -1);
}
} else {
- result = currname;
+ result.setTo(currname, -1);
}
}
}
// For some reason, a temporary is needed
stringVal = va_arg(ap, UChar*);
if(stringVal){
- args[i].setString(stringVal);
+ args[i].setString(UnicodeString(stringVal));
}else{
*status=U_ILLEGAL_ARGUMENT_ERROR;
}
}
UnicodeString srcString(source,sourceLength);
- Formattable *args = ((const MessageFormat*)fmt)->parse(source,*count,*status);
+ Formattable *args = ((const MessageFormat*)fmt)->parse(srcString,*count,*status);
UDate *aDate;
double *aDouble;
UChar *aString;
if(U_FAILURE(*status))
return;
- int32_t len = (newValueLength == -1 ? u_strlen(newValue) : newValueLength);
- const UnicodeString val((UChar*)newValue, len, len);
+ UnicodeString val(newValue, newValueLength);
NumberFormat* nf = reinterpret_cast<NumberFormat*>(fmt);
DecimalFormat* df = dynamic_cast<DecimalFormat*>(nf);
if (df != NULL) {
break;
case UNUM_PADDING_CHARACTER:
- df->setPadCharacter(*newValue);
+ df->setPadCharacter(val);
break;
case UNUM_CURRENCY_CODE:
- df->setCurrency(newValue, *status);
+ df->setCurrency(val.getTerminatedBuffer(), *status);
break;
default:
RuleBasedNumberFormat* rbnf = dynamic_cast<RuleBasedNumberFormat*>(nf);
U_ASSERT(rbnf != NULL);
if (tag == UNUM_DEFAULT_RULESET) {
- rbnf->setDefaultRuleSet(newValue, *status);
+ rbnf->setDefaultRuleSet(val, *status);
} else {
*status = U_UNSUPPORTED_ERROR;
}
goto rruleParseError;
}
- if (attr.compare(ICAL_FREQ) == 0) {
+ if (attr.compare(ICAL_FREQ, -1) == 0) {
// only support YEARLY frequency type
- if (value.compare(ICAL_YEARLY) == 0) {
+ if (value.compare(ICAL_YEARLY, -1) == 0) {
yearly = TRUE;
} else {
goto rruleParseError;
}
- } else if (attr.compare(ICAL_UNTIL) == 0) {
+ } else if (attr.compare(ICAL_UNTIL, -1) == 0) {
// ISO8601 UTC format, for example, "20060315T020000Z"
until = parseDateTimeString(value, 0, status);
if (U_FAILURE(status)) {
goto rruleParseError;
}
- } else if (attr.compare(ICAL_BYMONTH) == 0) {
+ } else if (attr.compare(ICAL_BYMONTH, -1) == 0) {
// Note: BYMONTH may contain multiple months, but only single month make sense for
// VTIMEZONE property.
if (value.length() > 2) {
if (U_FAILURE(status) || month < 0 || month >= 12) {
goto rruleParseError;
}
- } else if (attr.compare(ICAL_BYDAY) == 0) {
+ } else if (attr.compare(ICAL_BYDAY, -1) == 0) {
// Note: BYDAY may contain multiple day of week separated by comma. It is unlikely used for
// VTIMEZONE property. We do not support the case.
} else {
goto rruleParseError;
}
- } else if (attr.compare(ICAL_BYMONTHDAY) == 0) {
+ } else if (attr.compare(ICAL_BYMONTHDAY, -1) == 0) {
// Note: BYMONTHDAY may contain multiple days delimitted by comma
//
// A value of BYMONTHDAY could be negative, for example, -1 means
void write(const UnicodeString& str);
void write(UChar ch);
+ void write(const UChar* str);
//void write(const UChar* str, int32_t length);
private:
UnicodeString* out;
out->append(ch);
}
+void
+VTZWriter::write(const UChar* str) {
+ out->append(str, -1);
+}
+
/*
void
VTZWriter::write(const UChar* str, int32_t length) {
UChar ch = reader.read();
if (ch == 0xFFFF) {
// end of file
- if (start && line.startsWith(ICAL_END_VTIMEZONE)) {
+ if (start && line.startsWith(ICAL_END_VTIMEZONE, -1)) {
vtzlines->addElement(new UnicodeString(line), status);
if (U_FAILURE(status)) {
goto cleanupVtzlines;
// LF
eol = TRUE;
if (start) {
- if (line.startsWith(ICAL_END_VTIMEZONE)) {
+ if (line.startsWith(ICAL_END_VTIMEZONE, -1)) {
vtzlines->addElement(new UnicodeString(line), status);
if (U_FAILURE(status)) {
goto cleanupVtzlines;
break;
}
} else {
- if (line.startsWith(ICAL_BEGIN_VTIMEZONE)) {
+ if (line.startsWith(ICAL_BEGIN_VTIMEZONE, -1)) {
vtzlines->addElement(new UnicodeString(line), status);
if (U_FAILURE(status)) {
goto cleanupVtzlines;
switch (state) {
case INI:
- if (name.compare(ICAL_BEGIN) == 0
- && value.compare(ICAL_VTIMEZONE) == 0) {
+ if (name.compare(ICAL_BEGIN, -1) == 0
+ && value.compare(ICAL_VTIMEZONE, -1) == 0) {
state = VTZ;
}
break;
case VTZ:
- if (name.compare(ICAL_TZID) == 0) {
+ if (name.compare(ICAL_TZID, -1) == 0) {
tzid = value;
- } else if (name.compare(ICAL_TZURL) == 0) {
+ } else if (name.compare(ICAL_TZURL, -1) == 0) {
tzurl = value;
- } else if (name.compare(ICAL_LASTMOD) == 0) {
+ } else if (name.compare(ICAL_LASTMOD, -1) == 0) {
// Always in 'Z' format, so the offset argument for the parse method
// can be any value.
lastmod = parseDateTimeString(value, 0, status);
if (U_FAILURE(status)) {
goto cleanupParse;
}
- } else if (name.compare(ICAL_BEGIN) == 0) {
- UBool isDST = (value.compare(ICAL_DAYLIGHT) == 0);
- if (value.compare(ICAL_STANDARD) == 0 || isDST) {
+ } else if (name.compare(ICAL_BEGIN, -1) == 0) {
+ UBool isDST = (value.compare(ICAL_DAYLIGHT, -1) == 0);
+ if (value.compare(ICAL_STANDARD, -1) == 0 || isDST) {
// tzid must be ready at this point
if (tzid.length() == 0) {
goto cleanupParse;
// must not be there.
goto cleanupParse;
}
- } else if (name.compare(ICAL_END) == 0) {
+ } else if (name.compare(ICAL_END, -1) == 0) {
break;
}
break;
case TZI:
- if (name.compare(ICAL_DTSTART) == 0) {
+ if (name.compare(ICAL_DTSTART, -1) == 0) {
dtstart = value;
- } else if (name.compare(ICAL_TZNAME) == 0) {
+ } else if (name.compare(ICAL_TZNAME, -1) == 0) {
zonename = value;
- } else if (name.compare(ICAL_TZOFFSETFROM) == 0) {
+ } else if (name.compare(ICAL_TZOFFSETFROM, -1) == 0) {
from = value;
- } else if (name.compare(ICAL_TZOFFSETTO) == 0) {
+ } else if (name.compare(ICAL_TZOFFSETTO, -1) == 0) {
to = value;
- } else if (name.compare(ICAL_RDATE) == 0) {
+ } else if (name.compare(ICAL_RDATE, -1) == 0) {
// RDATE mixed with RRULE is not supported
if (isRRULE) {
goto cleanupParse;
}
dstart = dend + 1;
}
- } else if (name.compare(ICAL_RRULE) == 0) {
+ } else if (name.compare(ICAL_RRULE, -1) == 0) {
// RRULE mixed with RDATE is not supported
if (!isRRULE && dates->size() != 0) {
goto cleanupParse;
if (U_FAILURE(status)) {
goto cleanupParse;
}
- } else if (name.compare(ICAL_END) == 0) {
+ } else if (name.compare(ICAL_END, -1) == 0) {
// Mandatory properties
if (dtstart.length() == 0 || from.length() == 0 || to.length() == 0) {
goto cleanupParse;
if (vtzlines != NULL) {
for (int32_t i = 0; i < vtzlines->size(); i++) {
UnicodeString *line = (UnicodeString*)vtzlines->elementAt(i);
- if (line->startsWith(ICAL_TZURL)
+ if (line->startsWith(ICAL_TZURL, -1)
&& line->charAt(u_strlen(ICAL_TZURL)) == COLON) {
writer.write(ICAL_TZURL);
writer.write(COLON);
writer.write(tzurl);
writer.write(ICAL_NEWLINE);
- } else if (line->startsWith(ICAL_LASTMOD)
+ } else if (line->startsWith(ICAL_LASTMOD, -1)
&& line->charAt(u_strlen(ICAL_LASTMOD)) == COLON) {
UnicodeString utcString;
writer.write(ICAL_LASTMOD);
icutzprop->append(olsonzid);
icutzprop->append((UChar)0x005B/*'['*/);
icutzprop->append(icutzver);
- icutzprop->append(ICU_TZINFO_PARTIAL);
+ icutzprop->append(ICU_TZINFO_PARTIAL, -1);
appendMillis(start, *icutzprop);
icutzprop->append((UChar)0x005D/*']'*/);
customProps.addElement(icutzprop, status);
icutzprop->append(olsonzid);
icutzprop->append((UChar)0x005B/*'['*/);
icutzprop->append(icutzver);
- icutzprop->append(ICU_TZINFO_SIMPLE);
+ icutzprop->append(ICU_TZINFO_SIMPLE, -1);
appendMillis(time, *icutzprop);
icutzprop->append((UChar)0x005D/*']'*/);
customProps.addElement(icutzprop, status);
/*
*******************************************************************************
-* Copyright (C) 2009-2010, International Business Machines Corporation and *
-* others. All Rights Reserved. *
+* Copyright (C) 2009-2011, International Business Machines Corporation and
+* others. All Rights Reserved.
*******************************************************************************
*/
U_CAPI void U_EXPORT2
vzone_setTZURL(VZone* zone, UChar* url, int32_t urlLength) {
UnicodeString s(urlLength==-1, url, urlLength);
- return ((VTimeZone*)zone)->VTimeZone::setTZURL(url);
+ ((VTimeZone*)zone)->VTimeZone::setTZURL(s);
}
U_CAPI UBool U_EXPORT2
/*
*******************************************************************************
-* Copyright (C) 2009-2010, International Business Machines Corporation and *
-* others. All Rights Reserved. *
+* Copyright (C) 2009-2011, International Business Machines Corporation and
+* others. All Rights Reserved.
*******************************************************************************
*/
U_CAPI IZRule* U_EXPORT2
izrule_open(const UChar* name, int32_t nameLength, int32_t rawOffset, int32_t dstSavings) {
UnicodeString s(nameLength==-1, name, nameLength);
- return (IZRule*) new InitialTimeZoneRule(name, rawOffset, dstSavings);
+ return (IZRule*) new InitialTimeZoneRule(s, rawOffset, dstSavings);
}
U_CAPI void U_EXPORT2