Logo Search packages:      
Sourcecode: icu version File versions

void DecimalFormat::appendAffixPattern ( UnicodeString appendTo,
const UnicodeString affix,
UBool  localized 
) const [private]

Append an affix to the given UnicodeString, using quotes if there are special characters. Single quotes themselves must be escaped in either case.

Append an affix to the given StringBuffer, using quotes if there are special characters. Single quotes themselves must be escaped in either case.

Definition at line 3563 of file decimfmt.cpp.

References UnicodeString::char32At(), getConstSymbol(), UnicodeString::indexOf(), DecimalFormatSymbols::kDecimalSeparatorSymbol, DecimalFormatSymbols::kDigitSymbol, DecimalFormatSymbols::kGroupingSeparatorSymbol, DecimalFormatSymbols::kMinusSignSymbol, DecimalFormatSymbols::kPatternSeparatorSymbol, DecimalFormatSymbols::kPercentSymbol, DecimalFormatSymbols::kPerMillSymbol, DecimalFormatSymbols::kPlusSignSymbol, DecimalFormatSymbols::kZeroDigitSymbol, UnicodeString::length(), and U16_LENGTH.

Referenced by appendAffixPattern(), and toPattern().

                                                         {
    UBool needQuote;
    if(localized) {
        needQuote = affix.indexOf(getConstSymbol(DecimalFormatSymbols::kZeroDigitSymbol)) >= 0
            || affix.indexOf(getConstSymbol(DecimalFormatSymbols::kGroupingSeparatorSymbol)) >= 0
            || affix.indexOf(getConstSymbol(DecimalFormatSymbols::kDecimalSeparatorSymbol)) >= 0
            || affix.indexOf(getConstSymbol(DecimalFormatSymbols::kPercentSymbol)) >= 0
            || affix.indexOf(getConstSymbol(DecimalFormatSymbols::kPerMillSymbol)) >= 0
            || affix.indexOf(getConstSymbol(DecimalFormatSymbols::kDigitSymbol)) >= 0
            || affix.indexOf(getConstSymbol(DecimalFormatSymbols::kPatternSeparatorSymbol)) >= 0
            || affix.indexOf(getConstSymbol(DecimalFormatSymbols::kPlusSignSymbol)) >= 0
            || affix.indexOf(getConstSymbol(DecimalFormatSymbols::kMinusSignSymbol)) >= 0
            || affix.indexOf(kCurrencySign) >= 0;
    }
    else {
        needQuote = affix.indexOf(kPatternZeroDigit) >= 0
            || affix.indexOf(kPatternGroupingSeparator) >= 0
            || affix.indexOf(kPatternDecimalSeparator) >= 0
            || affix.indexOf(kPatternPercent) >= 0
            || affix.indexOf(kPatternPerMill) >= 0
            || affix.indexOf(kPatternDigit) >= 0
            || affix.indexOf(kPatternSeparator) >= 0
            || affix.indexOf(kPatternExponent) >= 0
            || affix.indexOf(kPatternPlus) >= 0
            || affix.indexOf(kPatternMinus) >= 0
            || affix.indexOf(kCurrencySign) >= 0;
    }
    if (needQuote)
        appendTo += (UChar)0x0027 /*'\''*/;
    if (affix.indexOf((UChar)0x0027 /*'\''*/) < 0)
        appendTo += affix;
    else {
        for (int32_t j = 0; j < affix.length(); ) {
            UChar32 c = affix.char32At(j);
            j += U16_LENGTH(c);
            appendTo += c;
            if (c == 0x0027 /*'\''*/)
                appendTo += c;
        }
    }
    if (needQuote)
        appendTo += (UChar)0x0027 /*'\''*/;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index