Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
michael@0 | 1 | /* |
michael@0 | 2 | ******************************************************************************** |
michael@0 | 3 | * Copyright (C) 1997-2013, International Business Machines |
michael@0 | 4 | * Corporation and others. All Rights Reserved. |
michael@0 | 5 | ******************************************************************************** |
michael@0 | 6 | * |
michael@0 | 7 | * File DCFMTSYM.H |
michael@0 | 8 | * |
michael@0 | 9 | * Modification History: |
michael@0 | 10 | * |
michael@0 | 11 | * Date Name Description |
michael@0 | 12 | * 02/19/97 aliu Converted from java. |
michael@0 | 13 | * 03/18/97 clhuang Updated per C++ implementation. |
michael@0 | 14 | * 03/27/97 helena Updated to pass the simple test after code review. |
michael@0 | 15 | * 08/26/97 aliu Added currency/intl currency symbol support. |
michael@0 | 16 | * 07/22/98 stephen Changed to match C++ style |
michael@0 | 17 | * currencySymbol -> fCurrencySymbol |
michael@0 | 18 | * Constants changed from CAPS to kCaps |
michael@0 | 19 | * 06/24/99 helena Integrated Alan's NF enhancements and Java2 bug fixes |
michael@0 | 20 | * 09/22/00 grhoten Marked deprecation tags with a pointer to replacement |
michael@0 | 21 | * functions. |
michael@0 | 22 | ******************************************************************************** |
michael@0 | 23 | */ |
michael@0 | 24 | |
michael@0 | 25 | #ifndef DCFMTSYM_H |
michael@0 | 26 | #define DCFMTSYM_H |
michael@0 | 27 | |
michael@0 | 28 | #include "unicode/utypes.h" |
michael@0 | 29 | #include "unicode/uchar.h" |
michael@0 | 30 | |
michael@0 | 31 | #if !UCONFIG_NO_FORMATTING |
michael@0 | 32 | |
michael@0 | 33 | #include "unicode/uobject.h" |
michael@0 | 34 | #include "unicode/locid.h" |
michael@0 | 35 | #include "unicode/unum.h" |
michael@0 | 36 | |
michael@0 | 37 | /** |
michael@0 | 38 | * \file |
michael@0 | 39 | * \brief C++ API: Symbols for formatting numbers. |
michael@0 | 40 | */ |
michael@0 | 41 | |
michael@0 | 42 | |
michael@0 | 43 | U_NAMESPACE_BEGIN |
michael@0 | 44 | |
michael@0 | 45 | /** |
michael@0 | 46 | * This class represents the set of symbols needed by DecimalFormat |
michael@0 | 47 | * to format numbers. DecimalFormat creates for itself an instance of |
michael@0 | 48 | * DecimalFormatSymbols from its locale data. If you need to change any |
michael@0 | 49 | * of these symbols, you can get the DecimalFormatSymbols object from |
michael@0 | 50 | * your DecimalFormat and modify it. |
michael@0 | 51 | * <P> |
michael@0 | 52 | * Here are the special characters used in the parts of the |
michael@0 | 53 | * subpattern, with notes on their usage. |
michael@0 | 54 | * <pre> |
michael@0 | 55 | * \code |
michael@0 | 56 | * Symbol Meaning |
michael@0 | 57 | * 0 a digit |
michael@0 | 58 | * # a digit, zero shows as absent |
michael@0 | 59 | * . placeholder for decimal separator |
michael@0 | 60 | * , placeholder for grouping separator. |
michael@0 | 61 | * ; separates formats. |
michael@0 | 62 | * - default negative prefix. |
michael@0 | 63 | * % divide by 100 and show as percentage |
michael@0 | 64 | * X any other characters can be used in the prefix or suffix |
michael@0 | 65 | * ' used to quote special characters in a prefix or suffix. |
michael@0 | 66 | * \endcode |
michael@0 | 67 | * </pre> |
michael@0 | 68 | * [Notes] |
michael@0 | 69 | * <P> |
michael@0 | 70 | * If there is no explicit negative subpattern, - is prefixed to the |
michael@0 | 71 | * positive form. That is, "0.00" alone is equivalent to "0.00;-0.00". |
michael@0 | 72 | * <P> |
michael@0 | 73 | * The grouping separator is commonly used for thousands, but in some |
michael@0 | 74 | * countries for ten-thousands. The interval is a constant number of |
michael@0 | 75 | * digits between the grouping characters, such as 100,000,000 or 1,0000,0000. |
michael@0 | 76 | * If you supply a pattern with multiple grouping characters, the interval |
michael@0 | 77 | * between the last one and the end of the integer is the one that is |
michael@0 | 78 | * used. So "#,##,###,####" == "######,####" == "##,####,####". |
michael@0 | 79 | * <P> |
michael@0 | 80 | * This class only handles localized digits where the 10 digits are |
michael@0 | 81 | * contiguous in Unicode, from 0 to 9. Other digits sets (such as |
michael@0 | 82 | * superscripts) would need a different subclass. |
michael@0 | 83 | */ |
michael@0 | 84 | class U_I18N_API DecimalFormatSymbols : public UObject { |
michael@0 | 85 | public: |
michael@0 | 86 | /** |
michael@0 | 87 | * Constants for specifying a number format symbol. |
michael@0 | 88 | * @stable ICU 2.0 |
michael@0 | 89 | */ |
michael@0 | 90 | enum ENumberFormatSymbol { |
michael@0 | 91 | /** The decimal separator */ |
michael@0 | 92 | kDecimalSeparatorSymbol, |
michael@0 | 93 | /** The grouping separator */ |
michael@0 | 94 | kGroupingSeparatorSymbol, |
michael@0 | 95 | /** The pattern separator */ |
michael@0 | 96 | kPatternSeparatorSymbol, |
michael@0 | 97 | /** The percent sign */ |
michael@0 | 98 | kPercentSymbol, |
michael@0 | 99 | /** Zero*/ |
michael@0 | 100 | kZeroDigitSymbol, |
michael@0 | 101 | /** Character representing a digit in the pattern */ |
michael@0 | 102 | kDigitSymbol, |
michael@0 | 103 | /** The minus sign */ |
michael@0 | 104 | kMinusSignSymbol, |
michael@0 | 105 | /** The plus sign */ |
michael@0 | 106 | kPlusSignSymbol, |
michael@0 | 107 | /** The currency symbol */ |
michael@0 | 108 | kCurrencySymbol, |
michael@0 | 109 | /** The international currency symbol */ |
michael@0 | 110 | kIntlCurrencySymbol, |
michael@0 | 111 | /** The monetary separator */ |
michael@0 | 112 | kMonetarySeparatorSymbol, |
michael@0 | 113 | /** The exponential symbol */ |
michael@0 | 114 | kExponentialSymbol, |
michael@0 | 115 | /** Per mill symbol - replaces kPermillSymbol */ |
michael@0 | 116 | kPerMillSymbol, |
michael@0 | 117 | /** Escape padding character */ |
michael@0 | 118 | kPadEscapeSymbol, |
michael@0 | 119 | /** Infinity symbol */ |
michael@0 | 120 | kInfinitySymbol, |
michael@0 | 121 | /** Nan symbol */ |
michael@0 | 122 | kNaNSymbol, |
michael@0 | 123 | /** Significant digit symbol |
michael@0 | 124 | * @stable ICU 3.0 */ |
michael@0 | 125 | kSignificantDigitSymbol, |
michael@0 | 126 | /** The monetary grouping separator |
michael@0 | 127 | * @stable ICU 3.6 |
michael@0 | 128 | */ |
michael@0 | 129 | kMonetaryGroupingSeparatorSymbol, |
michael@0 | 130 | /** One |
michael@0 | 131 | * @stable ICU 4.6 |
michael@0 | 132 | */ |
michael@0 | 133 | kOneDigitSymbol, |
michael@0 | 134 | /** Two |
michael@0 | 135 | * @stable ICU 4.6 |
michael@0 | 136 | */ |
michael@0 | 137 | kTwoDigitSymbol, |
michael@0 | 138 | /** Three |
michael@0 | 139 | * @stable ICU 4.6 |
michael@0 | 140 | */ |
michael@0 | 141 | kThreeDigitSymbol, |
michael@0 | 142 | /** Four |
michael@0 | 143 | * @stable ICU 4.6 |
michael@0 | 144 | */ |
michael@0 | 145 | kFourDigitSymbol, |
michael@0 | 146 | /** Five |
michael@0 | 147 | * @stable ICU 4.6 |
michael@0 | 148 | */ |
michael@0 | 149 | kFiveDigitSymbol, |
michael@0 | 150 | /** Six |
michael@0 | 151 | * @stable ICU 4.6 |
michael@0 | 152 | */ |
michael@0 | 153 | kSixDigitSymbol, |
michael@0 | 154 | /** Seven |
michael@0 | 155 | * @stable ICU 4.6 |
michael@0 | 156 | */ |
michael@0 | 157 | kSevenDigitSymbol, |
michael@0 | 158 | /** Eight |
michael@0 | 159 | * @stable ICU 4.6 |
michael@0 | 160 | */ |
michael@0 | 161 | kEightDigitSymbol, |
michael@0 | 162 | /** Nine |
michael@0 | 163 | * @stable ICU 4.6 |
michael@0 | 164 | */ |
michael@0 | 165 | kNineDigitSymbol, |
michael@0 | 166 | /** count symbol constants */ |
michael@0 | 167 | kFormatSymbolCount |
michael@0 | 168 | }; |
michael@0 | 169 | |
michael@0 | 170 | /** |
michael@0 | 171 | * Create a DecimalFormatSymbols object for the given locale. |
michael@0 | 172 | * |
michael@0 | 173 | * @param locale The locale to get symbols for. |
michael@0 | 174 | * @param status Input/output parameter, set to success or |
michael@0 | 175 | * failure code upon return. |
michael@0 | 176 | * @stable ICU 2.0 |
michael@0 | 177 | */ |
michael@0 | 178 | DecimalFormatSymbols(const Locale& locale, UErrorCode& status); |
michael@0 | 179 | |
michael@0 | 180 | /** |
michael@0 | 181 | * Create a DecimalFormatSymbols object for the default locale. |
michael@0 | 182 | * This constructor will not fail. If the resource file data is |
michael@0 | 183 | * not available, it will use hard-coded last-resort data and |
michael@0 | 184 | * set status to U_USING_FALLBACK_ERROR. |
michael@0 | 185 | * |
michael@0 | 186 | * @param status Input/output parameter, set to success or |
michael@0 | 187 | * failure code upon return. |
michael@0 | 188 | * @stable ICU 2.0 |
michael@0 | 189 | */ |
michael@0 | 190 | DecimalFormatSymbols(UErrorCode& status); |
michael@0 | 191 | |
michael@0 | 192 | #ifndef U_HIDE_DRAFT_API |
michael@0 | 193 | /** |
michael@0 | 194 | * Creates a DecimalFormatSymbols object with last-resort data. |
michael@0 | 195 | * Intended for callers who cache the symbols data and |
michael@0 | 196 | * set all symbols on the resulting object. |
michael@0 | 197 | * |
michael@0 | 198 | * The last-resort symbols are similar to those for the root data, |
michael@0 | 199 | * except that the grouping separators are empty, |
michael@0 | 200 | * the NaN symbol is U+FFFD rather than "NaN", |
michael@0 | 201 | * and the CurrencySpacing patterns are empty. |
michael@0 | 202 | * |
michael@0 | 203 | * @param status Input/output parameter, set to success or |
michael@0 | 204 | * failure code upon return. |
michael@0 | 205 | * @return last-resort symbols |
michael@0 | 206 | * @draft ICU 52 |
michael@0 | 207 | */ |
michael@0 | 208 | static DecimalFormatSymbols* createWithLastResortData(UErrorCode& status); |
michael@0 | 209 | #endif /* U_HIDE_DRAFT_API */ |
michael@0 | 210 | |
michael@0 | 211 | /** |
michael@0 | 212 | * Copy constructor. |
michael@0 | 213 | * @stable ICU 2.0 |
michael@0 | 214 | */ |
michael@0 | 215 | DecimalFormatSymbols(const DecimalFormatSymbols&); |
michael@0 | 216 | |
michael@0 | 217 | /** |
michael@0 | 218 | * Assignment operator. |
michael@0 | 219 | * @stable ICU 2.0 |
michael@0 | 220 | */ |
michael@0 | 221 | DecimalFormatSymbols& operator=(const DecimalFormatSymbols&); |
michael@0 | 222 | |
michael@0 | 223 | /** |
michael@0 | 224 | * Destructor. |
michael@0 | 225 | * @stable ICU 2.0 |
michael@0 | 226 | */ |
michael@0 | 227 | virtual ~DecimalFormatSymbols(); |
michael@0 | 228 | |
michael@0 | 229 | /** |
michael@0 | 230 | * Return true if another object is semantically equal to this one. |
michael@0 | 231 | * |
michael@0 | 232 | * @param other the object to be compared with. |
michael@0 | 233 | * @return true if another object is semantically equal to this one. |
michael@0 | 234 | * @stable ICU 2.0 |
michael@0 | 235 | */ |
michael@0 | 236 | UBool operator==(const DecimalFormatSymbols& other) const; |
michael@0 | 237 | |
michael@0 | 238 | /** |
michael@0 | 239 | * Return true if another object is semantically unequal to this one. |
michael@0 | 240 | * |
michael@0 | 241 | * @param other the object to be compared with. |
michael@0 | 242 | * @return true if another object is semantically unequal to this one. |
michael@0 | 243 | * @stable ICU 2.0 |
michael@0 | 244 | */ |
michael@0 | 245 | UBool operator!=(const DecimalFormatSymbols& other) const { return !operator==(other); } |
michael@0 | 246 | |
michael@0 | 247 | /** |
michael@0 | 248 | * Get one of the format symbols by its enum constant. |
michael@0 | 249 | * Each symbol is stored as a string so that graphemes |
michael@0 | 250 | * (characters with modifier letters) can be used. |
michael@0 | 251 | * |
michael@0 | 252 | * @param symbol Constant to indicate a number format symbol. |
michael@0 | 253 | * @return the format symbols by the param 'symbol' |
michael@0 | 254 | * @stable ICU 2.0 |
michael@0 | 255 | */ |
michael@0 | 256 | inline UnicodeString getSymbol(ENumberFormatSymbol symbol) const; |
michael@0 | 257 | |
michael@0 | 258 | /** |
michael@0 | 259 | * Set one of the format symbols by its enum constant. |
michael@0 | 260 | * Each symbol is stored as a string so that graphemes |
michael@0 | 261 | * (characters with modifier letters) can be used. |
michael@0 | 262 | * |
michael@0 | 263 | * @param symbol Constant to indicate a number format symbol. |
michael@0 | 264 | * @param value value of the format symbol |
michael@0 | 265 | * @param propogateDigits If false, setting the zero digit will not automatically set 1-9. |
michael@0 | 266 | * The default behavior is to automatically set 1-9 if zero is being set and the value |
michael@0 | 267 | * it is being set to corresponds to a known Unicode zero digit. |
michael@0 | 268 | * @stable ICU 2.0 |
michael@0 | 269 | */ |
michael@0 | 270 | void setSymbol(ENumberFormatSymbol symbol, const UnicodeString &value, const UBool propogateDigits); |
michael@0 | 271 | |
michael@0 | 272 | /** |
michael@0 | 273 | * Returns the locale for which this object was constructed. |
michael@0 | 274 | * @stable ICU 2.6 |
michael@0 | 275 | */ |
michael@0 | 276 | inline Locale getLocale() const; |
michael@0 | 277 | |
michael@0 | 278 | /** |
michael@0 | 279 | * Returns the locale for this object. Two flavors are available: |
michael@0 | 280 | * valid and actual locale. |
michael@0 | 281 | * @stable ICU 2.8 |
michael@0 | 282 | */ |
michael@0 | 283 | Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const; |
michael@0 | 284 | |
michael@0 | 285 | /** |
michael@0 | 286 | * Get pattern string for 'CurrencySpacing' that can be applied to |
michael@0 | 287 | * currency format. |
michael@0 | 288 | * This API gets the CurrencySpacing data from ResourceBundle. The pattern can |
michael@0 | 289 | * be empty if there is no data from current locale and its parent locales. |
michael@0 | 290 | * |
michael@0 | 291 | * @param type : UNUM_CURRENCY_MATCH, UNUM_CURRENCY_SURROUNDING_MATCH or UNUM_CURRENCY_INSERT. |
michael@0 | 292 | * @param beforeCurrency : true if the pattern is for before currency symbol. |
michael@0 | 293 | * false if the pattern is for after currency symbol. |
michael@0 | 294 | * @param status: Input/output parameter, set to success or |
michael@0 | 295 | * failure code upon return. |
michael@0 | 296 | * @return pattern string for currencyMatch, surroundingMatch or spaceInsert. |
michael@0 | 297 | * Return empty string if there is no data for this locale and its parent |
michael@0 | 298 | * locales. |
michael@0 | 299 | * @stable ICU 4.8 |
michael@0 | 300 | */ |
michael@0 | 301 | const UnicodeString& getPatternForCurrencySpacing(UCurrencySpacing type, |
michael@0 | 302 | UBool beforeCurrency, |
michael@0 | 303 | UErrorCode& status) const; |
michael@0 | 304 | /** |
michael@0 | 305 | * Set pattern string for 'CurrencySpacing' that can be applied to |
michael@0 | 306 | * currency format. |
michael@0 | 307 | * |
michael@0 | 308 | * @param type : UNUM_CURRENCY_MATCH, UNUM_CURRENCY_SURROUNDING_MATCH or UNUM_CURRENCY_INSERT. |
michael@0 | 309 | * @param beforeCurrency : true if the pattern is for before currency symbol. |
michael@0 | 310 | * false if the pattern is for after currency symbol. |
michael@0 | 311 | * @param pattern : pattern string to override current setting. |
michael@0 | 312 | * @stable ICU 4.8 |
michael@0 | 313 | */ |
michael@0 | 314 | void setPatternForCurrencySpacing(UCurrencySpacing type, |
michael@0 | 315 | UBool beforeCurrency, |
michael@0 | 316 | const UnicodeString& pattern); |
michael@0 | 317 | |
michael@0 | 318 | /** |
michael@0 | 319 | * ICU "poor man's RTTI", returns a UClassID for the actual class. |
michael@0 | 320 | * |
michael@0 | 321 | * @stable ICU 2.2 |
michael@0 | 322 | */ |
michael@0 | 323 | virtual UClassID getDynamicClassID() const; |
michael@0 | 324 | |
michael@0 | 325 | /** |
michael@0 | 326 | * ICU "poor man's RTTI", returns a UClassID for this class. |
michael@0 | 327 | * |
michael@0 | 328 | * @stable ICU 2.2 |
michael@0 | 329 | */ |
michael@0 | 330 | static UClassID U_EXPORT2 getStaticClassID(); |
michael@0 | 331 | |
michael@0 | 332 | private: |
michael@0 | 333 | DecimalFormatSymbols(); |
michael@0 | 334 | |
michael@0 | 335 | /** |
michael@0 | 336 | * Initializes the symbols from the LocaleElements resource bundle. |
michael@0 | 337 | * Note: The organization of LocaleElements badly needs to be |
michael@0 | 338 | * cleaned up. |
michael@0 | 339 | * |
michael@0 | 340 | * @param locale The locale to get symbols for. |
michael@0 | 341 | * @param success Input/output parameter, set to success or |
michael@0 | 342 | * failure code upon return. |
michael@0 | 343 | * @param useLastResortData determine if use last resort data |
michael@0 | 344 | */ |
michael@0 | 345 | void initialize(const Locale& locale, UErrorCode& success, UBool useLastResortData = FALSE); |
michael@0 | 346 | |
michael@0 | 347 | /** |
michael@0 | 348 | * Initialize the symbols with default values. |
michael@0 | 349 | */ |
michael@0 | 350 | void initialize(); |
michael@0 | 351 | |
michael@0 | 352 | void setCurrencyForSymbols(); |
michael@0 | 353 | |
michael@0 | 354 | public: |
michael@0 | 355 | #ifndef U_HIDE_INTERNAL_API |
michael@0 | 356 | /** |
michael@0 | 357 | * _Internal_ function - more efficient version of getSymbol, |
michael@0 | 358 | * returning a const reference to one of the symbol strings. |
michael@0 | 359 | * The returned reference becomes invalid when the symbol is changed |
michael@0 | 360 | * or when the DecimalFormatSymbols are destroyed. |
michael@0 | 361 | * ### TODO markus 2002oct11: Consider proposing getConstSymbol() to be really public. |
michael@0 | 362 | * |
michael@0 | 363 | * @param symbol Constant to indicate a number format symbol. |
michael@0 | 364 | * @return the format symbol by the param 'symbol' |
michael@0 | 365 | * @internal |
michael@0 | 366 | */ |
michael@0 | 367 | inline const UnicodeString &getConstSymbol(ENumberFormatSymbol symbol) const; |
michael@0 | 368 | |
michael@0 | 369 | /** |
michael@0 | 370 | * Returns that pattern stored in currecy info. Internal API for use by NumberFormat API. |
michael@0 | 371 | * @internal |
michael@0 | 372 | */ |
michael@0 | 373 | inline const UChar* getCurrencyPattern(void) const; |
michael@0 | 374 | #endif /* U_HIDE_INTERNAL_API */ |
michael@0 | 375 | |
michael@0 | 376 | private: |
michael@0 | 377 | /** |
michael@0 | 378 | * Private symbol strings. |
michael@0 | 379 | * They are either loaded from a resource bundle or otherwise owned. |
michael@0 | 380 | * setSymbol() clones the symbol string. |
michael@0 | 381 | * Readonly aliases can only come from a resource bundle, so that we can always |
michael@0 | 382 | * use fastCopyFrom() with them. |
michael@0 | 383 | * |
michael@0 | 384 | * If DecimalFormatSymbols becomes subclassable and the status of fSymbols changes |
michael@0 | 385 | * from private to protected, |
michael@0 | 386 | * or when fSymbols can be set any other way that allows them to be readonly aliases |
michael@0 | 387 | * to non-resource bundle strings, |
michael@0 | 388 | * then regular UnicodeString copies must be used instead of fastCopyFrom(). |
michael@0 | 389 | * |
michael@0 | 390 | * @internal |
michael@0 | 391 | */ |
michael@0 | 392 | UnicodeString fSymbols[kFormatSymbolCount]; |
michael@0 | 393 | |
michael@0 | 394 | /** |
michael@0 | 395 | * Non-symbol variable for getConstSymbol(). Always empty. |
michael@0 | 396 | * @internal |
michael@0 | 397 | */ |
michael@0 | 398 | UnicodeString fNoSymbol; |
michael@0 | 399 | |
michael@0 | 400 | Locale locale; |
michael@0 | 401 | |
michael@0 | 402 | char actualLocale[ULOC_FULLNAME_CAPACITY]; |
michael@0 | 403 | char validLocale[ULOC_FULLNAME_CAPACITY]; |
michael@0 | 404 | const UChar* currPattern; |
michael@0 | 405 | |
michael@0 | 406 | UnicodeString currencySpcBeforeSym[UNUM_CURRENCY_SPACING_COUNT]; |
michael@0 | 407 | UnicodeString currencySpcAfterSym[UNUM_CURRENCY_SPACING_COUNT]; |
michael@0 | 408 | }; |
michael@0 | 409 | |
michael@0 | 410 | // ------------------------------------- |
michael@0 | 411 | |
michael@0 | 412 | inline UnicodeString |
michael@0 | 413 | DecimalFormatSymbols::getSymbol(ENumberFormatSymbol symbol) const { |
michael@0 | 414 | const UnicodeString *strPtr; |
michael@0 | 415 | if(symbol < kFormatSymbolCount) { |
michael@0 | 416 | strPtr = &fSymbols[symbol]; |
michael@0 | 417 | } else { |
michael@0 | 418 | strPtr = &fNoSymbol; |
michael@0 | 419 | } |
michael@0 | 420 | return *strPtr; |
michael@0 | 421 | } |
michael@0 | 422 | |
michael@0 | 423 | #ifndef U_HIDE_INTERNAL_API |
michael@0 | 424 | |
michael@0 | 425 | inline const UnicodeString & |
michael@0 | 426 | DecimalFormatSymbols::getConstSymbol(ENumberFormatSymbol symbol) const { |
michael@0 | 427 | const UnicodeString *strPtr; |
michael@0 | 428 | if(symbol < kFormatSymbolCount) { |
michael@0 | 429 | strPtr = &fSymbols[symbol]; |
michael@0 | 430 | } else { |
michael@0 | 431 | strPtr = &fNoSymbol; |
michael@0 | 432 | } |
michael@0 | 433 | return *strPtr; |
michael@0 | 434 | } |
michael@0 | 435 | |
michael@0 | 436 | #endif /* U_HIDE_INTERNAL_API */ |
michael@0 | 437 | |
michael@0 | 438 | |
michael@0 | 439 | // ------------------------------------- |
michael@0 | 440 | |
michael@0 | 441 | inline void |
michael@0 | 442 | DecimalFormatSymbols::setSymbol(ENumberFormatSymbol symbol, const UnicodeString &value, const UBool propogateDigits = TRUE) { |
michael@0 | 443 | if(symbol<kFormatSymbolCount) { |
michael@0 | 444 | fSymbols[symbol]=value; |
michael@0 | 445 | } |
michael@0 | 446 | |
michael@0 | 447 | // If the zero digit is being set to a known zero digit according to Unicode, |
michael@0 | 448 | // then we automatically set the corresponding 1-9 digits |
michael@0 | 449 | if ( propogateDigits && symbol == kZeroDigitSymbol && value.countChar32() == 1 ) { |
michael@0 | 450 | UChar32 sym = value.char32At(0); |
michael@0 | 451 | if ( u_charDigitValue(sym) == 0 ) { |
michael@0 | 452 | for ( int8_t i = 1 ; i<= 9 ; i++ ) { |
michael@0 | 453 | sym++; |
michael@0 | 454 | fSymbols[(int)kOneDigitSymbol+i-1] = UnicodeString(sym); |
michael@0 | 455 | } |
michael@0 | 456 | } |
michael@0 | 457 | } |
michael@0 | 458 | } |
michael@0 | 459 | |
michael@0 | 460 | // ------------------------------------- |
michael@0 | 461 | |
michael@0 | 462 | inline Locale |
michael@0 | 463 | DecimalFormatSymbols::getLocale() const { |
michael@0 | 464 | return locale; |
michael@0 | 465 | } |
michael@0 | 466 | |
michael@0 | 467 | #ifndef U_HIDE_INTERNAL_API |
michael@0 | 468 | inline const UChar* |
michael@0 | 469 | DecimalFormatSymbols::getCurrencyPattern() const { |
michael@0 | 470 | return currPattern; |
michael@0 | 471 | } |
michael@0 | 472 | #endif /* U_HIDE_INTERNAL_API */ |
michael@0 | 473 | |
michael@0 | 474 | U_NAMESPACE_END |
michael@0 | 475 | |
michael@0 | 476 | #endif /* #if !UCONFIG_NO_FORMATTING */ |
michael@0 | 477 | |
michael@0 | 478 | #endif // _DCFMTSYM |
michael@0 | 479 | //eof |