U_CAPI void U_EXPORT2 unum_setTextAttribute( UNumberFormat* fmt, UNumberFormatTextAttribute tag, const UChar* newValue, int32_t newValueLength, UErrorCode *status) { if(U_FAILURE(*status)) return; int32_t len = (newValueLength == -1 ? u_strlen(newValue) : newValueLength); const UnicodeString val((UChar*)newValue, len, len); NumberFormat* nf = reinterpret_cast<NumberFormat*>(fmt); DecimalFormat* df = dynamic_cast<DecimalFormat*>(nf); if (df != NULL) { switch(tag) { case UNUM_POSITIVE_PREFIX: df->setPositivePrefix(val); break; case UNUM_POSITIVE_SUFFIX: df->setPositiveSuffix(val); break; case UNUM_NEGATIVE_PREFIX: df->setNegativePrefix(val); break; case UNUM_NEGATIVE_SUFFIX: df->setNegativeSuffix(val); break; case UNUM_PADDING_CHARACTER: df->setPadCharacter(*newValue); break; case UNUM_CURRENCY_CODE: df->setCurrency(newValue, *status); break; default: *status = U_UNSUPPORTED_ERROR; break; } } else { RuleBasedNumberFormat* rbnf = dynamic_cast<RuleBasedNumberFormat*>(nf); U_ASSERT(rbnf != NULL); if (tag == UNUM_DEFAULT_RULESET) { rbnf->setDefaultRuleSet(newValue, *status); } else { *status = U_UNSUPPORTED_ERROR; } } }
U_CAPI void U_EXPORT2 unum_setTextAttribute( UNumberFormat* fmt, UNumberFormatTextAttribute tag, const UChar* newValue, int32_t newValueLength, UErrorCode *status) { if(U_FAILURE(*status)) return; int32_t len = (newValueLength == -1 ? u_strlen(newValue) : newValueLength); const UnicodeString val((UChar*)newValue, len, len); if (((NumberFormat*)fmt)->getDynamicClassID() == DecimalFormat::getStaticClassID()) { DecimalFormat* df = (DecimalFormat*) fmt; switch(tag) { case UNUM_POSITIVE_PREFIX: df->setPositivePrefix(val); break; case UNUM_POSITIVE_SUFFIX: df->setPositiveSuffix(val); break; case UNUM_NEGATIVE_PREFIX: df->setNegativePrefix(val); break; case UNUM_NEGATIVE_SUFFIX: df->setNegativeSuffix(val); break; case UNUM_PADDING_CHARACTER: df->setPadCharacter(*newValue); break; case UNUM_CURRENCY_CODE: df->setCurrency(newValue, *status); break; default: *status = U_UNSUPPORTED_ERROR; break; } } else { U_ASSERT(((NumberFormat*)fmt)->getDynamicClassID() == RuleBasedNumberFormat::getStaticClassID()); if (tag == UNUM_DEFAULT_RULESET) { ((RuleBasedNumberFormat*)fmt)->setDefaultRuleSet(newValue, *status); } else { *status = U_UNSUPPORTED_ERROR; } } }