164339d36f8bd4db5025fe2988eda22b491a9219cFredrik Roubert// Copyright (C) 2016 and later: Unicode, Inc. and others. 264339d36f8bd4db5025fe2988eda22b491a9219cFredrik Roubert// License & terms of use: http://www.unicode.org/copyright.html 3ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/* 4ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru******************************************************************************** 58de051c3d18a56cc126f0f44e368495a52f9148cFredrik Roubert* Copyright (C) 1997-2016, International Business Machines 6ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* Corporation and others. All Rights Reserved. 7ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru******************************************************************************** 8ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* 9ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* File DECIMFMT.H 10ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* 11ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* Modification History: 12ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* 13ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* Date Name Description 14ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* 02/19/97 aliu Converted from java. 15ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* 03/20/97 clhuang Updated per C++ implementation. 16ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* 04/03/97 aliu Rewrote parsing and formatting completely, and 17ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* cleaned up and debugged. Actually works now. 18ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* 04/17/97 aliu Changed DigitCount to int per code review. 19ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* 07/10/97 helena Made ParsePosition a class and get rid of the function 20ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* hiding problems. 21ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* 09/09/97 aliu Ported over support for exponential formats. 228393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius* 07/20/98 stephen Changed documentation 238393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius* 01/30/13 emmons Added Scaling methods 24ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru******************************************************************************** 25ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*/ 2650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 27ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#ifndef DECIMFMT_H 28ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define DECIMFMT_H 2950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 30ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/utypes.h" 31ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/** 3250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * \file 33ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \brief C++ API: Formats decimal numbers. 34ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 3550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 36ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#if !UCONFIG_NO_FORMATTING 37ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 38ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/dcfmtsym.h" 39ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/numfmt.h" 40ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/locid.h" 4150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#include "unicode/fpositer.h" 4250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#include "unicode/stringpiece.h" 43103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#include "unicode/curramt.h" 4454dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius#include "unicode/enumset.h" 45ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 46c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert#ifndef U_HIDE_INTERNAL_API 47103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius/** 4854dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * \def UNUM_DECIMALFORMAT_INTERNAL_SIZE 49103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @internal 50103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius */ 51103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#if UCONFIG_FORMAT_FASTPATHS_49 52103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#define UNUM_DECIMALFORMAT_INTERNAL_SIZE 16 53103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif 54c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert#endif /* U_HIDE_INTERNAL_API */ 5585bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho 56ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_NAMESPACE_BEGIN 57ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 58ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass DigitList; 5985bf2e2fbc60a9f938064abc8127d61da7d19882Claire Hoclass CurrencyPluralInfo; 6085bf2e2fbc60a9f938064abc8127d61da7d19882Claire Hoclass Hashtable; 61b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2clairehoclass UnicodeSet; 6250294ead5e5d23f5bbfed76e00e6b510bd41eee1clairehoclass FieldPositionHandler; 6359d709d503bab6e2b61931737e662dd293b40578ccorneliusclass DecimalFormatStaticSets; 6459d709d503bab6e2b61931737e662dd293b40578ccorneliusclass FixedDecimal; 65c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubertclass DecimalFormatImpl; 66c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubertclass PluralRules; 67c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubertclass VisibleDigitsWithExponent; 68ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 6954dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius// explicit template instantiation. see digitlst.h 7054dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius#if defined (_MSC_VER) 7154dcd9b6a06071f647dac967e9e267abb9410720Craig Corneliustemplate class U_I18N_API EnumSet<UNumberFormatAttribute, 72fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius UNUM_MAX_NONBOOLEAN_ATTRIBUTE+1, 7354dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius UNUM_LIMIT_BOOLEAN_ATTRIBUTE>; 7454dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius#endif 7554dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius 76ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/** 77ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * DecimalFormat is a concrete subclass of NumberFormat that formats decimal 78ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * numbers. It has a variety of features designed to make it possible to parse 79ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * and format numbers in any locale, including support for Western, Arabic, or 80ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Indic digits. It also supports different flavors of numbers, including 81ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * integers ("123"), fixed-point numbers ("123.4"), scientific notation 8285bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * ("1.23E4"), percentages ("12%"), and currency amounts ("$123", "USD123", 8385bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * "123 US dollars"). All of these flavors can be easily localized. 84ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 85ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>To obtain a NumberFormat for a specific locale (including the default 86ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * locale) call one of NumberFormat's factory methods such as 87ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * createInstance(). Do not call the DecimalFormat constructors directly, unless 88ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * you know what you are doing, since the NumberFormat factory methods may 89ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * return subclasses other than DecimalFormat. 90ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 91ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p><strong>Example Usage</strong> 92ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 93ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \code 94ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * // Normally we would have a GUI with a menu for this 95ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * int32_t locCount; 96ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * const Locale* locales = NumberFormat::getAvailableLocales(locCount); 9750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 98ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * double myNumber = -1234.56; 99ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * UErrorCode success = U_ZERO_ERROR; 100ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * NumberFormat* form; 10150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 102ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * // Print out a number with the localized number, currency and percent 103ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * // format for each locale. 104ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * UnicodeString countryName; 105ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * UnicodeString displayName; 106ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * UnicodeString str; 107ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * UnicodeString pattern; 108ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Formattable fmtable; 109ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * for (int32_t j = 0; j < 3; ++j) { 110ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * cout << endl << "FORMAT " << j << endl; 111ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * for (int32_t i = 0; i < locCount; ++i) { 112ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * if (locales[i].getCountry(countryName).size() == 0) { 113ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * // skip language-only 114ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * continue; 115ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * } 116ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * switch (j) { 117ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * case 0: 118ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * form = NumberFormat::createInstance(locales[i], success ); break; 119ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * case 1: 120ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * form = NumberFormat::createCurrencyInstance(locales[i], success ); break; 121ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * default: 122ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * form = NumberFormat::createPercentInstance(locales[i], success ); break; 123ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * } 124ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * if (form) { 125ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * str.remove(); 126ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * pattern = ((DecimalFormat*)form)->toPattern(pattern); 127ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * cout << locales[i].getDisplayName(displayName) << ": " << pattern; 128ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * cout << " -> " << form->format(myNumber,str) << endl; 129ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * form->parse(form->format(myNumber,str), fmtable, success); 13050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * delete form; 131ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * } 132ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * } 133ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * } 134ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \endcode 13585bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * <P> 13685bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * Another example use createInstance(style) 13785bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * <P> 13885bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * <pre> 13985bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * <strong>// Print out a number using the localized number, currency, 14085bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * // percent, scientific, integer, iso currency, and plural currency 14185bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * // format for each locale</strong> 14285bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * Locale* locale = new Locale("en", "US"); 14385bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * double myNumber = 1234.56; 14485bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * UErrorCode success = U_ZERO_ERROR; 14585bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * UnicodeString str; 14685bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * Formattable fmtable; 14750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * for (int j=NumberFormat::kNumberStyle; 14850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * j<=NumberFormat::kPluralCurrencyStyle; 14985bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * ++j) { 15085bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * NumberFormat* format = NumberFormat::createInstance(locale, j, success); 15185bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * str.remove(); 15285bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * cout << "format result " << form->format(myNumber, str) << endl; 15385bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * format->parse(form->format(myNumber, str), fmtable, success); 15450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * }</pre> 15585bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * 156ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 157ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p><strong>Patterns</strong> 158ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 159ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>A DecimalFormat consists of a <em>pattern</em> and a set of 160ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <em>symbols</em>. The pattern may be set directly using 161ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * applyPattern(), or indirectly using other API methods which 162ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * manipulate aspects of the pattern, such as the minimum number of integer 163ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * digits. The symbols are stored in a DecimalFormatSymbols 164ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * object. When using the NumberFormat factory methods, the 165ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * pattern and symbols are read from ICU's locale data. 16650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 167ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p><strong>Special Pattern Characters</strong> 168ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 169ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>Many characters in a pattern are taken literally; they are matched during 170ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * parsing and output unchanged during formatting. Special characters, on the 171ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * other hand, stand for other characters, strings, or classes of characters. 172ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * For example, the '#' character is replaced by a localized digit. Often the 173ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * replacement character is the same as the pattern character; in the U.S. locale, 174ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * the ',' grouping character is replaced by ','. However, the replacement is 175ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * still happening, and if the symbols are modified, the grouping character 176ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * changes. Some special characters affect the behavior of the formatter by 177ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * their presence; for example, if the percent character is seen, then the 178ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * value is multiplied by 100 before being displayed. 179ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 180ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>To insert a special character in a pattern as a literal, that is, without 181ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * any special meaning, the character must be quoted. There are some exceptions to 182ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * this which are noted below. 183ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 184ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>The characters listed here are used in non-localized patterns. Localized 185ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * patterns use the corresponding characters taken from this formatter's 186ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * DecimalFormatSymbols object instead, and these characters lose 187ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * their special status. Two exceptions are the currency sign and quote, which 188ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * are not localized. 189ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 190ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <table border=0 cellspacing=3 cellpadding=0> 191ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <tr bgcolor="#ccccff"> 192ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td align=left><strong>Symbol</strong> 193ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td align=left><strong>Location</strong> 194ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td align=left><strong>Localized?</strong> 195ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td align=left><strong>Meaning</strong> 196ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <tr valign=top> 197ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td><code>0</code> 198ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Number 199ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Yes 200ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Digit 201ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <tr valign=top bgcolor="#eeeeff"> 202ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td><code>1-9</code> 203ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Number 204ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Yes 205ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>'1' through '9' indicate rounding. 206ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <tr valign=top> 207ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td><code>\htmlonly@\endhtmlonly</code> <!--doxygen doesn't like @--> 208ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Number 209ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>No 210ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Significant digit 211ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <tr valign=top bgcolor="#eeeeff"> 212ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td><code>#</code> 213ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Number 214ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Yes 215ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Digit, zero shows as absent 216ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <tr valign=top> 217ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td><code>.</code> 218ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Number 219ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Yes 220ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Decimal separator or monetary decimal separator 221ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <tr valign=top bgcolor="#eeeeff"> 222ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td><code>-</code> 223ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Number 224ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Yes 225ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Minus sign 226ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <tr valign=top> 227ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td><code>,</code> 228ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Number 229ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Yes 230ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Grouping separator 231ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <tr valign=top bgcolor="#eeeeff"> 232ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td><code>E</code> 233ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Number 234ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Yes 235ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Separates mantissa and exponent in scientific notation. 236ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <em>Need not be quoted in prefix or suffix.</em> 237ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <tr valign=top> 238ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td><code>+</code> 239ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Exponent 240ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Yes 241ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Prefix positive exponents with localized plus sign. 242ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <em>Need not be quoted in prefix or suffix.</em> 243ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <tr valign=top bgcolor="#eeeeff"> 244ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td><code>;</code> 245ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Subpattern boundary 246ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Yes 247ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Separates positive and negative subpatterns 248ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <tr valign=top> 249ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td><code>\%</code> 250ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Prefix or suffix 251ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Yes 252ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Multiply by 100 and show as percentage 253ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <tr valign=top bgcolor="#eeeeff"> 254ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td><code>\\u2030</code> 255ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Prefix or suffix 256ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Yes 257ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Multiply by 1000 and show as per mille 258ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <tr valign=top> 259ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td><code>\htmlonly¤\endhtmlonly</code> (<code>\\u00A4</code>) 260ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Prefix or suffix 261ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>No 262ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Currency sign, replaced by currency symbol. If 263ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * doubled, replaced by international currency symbol. 26485bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * If tripled, replaced by currency plural names, for example, 26585bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * "US dollar" or "US dollars" for America. 266ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * If present in a pattern, the monetary decimal separator 267ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * is used instead of the decimal separator. 268ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <tr valign=top bgcolor="#eeeeff"> 269ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td><code>'</code> 270ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Prefix or suffix 271ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>No 272ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Used to quote special characters in a prefix or suffix, 273ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * for example, <code>"'#'#"</code> formats 123 to 274ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>"#123"</code>. To create a single quote 275ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * itself, use two in a row: <code>"# o''clock"</code>. 276ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <tr valign=top> 277ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td><code>*</code> 278ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Prefix or suffix boundary 279ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Yes 280ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>Pad escape, precedes pad character 281ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * </table> 282ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 283ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>A DecimalFormat pattern contains a postive and negative 284ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * subpattern, for example, "#,##0.00;(#,##0.00)". Each subpattern has a 285ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * prefix, a numeric part, and a suffix. If there is no explicit negative 286ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * subpattern, the negative subpattern is the localized minus sign prefixed to the 287ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * positive subpattern. That is, "0.00" alone is equivalent to "0.00;-0.00". If there 288ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * is an explicit negative subpattern, it serves only to specify the negative 289ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * prefix and suffix; the number of digits, minimal digits, and other 290ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * characteristics are ignored in the negative subpattern. That means that 291ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * "#,##0.0#;(#)" has precisely the same result as "#,##0.0#;(#,##0.0#)". 292ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 293ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>The prefixes, suffixes, and various symbols used for infinity, digits, 294ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * thousands separators, decimal separators, etc. may be set to arbitrary 295ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * values, and they will appear properly during formatting. However, care must 296ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * be taken that the symbols and strings do not conflict, or parsing will be 297ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * unreliable. For example, either the positive and negative prefixes or the 298ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * suffixes must be distinct for parse() to be able 299ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * to distinguish positive from negative values. Another example is that the 300ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * decimal separator and thousands separator should be distinct characters, or 301ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * parsing will be impossible. 302ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 303ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>The <em>grouping separator</em> is a character that separates clusters of 304ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * integer digits to make large numbers more legible. It commonly used for 305ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * thousands, but in some locales it separates ten-thousands. The <em>grouping 306ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * size</em> is the number of digits between the grouping separators, such as 3 307ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * for "100,000,000" or 4 for "1 0000 0000". There are actually two different 308ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * grouping sizes: One used for the least significant integer digits, the 309ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <em>primary grouping size</em>, and one used for all others, the 310ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <em>secondary grouping size</em>. In most locales these are the same, but 311ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * sometimes they are different. For example, if the primary grouping interval 312ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * is 3, and the secondary is 2, then this corresponds to the pattern 313ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * "#,##,##0", and the number 123456789 is formatted as "12,34,56,789". If a 314ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * pattern contains multiple grouping separators, the interval between the last 315ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * one and the end of the integer defines the primary grouping size, and the 316ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * interval between the last two defines the secondary grouping size. All others 317ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * are ignored, so "#,##,###,####" == "###,###,####" == "##,#,###,####". 318ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 319ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>Illegal patterns, such as "#.#.#" or "#.###,###", will cause 320ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * DecimalFormat to set a failing UErrorCode. 321ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 322ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p><strong>Pattern BNF</strong> 323ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 324ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <pre> 325ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * pattern := subpattern (';' subpattern)? 326ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * subpattern := prefix? number exponent? suffix? 327ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * number := (integer ('.' fraction)?) | sigDigits 328ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * prefix := '\\u0000'..'\\uFFFD' - specialCharacters 329ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * suffix := '\\u0000'..'\\uFFFD' - specialCharacters 330ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * integer := '#'* '0'* '0' 331ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * fraction := '0'* '#'* 332ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * sigDigits := '#'* '@' '@'* '#'* 333ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * exponent := 'E' '+'? '0'* '0' 334ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * padSpec := '*' padChar 335ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * padChar := '\\u0000'..'\\uFFFD' - quote 336ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 337ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Notation: 338ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * X* 0 or more instances of X 339ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * X? 0 or 1 instances of X 340ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * X|Y either X or Y 341ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * C..D any character from C up to D, inclusive 342ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * S-T characters in S, except those in T 343ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * </pre> 344ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * The first subpattern is for positive numbers. The second (optional) 345ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * subpattern is for negative numbers. 34650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 347ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>Not indicated in the BNF syntax above: 348ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 349ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <ul><li>The grouping separator ',' can occur inside the integer and 350ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * sigDigits elements, between any two pattern characters of that 351ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * element, as long as the integer or sigDigits element is not 352ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * followed by the exponent element. 353ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 354ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>Two grouping intervals are recognized: That between the 355ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * decimal point and the first grouping symbol, and that 356ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * between the first and second grouping symbols. These 357ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * intervals are identical in most locales, but in some 358ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * locales they differ. For example, the pattern 359ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * "#,##,###" formats the number 123456789 as 360ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * "12,34,56,789".</li> 36150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 362ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>The pad specifier <code>padSpec</code> may appear before the prefix, 363ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * after the prefix, before the suffix, after the suffix, or not at all. 364ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 365ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>In place of '0', the digits '1' through '9' may be used to 366ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * indicate a rounding increment. 367ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * </ul> 368ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 369ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p><strong>Parsing</strong> 370ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 371ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>DecimalFormat parses all Unicode characters that represent 372ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * decimal digits, as defined by u_charDigitValue(). In addition, 373ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * DecimalFormat also recognizes as digits the ten consecutive 374ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * characters starting with the localized zero digit defined in the 375ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * DecimalFormatSymbols object. During formatting, the 376ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * DecimalFormatSymbols-based digits are output. 377ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 378b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <p>During parsing, grouping separators are ignored if in lenient mode; 379b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * otherwise, if present, they must be in appropriate positions. 380ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 38185bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * <p>For currency parsing, the formatter is able to parse every currency 38285bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * style formats no matter which style the formatter is constructed with. 38350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * For example, a formatter instance gotten from 38485bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * NumberFormat.getInstance(ULocale, NumberFormat.CURRENCYSTYLE) can parse 38585bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * formats such as "USD1.00" and "3.00 US dollars". 38685bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * 387ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>If parse(UnicodeString&,Formattable&,ParsePosition&) 388ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * fails to parse a string, it leaves the parse position unchanged. 389ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * The convenience method parse(UnicodeString&,Formattable&,UErrorCode&) 390ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * indicates parse failure by setting a failing 391ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * UErrorCode. 392ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 393ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p><strong>Formatting</strong> 394ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 395ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>Formatting is guided by several parameters, all of which can be 396ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * specified either using a pattern or using the API. The following 397ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * description applies to formats that do not use <a href="#sci">scientific 398ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * notation</a> or <a href="#sigdig">significant digits</a>. 399ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 400ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <ul><li>If the number of actual integer digits exceeds the 401ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <em>maximum integer digits</em>, then only the least significant 402ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * digits are shown. For example, 1997 is formatted as "97" if the 403ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * maximum integer digits is set to 2. 404ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 405ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>If the number of actual integer digits is less than the 406ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <em>minimum integer digits</em>, then leading zeros are added. For 407ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * example, 1997 is formatted as "01997" if the minimum integer digits 408ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * is set to 5. 409ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 410ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>If the number of actual fraction digits exceeds the <em>maximum 41127f654740f2a26ad62a5c155af9199af9e69b889claireho * fraction digits</em>, then rounding is performed to the 412ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * maximum fraction digits. For example, 0.125 is formatted as "0.12" 413ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * if the maximum fraction digits is 2. This behavior can be changed 41427f654740f2a26ad62a5c155af9199af9e69b889claireho * by specifying a rounding increment and/or a rounding mode. 415ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 416ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>If the number of actual fraction digits is less than the 417ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <em>minimum fraction digits</em>, then trailing zeros are added. 418ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * For example, 0.125 is formatted as "0.1250" if the mimimum fraction 419ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * digits is set to 4. 420ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 421ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>Trailing fractional zeros are not displayed if they occur 422ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <em>j</em> positions after the decimal, where <em>j</em> is less 423ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * than the maximum fraction digits. For example, 0.10004 is 424ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * formatted as "0.1" if the maximum fraction digits is four or less. 425ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * </ul> 426ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 427ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p><strong>Special Values</strong> 428ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 429ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p><code>NaN</code> is represented as a single character, typically 430ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>\\uFFFD</code>. This character is determined by the 431ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * DecimalFormatSymbols object. This is the only value for which 432ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * the prefixes and suffixes are not used. 433ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 434ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>Infinity is represented as a single character, typically 435ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>\\u221E</code>, with the positive or negative prefixes and suffixes 436ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * applied. The infinity character is determined by the 437ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * DecimalFormatSymbols object. 438ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 439ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <a name="sci"><strong>Scientific Notation</strong></a> 440ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 441ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>Numbers in scientific notation are expressed as the product of a mantissa 442ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * and a power of ten, for example, 1234 can be expressed as 1.234 x 10<sup>3</sup>. The 443ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * mantissa is typically in the half-open interval [1.0, 10.0) or sometimes [0.0, 1.0), 444ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * but it need not be. DecimalFormat supports arbitrary mantissas. 445ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * DecimalFormat can be instructed to use scientific 446ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * notation through the API or through the pattern. In a pattern, the exponent 447ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * character immediately followed by one or more digit characters indicates 448ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * scientific notation. Example: "0.###E0" formats the number 1234 as 449ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * "1.234E3". 450ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 451ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <ul> 452ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>The number of digit characters after the exponent character gives the 453ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * minimum exponent digit count. There is no maximum. Negative exponents are 454ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * formatted using the localized minus sign, <em>not</em> the prefix and suffix 455ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * from the pattern. This allows patterns such as "0.###E0 m/s". To prefix 456ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * positive exponents with a localized plus sign, specify '+' between the 457ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * exponent and the digits: "0.###E+0" will produce formats "1E+1", "1E+0", 458ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * "1E-1", etc. (In localized patterns, use the localized plus sign rather than 459ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * '+'.) 460ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 461ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>The minimum number of integer digits is achieved by adjusting the 462ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * exponent. Example: 0.00123 formatted with "00.###E0" yields "12.3E-4". This 463ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * only happens if there is no maximum number of integer digits. If there is a 464ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * maximum, then the minimum number of integer digits is fixed at one. 465ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 466ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>The maximum number of integer digits, if present, specifies the exponent 467ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * grouping. The most common use of this is to generate <em>engineering 468ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * notation</em>, in which the exponent is a multiple of three, e.g., 469ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * "##0.###E0". The number 12345 is formatted using "##0.####E0" as "12.345E3". 470ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 471ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>When using scientific notation, the formatter controls the 472ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * digit counts using significant digits logic. The maximum number of 473ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * significant digits limits the total number of integer and fraction 474ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * digits that will be shown in the mantissa; it does not affect 475ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * parsing. For example, 12345 formatted with "##0.##E0" is "12.3E3". 476ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * See the section on significant digits for more details. 477ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 478ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>The number of significant digits shown is determined as 479ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * follows: If areSignificantDigitsUsed() returns false, then the 480ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * minimum number of significant digits shown is one, and the maximum 481ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * number of significant digits shown is the sum of the <em>minimum 482ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * integer</em> and <em>maximum fraction</em> digits, and is 483ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * unaffected by the maximum integer digits. If this sum is zero, 484ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * then all significant digits are shown. If 485ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * areSignificantDigitsUsed() returns true, then the significant digit 486ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * counts are specified by getMinimumSignificantDigits() and 487ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * getMaximumSignificantDigits(). In this case, the number of 488ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * integer digits is fixed at one, and there is no exponent grouping. 489ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 490ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>Exponential patterns may not contain grouping separators. 491ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * </ul> 492ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 493ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <a name="sigdig"><strong>Significant Digits</strong></a> 494ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 495ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>DecimalFormat</code> has two ways of controlling how many 496ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * digits are shows: (a) significant digits counts, or (b) integer and 497ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * fraction digit counts. Integer and fraction digit counts are 498ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * described above. When a formatter is using significant digits 499ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * counts, the number of integer and fraction digits is not specified 500ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * directly, and the formatter settings for these counts are ignored. 501ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Instead, the formatter uses however many integer and fraction 502ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * digits are required to display the specified number of significant 503ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * digits. Examples: 504ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 505ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <table border=0 cellspacing=3 cellpadding=0> 506ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <tr bgcolor="#ccccff"> 507ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td align=left>Pattern 508ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td align=left>Minimum significant digits 509ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td align=left>Maximum significant digits 510ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td align=left>Number 511ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td align=left>Output of format() 512ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <tr valign=top> 513ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td><code>\@\@\@</code> 514ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>3 515ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>3 516ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>12345 517ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td><code>12300</code> 518ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <tr valign=top bgcolor="#eeeeff"> 519ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td><code>\@\@\@</code> 520ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>3 521ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>3 522ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>0.12345 523ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td><code>0.123</code> 524ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <tr valign=top> 525ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td><code>\@\@##</code> 526ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>2 527ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>4 528ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>3.14159 529ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td><code>3.142</code> 530ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <tr valign=top bgcolor="#eeeeff"> 531ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td><code>\@\@##</code> 532ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>2 533ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>4 534ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td>1.23004 535ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <td><code>1.23</code> 536ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * </table> 537ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 538ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <ul> 539ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>Significant digit counts may be expressed using patterns that 540ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * specify a minimum and maximum number of significant digits. These 541ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * are indicated by the <code>'@'</code> and <code>'#'</code> 542ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * characters. The minimum number of significant digits is the number 543ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * of <code>'@'</code> characters. The maximum number of significant 544ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * digits is the number of <code>'@'</code> characters plus the number 545ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * of <code>'#'</code> characters following on the right. For 546ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * example, the pattern <code>"@@@"</code> indicates exactly 3 547ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * significant digits. The pattern <code>"@##"</code> indicates from 548ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 1 to 3 significant digits. Trailing zero digits to the right of 549ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * the decimal separator are suppressed after the minimum number of 550ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * significant digits have been shown. For example, the pattern 551ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>"@##"</code> formats the number 0.1203 as 552ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>"0.12"</code>. 553ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 554ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>If a pattern uses significant digits, it may not contain a 555ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * decimal separator, nor the <code>'0'</code> pattern character. 556ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Patterns such as <code>"@00"</code> or <code>"@.###"</code> are 557ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * disallowed. 558ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 559ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>Any number of <code>'#'</code> characters may be prepended to 560ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * the left of the leftmost <code>'@'</code> character. These have no 561ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * effect on the minimum and maximum significant digits counts, but 562ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * may be used to position grouping separators. For example, 563ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>"#,#@#"</code> indicates a minimum of one significant digits, 564ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * a maximum of two significant digits, and a grouping size of three. 565ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 566ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>In order to enable significant digits formatting, use a pattern 567ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * containing the <code>'@'</code> pattern character. Alternatively, 568ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * call setSignificantDigitsUsed(TRUE). 569ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 570ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>In order to disable significant digits formatting, use a 571ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * pattern that does not contain the <code>'@'</code> pattern 572ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * character. Alternatively, call setSignificantDigitsUsed(FALSE). 573ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 574ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>The number of significant digits has no effect on parsing. 575ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 576ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>Significant digits may be used together with exponential notation. Such 577ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * patterns are equivalent to a normal exponential pattern with a minimum and 578ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * maximum integer digit count of one, a minimum fraction digit count of 579ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>getMinimumSignificantDigits() - 1</code>, and a maximum fraction digit 580ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * count of <code>getMaximumSignificantDigits() - 1</code>. For example, the 581ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * pattern <code>"@@###E0"</code> is equivalent to <code>"0.0###E0"</code>. 582ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 583ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>If signficant digits are in use, then the integer and fraction 584ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * digit counts, as set via the API, are ignored. If significant 585ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * digits are not in use, then the signficant digit counts, as set via 586ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * the API, are ignored. 587ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 588ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * </ul> 589ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 590ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p><strong>Padding</strong> 591ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 592ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>DecimalFormat supports padding the result of 593ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * format() to a specific width. Padding may be specified either 594ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * through the API or through the pattern syntax. In a pattern the pad escape 595ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * character, followed by a single pad character, causes padding to be parsed 596ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * and formatted. The pad escape character is '*' in unlocalized patterns, and 597ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * can be localized using DecimalFormatSymbols::setSymbol() with a 598ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * DecimalFormatSymbols::kPadEscapeSymbol 599ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * selector. For example, <code>"$*x#,##0.00"</code> formats 123 to 600ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>"$xx123.00"</code>, and 1234 to <code>"$1,234.00"</code>. 601ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 602ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <ul> 603ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>When padding is in effect, the width of the positive subpattern, 604ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * including prefix and suffix, determines the format width. For example, in 605ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * the pattern <code>"* #0 o''clock"</code>, the format width is 10. 606ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 607ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>The width is counted in 16-bit code units (UChars). 608ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 609ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>Some parameters which usually do not matter have meaning when padding is 610ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * used, because the pattern width is significant with padding. In the pattern 611ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * "* ##,##,#,##0.##", the format width is 14. The initial characters "##,##," 612ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * do not affect the grouping size or maximum integer digits, but they do affect 613ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * the format width. 614ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 615ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>Padding may be inserted at one of four locations: before the prefix, 616ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * after the prefix, before the suffix, or after the suffix. If padding is 617ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * specified in any other location, applyPattern() 618ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * sets a failing UErrorCode. If there is no prefix, 619ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * before the prefix and after the prefix are equivalent, likewise for the 620ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * suffix. 621ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 622ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>When specified in a pattern, the 32-bit code point immediately 623ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * following the pad escape is the pad character. This may be any character, 624ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * including a special pattern character. That is, the pad escape 625ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <em>escapes</em> the following character. If there is no character after 626ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * the pad escape, then the pattern is illegal. 627ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 628ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * </ul> 629ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 630ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p><strong>Rounding</strong> 631ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 632ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>DecimalFormat supports rounding to a specific increment. For 633ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * example, 1230 rounded to the nearest 50 is 1250. 1.234 rounded to the 634ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * nearest 0.65 is 1.3. The rounding increment may be specified through the API 635ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * or in a pattern. To specify a rounding increment in a pattern, include the 636ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * increment in the pattern itself. "#,#50" specifies a rounding increment of 637ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 50. "#,##0.05" specifies a rounding increment of 0.05. 638ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 63927f654740f2a26ad62a5c155af9199af9e69b889claireho * <p>In the absense of an explicit rounding increment numbers are 64027f654740f2a26ad62a5c155af9199af9e69b889claireho * rounded to their formatted width. 64127f654740f2a26ad62a5c155af9199af9e69b889claireho * 642ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <ul> 643ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>Rounding only affects the string produced by formatting. It does 644ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * not affect parsing or change any numerical values. 645ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 646ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>A <em>rounding mode</em> determines how values are rounded; see 64727f654740f2a26ad62a5c155af9199af9e69b889claireho * DecimalFormat::ERoundingMode. The default rounding mode is 64827f654740f2a26ad62a5c155af9199af9e69b889claireho * DecimalFormat::kRoundHalfEven. The rounding mode can only be set 64927f654740f2a26ad62a5c155af9199af9e69b889claireho * through the API; it can not be set with a pattern. 650ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 651ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>Some locales use rounding in their currency formats to reflect the 652ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * smallest currency denomination. 653ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 654ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>In a pattern, digits '1' through '9' specify rounding, but otherwise 655ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * behave identically to digit '0'. 656ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * </ul> 657ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 658ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p><strong>Synchronization</strong> 659ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 660ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>DecimalFormat objects are not synchronized. Multiple 661ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * threads should not access one formatter concurrently. 662ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 663ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p><strong>Subclassing</strong> 664ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 665ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p><em>User subclasses are not supported.</em> While clients may write 666ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * subclasses, such code will not necessarily work and will not be 667ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * guaranteed to work stably from release to release. 668ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 669ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass U_I18N_API DecimalFormat: public NumberFormat { 670ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic: 671ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 672ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Rounding mode. 673ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4 674ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 675ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru enum ERoundingMode { 676ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru kRoundCeiling, /**< Round towards positive infinity */ 677ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru kRoundFloor, /**< Round towards negative infinity */ 678ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru kRoundDown, /**< Round towards zero */ 679ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru kRoundUp, /**< Round away from zero */ 680ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru kRoundHalfEven, /**< Round towards the nearest integer, or 681ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru towards the nearest even integer if equidistant */ 682ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru kRoundHalfDown, /**< Round towards the nearest integer, or 683ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru towards zero if equidistant */ 684b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho kRoundHalfUp, /**< Round towards the nearest integer, or 685ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru away from zero if equidistant */ 686b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho /** 687fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * Return U_FORMAT_INEXACT_ERROR if number does not format exactly. 688fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * @stable ICU 4.8 689b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho */ 690103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius kRoundUnnecessary 691ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru }; 692ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 693ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 694ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Pad position. 695ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4 696ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 697ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru enum EPadPosition { 698ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru kPadBeforePrefix, 699ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru kPadAfterPrefix, 700ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru kPadBeforeSuffix, 701ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru kPadAfterSuffix 702ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru }; 703ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 704ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 705ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Create a DecimalFormat using the default pattern and symbols 706ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * for the default locale. This is a convenient way to obtain a 707ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * DecimalFormat when internationalization is not the main concern. 708ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <P> 709ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * To obtain standard formats for a given locale, use the factory methods 710ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * on NumberFormat such as createInstance. These factories will 711ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * return the most appropriate sub-class of NumberFormat for a given 712ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * locale. 713ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param status Output param set to success/failure code. If the 714ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * pattern is invalid this will be set to a failure code. 715ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 716ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 717ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru DecimalFormat(UErrorCode& status); 718ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 719ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 720ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Create a DecimalFormat from the given pattern and the symbols 721ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * for the default locale. This is a convenient way to obtain a 722ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * DecimalFormat when internationalization is not the main concern. 723ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <P> 724ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * To obtain standard formats for a given locale, use the factory methods 725ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * on NumberFormat such as createInstance. These factories will 726ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * return the most appropriate sub-class of NumberFormat for a given 727ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * locale. 728ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param pattern A non-localized pattern string. 729ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param status Output param set to success/failure code. If the 730ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * pattern is invalid this will be set to a failure code. 731ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 732ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 733ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru DecimalFormat(const UnicodeString& pattern, 734ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UErrorCode& status); 735ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 736ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 737ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Create a DecimalFormat from the given pattern and symbols. 738ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Use this constructor when you need to completely customize the 739ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * behavior of the format. 740ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <P> 741ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * To obtain standard formats for a given 742ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * locale, use the factory methods on NumberFormat such as 743ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * createInstance or createCurrencyInstance. If you need only minor adjustments 744ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * to a standard format, you can modify the format returned by 745ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * a NumberFormat factory method. 746ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 747ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param pattern a non-localized pattern string 748ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param symbolsToAdopt the set of symbols to be used. The caller should not 749ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * delete this object after making this call. 750ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param status Output param set to success/failure code. If the 751ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * pattern is invalid this will be set to a failure code. 752ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 753ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 754ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru DecimalFormat( const UnicodeString& pattern, 755ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru DecimalFormatSymbols* symbolsToAdopt, 756ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UErrorCode& status); 757ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 758103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_HIDE_INTERNAL_API 759ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 76085bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * This API is for ICU use only. 76185bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * Create a DecimalFormat from the given pattern, symbols, and style. 76285bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * 76385bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * @param pattern a non-localized pattern string 76485bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * @param symbolsToAdopt the set of symbols to be used. The caller should not 76585bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * delete this object after making this call. 766b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * @param style style of decimal format 76785bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * @param status Output param set to success/failure code. If the 76885bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * pattern is invalid this will be set to a failure code. 7698393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius * @internal 77085bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho */ 77185bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho DecimalFormat( const UnicodeString& pattern, 77285bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho DecimalFormatSymbols* symbolsToAdopt, 773b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho UNumberFormatStyle style, 77485bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho UErrorCode& status); 77585bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho 7768393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius#if UCONFIG_HAVE_PARSEALLINPUT 7778393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius /** 7788393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius * @internal 7798393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius */ 7808393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius void setParseAllInput(UNumberFormatAttributeValue value); 7818393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius#endif 7828393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius 7838393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius#endif /* U_HIDE_INTERNAL_API */ 7848393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius 785103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius 78654dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius /** 78754dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * Set an integer attribute on this DecimalFormat. 78854dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * May return U_UNSUPPORTED_ERROR if this instance does not support 78954dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * the specified attribute. 79054dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * @param attr the attribute to set 79154dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * @param newvalue new value 79254dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * @param status the error type 7938393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius * @return *this - for chaining (example: format.setAttribute(...).setAttribute(...) ) 794fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * @stable ICU 51 79554dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius */ 79654dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius virtual DecimalFormat& setAttribute( UNumberFormatAttribute attr, 79754dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius int32_t newvalue, 79854dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius UErrorCode &status); 79954dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius 80054dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius /** 80154dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * Get an integer 80254dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * May return U_UNSUPPORTED_ERROR if this instance does not support 80354dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * the specified attribute. 80454dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * @param attr the attribute to set 80554dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * @param status the error type 80654dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * @return the attribute value. Undefined if there is an error. 807fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * @stable ICU 51 80854dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius */ 80954dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius virtual int32_t getAttribute( UNumberFormatAttribute attr, 81054dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius UErrorCode &status) const; 81154dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius 8128de051c3d18a56cc126f0f44e368495a52f9148cFredrik Roubert 813fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius /** 814fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * Set whether or not grouping will be used in this format. 815fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * @param newValue True, grouping will be used in this format. 816fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * @see getGroupingUsed 8171b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert * @stable ICU 53 818fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius */ 819fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius virtual void setGroupingUsed(UBool newValue); 820fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius 821fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius /** 822fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * Sets whether or not numbers should be parsed as integers only. 823fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * @param value set True, this format will parse numbers as integers 824fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * only. 825fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * @see isParseIntegerOnly 8261b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert * @stable ICU 53 827fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius */ 828fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius virtual void setParseIntegerOnly(UBool value); 829103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius 830fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius /** 831fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * Set a particular UDisplayContext value in the formatter, such as 832fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * UDISPCTX_CAPITALIZATION_FOR_STANDALONE. 833fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * @param value The UDisplayContext value to set. 834fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * @param status Input/output status. If at entry this indicates a failure 835fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * status, the function will do nothing; otherwise this will be 8368de051c3d18a56cc126f0f44e368495a52f9148cFredrik Roubert * updated with any new status from the function. 8371b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert * @stable ICU 53 838fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius */ 839fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius virtual void setContext(UDisplayContext value, UErrorCode& status); 840103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius 84185bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho /** 842ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Create a DecimalFormat from the given pattern and symbols. 843ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Use this constructor when you need to completely customize the 844ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * behavior of the format. 845ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <P> 846ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * To obtain standard formats for a given 847ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * locale, use the factory methods on NumberFormat such as 848ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * createInstance or createCurrencyInstance. If you need only minor adjustments 849ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * to a standard format, you can modify the format returned by 850ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * a NumberFormat factory method. 851ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 852ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param pattern a non-localized pattern string 853ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param symbolsToAdopt the set of symbols to be used. The caller should not 854ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * delete this object after making this call. 85550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param parseError Output param to receive errors occured during parsing 856ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param status Output param set to success/failure code. If the 857ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * pattern is invalid this will be set to a failure code. 858ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 859ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 860ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru DecimalFormat( const UnicodeString& pattern, 861ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru DecimalFormatSymbols* symbolsToAdopt, 862ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UParseError& parseError, 863ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UErrorCode& status); 864ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 865ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Create a DecimalFormat from the given pattern and symbols. 866ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Use this constructor when you need to completely customize the 867ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * behavior of the format. 868ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <P> 869ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * To obtain standard formats for a given 870ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * locale, use the factory methods on NumberFormat such as 871ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * createInstance or createCurrencyInstance. If you need only minor adjustments 872ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * to a standard format, you can modify the format returned by 873ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * a NumberFormat factory method. 874ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 875ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param pattern a non-localized pattern string 876ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param symbols the set of symbols to be used 877ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param status Output param set to success/failure code. If the 878ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * pattern is invalid this will be set to a failure code. 879ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 880ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 881ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru DecimalFormat( const UnicodeString& pattern, 882ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const DecimalFormatSymbols& symbols, 883ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UErrorCode& status); 884ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 885ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 886ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Copy constructor. 88750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 888ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param source the DecimalFormat object to be copied from. 889ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 890ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 891ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru DecimalFormat(const DecimalFormat& source); 892ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 893ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 894ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Assignment operator. 895ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 896ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param rhs the DecimalFormat object to be copied. 897ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 898ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 899ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru DecimalFormat& operator=(const DecimalFormat& rhs); 900ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 901ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 902ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Destructor. 903ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 904ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 905ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual ~DecimalFormat(); 906ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 907ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 908ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Clone this Format object polymorphically. The caller owns the 909ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * result and should delete it when done. 910ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 911ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return a polymorphic copy of this DecimalFormat. 912ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 913ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 914ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual Format* clone(void) const; 915ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 916ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 917ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Return true if the given Format objects are semantically equal. 918ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Objects of different subclasses are considered unequal. 919ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 920ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param other the object to be compared with. 921ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return true if the given Format objects are semantically equal. 922ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 923ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 924ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual UBool operator==(const Format& other) const; 925ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 92650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 92750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho using NumberFormat::format; 92850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 929ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 930ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Format a double or long number using base-10 representation. 931ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 932ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param number The value to be formatted. 933ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param appendTo Output parameter to receive result. 934ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Result is appended to existing contents. 935ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param pos On input: an alignment field, if desired. 936ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * On output: the offsets of the alignment field. 937ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return Reference to 'appendTo' parameter. 938ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 93950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho */ 940ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual UnicodeString& format(double number, 941ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UnicodeString& appendTo, 942ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru FieldPosition& pos) const; 9437c971b21cb09c84a9bd948bdf2918b727d46992cJean-Baptiste Queru 94454dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius 94554dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius /** 94654dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * Format a double or long number using base-10 representation. 94754dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * 94854dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * @param number The value to be formatted. 94954dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * @param appendTo Output parameter to receive result. 95054dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * Result is appended to existing contents. 95154dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * @param pos On input: an alignment field, if desired. 95254dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * On output: the offsets of the alignment field. 95354dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * @param status 95454dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * @return Reference to 'appendTo' parameter. 95554dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * @internal 95654dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius */ 95754dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius virtual UnicodeString& format(double number, 95854dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius UnicodeString& appendTo, 95954dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius FieldPosition& pos, 96054dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius UErrorCode &status) const; 96154dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius 96250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho /** 96350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Format a double or long number using base-10 representation. 96450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 96550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param number The value to be formatted. 96650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param appendTo Output parameter to receive result. 96750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Result is appended to existing contents. 96850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param posIter On return, can be used to iterate over positions 96950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * of fields generated by this format call. 97050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Can be NULL. 97150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param status Output param filled with success/failure status. 97250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @return Reference to 'appendTo' parameter. 97364339d36f8bd4db5025fe2988eda22b491a9219cFredrik Roubert * @stable ICU 4.4 97450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho */ 9757c971b21cb09c84a9bd948bdf2918b727d46992cJean-Baptiste Queru virtual UnicodeString& format(double number, 9767c971b21cb09c84a9bd948bdf2918b727d46992cJean-Baptiste Queru UnicodeString& appendTo, 97750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho FieldPositionIterator* posIter, 97850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho UErrorCode& status) const; 9797c971b21cb09c84a9bd948bdf2918b727d46992cJean-Baptiste Queru 980ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 981ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Format a long number using base-10 representation. 982ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 983ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param number The value to be formatted. 984ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param appendTo Output parameter to receive result. 985ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Result is appended to existing contents. 986ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param pos On input: an alignment field, if desired. 987ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * On output: the offsets of the alignment field. 988ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return Reference to 'appendTo' parameter. 989ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 990ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 991ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual UnicodeString& format(int32_t number, 992ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UnicodeString& appendTo, 993ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru FieldPosition& pos) const; 9947c971b21cb09c84a9bd948bdf2918b727d46992cJean-Baptiste Queru 99550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho /** 99650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Format a long number using base-10 representation. 99750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 99850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param number The value to be formatted. 99950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param appendTo Output parameter to receive result. 100050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Result is appended to existing contents. 100154dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * @param pos On input: an alignment field, if desired. 100254dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * On output: the offsets of the alignment field. 100354dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * @return Reference to 'appendTo' parameter. 100454dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * @internal 100554dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius */ 100654dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius virtual UnicodeString& format(int32_t number, 100754dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius UnicodeString& appendTo, 100854dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius FieldPosition& pos, 100954dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius UErrorCode &status) const; 101054dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius 101154dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius /** 101254dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * Format a long number using base-10 representation. 101354dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * 101454dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * @param number The value to be formatted. 101554dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * @param appendTo Output parameter to receive result. 101654dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * Result is appended to existing contents. 101750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param posIter On return, can be used to iterate over positions 101850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * of fields generated by this format call. 101950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Can be NULL. 102050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param status Output param filled with success/failure status. 102150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @return Reference to 'appendTo' parameter. 102264339d36f8bd4db5025fe2988eda22b491a9219cFredrik Roubert * @stable ICU 4.4 102350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho */ 10247c971b21cb09c84a9bd948bdf2918b727d46992cJean-Baptiste Queru virtual UnicodeString& format(int32_t number, 10257c971b21cb09c84a9bd948bdf2918b727d46992cJean-Baptiste Queru UnicodeString& appendTo, 102650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho FieldPositionIterator* posIter, 102750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho UErrorCode& status) const; 10287c971b21cb09c84a9bd948bdf2918b727d46992cJean-Baptiste Queru 1029ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1030ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Format an int64 number using base-10 representation. 1031ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 1032ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param number The value to be formatted. 1033ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param appendTo Output parameter to receive result. 1034ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Result is appended to existing contents. 1035ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param pos On input: an alignment field, if desired. 1036ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * On output: the offsets of the alignment field. 1037ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return Reference to 'appendTo' parameter. 1038ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.8 1039ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1040ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual UnicodeString& format(int64_t number, 1041ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UnicodeString& appendTo, 1042ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru FieldPosition& pos) const; 1043ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1044b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 104550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Format an int64 number using base-10 representation. 104650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 104750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param number The value to be formatted. 104850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param appendTo Output parameter to receive result. 104950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Result is appended to existing contents. 105054dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * @param pos On input: an alignment field, if desired. 105154dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * On output: the offsets of the alignment field. 105254dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * @return Reference to 'appendTo' parameter. 105354dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * @internal 105454dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius */ 105554dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius virtual UnicodeString& format(int64_t number, 105654dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius UnicodeString& appendTo, 105754dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius FieldPosition& pos, 105854dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius UErrorCode &status) const; 105954dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius 106054dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius /** 106154dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * Format an int64 number using base-10 representation. 106254dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * 106354dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * @param number The value to be formatted. 106454dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * @param appendTo Output parameter to receive result. 106554dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * Result is appended to existing contents. 106650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param posIter On return, can be used to iterate over positions 106750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * of fields generated by this format call. 106850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Can be NULL. 106950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param status Output param filled with success/failure status. 107050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @return Reference to 'appendTo' parameter. 107164339d36f8bd4db5025fe2988eda22b491a9219cFredrik Roubert * @stable ICU 4.4 107250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho */ 10737c971b21cb09c84a9bd948bdf2918b727d46992cJean-Baptiste Queru virtual UnicodeString& format(int64_t number, 10747c971b21cb09c84a9bd948bdf2918b727d46992cJean-Baptiste Queru UnicodeString& appendTo, 107550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho FieldPositionIterator* posIter, 107650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho UErrorCode& status) const; 107750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 107850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho /** 107950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Format a decimal number. 108050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * The syntax of the unformatted number is a "numeric string" 108150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * as defined in the Decimal Arithmetic Specification, available at 108250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * http://speleotrove.com/decimal 108350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 108450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param number The unformatted number, as a string. 108550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param appendTo Output parameter to receive result. 108650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Result is appended to existing contents. 108750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param posIter On return, can be used to iterate over positions 108850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * of fields generated by this format call. 108950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Can be NULL. 109050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param status Output param filled with success/failure status. 109150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @return Reference to 'appendTo' parameter. 109264339d36f8bd4db5025fe2988eda22b491a9219cFredrik Roubert * @stable ICU 4.4 109350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho */ 109464339d36f8bd4db5025fe2988eda22b491a9219cFredrik Roubert virtual UnicodeString& format(StringPiece number, 109550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho UnicodeString& appendTo, 109650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho FieldPositionIterator* posIter, 109750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho UErrorCode& status) const; 109850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 109950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 110050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho /** 1101fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * Format a decimal number. 110250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * The number is a DigitList wrapper onto a floating point decimal number. 110350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * The default implementation in NumberFormat converts the decimal number 110450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * to a double and formats that. 110550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 110650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param number The number, a DigitList format Decimal Floating Point. 110750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param appendTo Output parameter to receive result. 110850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Result is appended to existing contents. 110950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param posIter On return, can be used to iterate over positions 111050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * of fields generated by this format call. 111150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param status Output param filled with success/failure status. 111250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @return Reference to 'appendTo' parameter. 111350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @internal 111450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho */ 111550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho virtual UnicodeString& format(const DigitList &number, 111650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho UnicodeString& appendTo, 111750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho FieldPositionIterator* posIter, 111850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho UErrorCode& status) const; 111950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 112050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho /** 1121fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * Format a decimal number. 1122c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * @param number The number 1123c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * @param appendTo Output parameter to receive result. 1124c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * Result is appended to existing contents. 1125c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * @param pos On input: an alignment field, if desired. 1126c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * On output: the offsets of the alignment field. 1127c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * @param status Output param filled with success/failure status. 1128c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * @return Reference to 'appendTo' parameter. 1129c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * @internal 1130c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert */ 1131c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert virtual UnicodeString& format( 1132c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert const VisibleDigitsWithExponent &number, 1133c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert UnicodeString& appendTo, 1134c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert FieldPosition& pos, 1135c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert UErrorCode& status) const; 1136c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert 1137c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert /** 1138c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * Format a decimal number. 1139c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * @param number The number 1140c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * @param appendTo Output parameter to receive result. 1141c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * Result is appended to existing contents. 1142c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * @param posIter On return, can be used to iterate over positions 1143c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * of fields generated by this format call. 1144c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * @param status Output param filled with success/failure status. 1145c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * @return Reference to 'appendTo' parameter. 1146c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * @internal 1147c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert */ 1148c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert virtual UnicodeString& format( 1149c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert const VisibleDigitsWithExponent &number, 1150c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert UnicodeString& appendTo, 1151c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert FieldPositionIterator* posIter, 1152c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert UErrorCode& status) const; 1153c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert 1154c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert /** 1155c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * Format a decimal number. 115650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * The number is a DigitList wrapper onto a floating point decimal number. 115750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * The default implementation in NumberFormat converts the decimal number 1158fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * to a double and formats that. 115950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 116050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param number The number, a DigitList format Decimal Floating Point. 116150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param appendTo Output parameter to receive result. 116250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Result is appended to existing contents. 116350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param pos On input: an alignment field, if desired. 116450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * On output: the offsets of the alignment field. 116550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param status Output param filled with success/failure status. 116650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @return Reference to 'appendTo' parameter. 116750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @internal 116850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho */ 116950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho virtual UnicodeString& format(const DigitList &number, 117050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho UnicodeString& appendTo, 11717c971b21cb09c84a9bd948bdf2918b727d46992cJean-Baptiste Queru FieldPosition& pos, 117250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho UErrorCode& status) const; 117350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 117459d709d503bab6e2b61931737e662dd293b40578ccornelius using NumberFormat::parse; 11757c971b21cb09c84a9bd948bdf2918b727d46992cJean-Baptiste Queru 1176ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1177ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Parse the given string using this object's choices. The method 1178ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * does string comparisons to try to find an optimal match. 1179ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * If no object can be parsed, index is unchanged, and NULL is 1180ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * returned. The result is returned as the most parsimonious 1181ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * type of Formattable that will accomodate all of the 1182ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * necessary precision. For example, if the result is exactly 12, 1183ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * it will be returned as a long. However, if it is 1.5, it will 1184ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * be returned as a double. 1185ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 1186ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param text The text to be parsed. 1187ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param result Formattable to be set to the parse result. 1188ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * If parse fails, return contents are undefined. 1189ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param parsePosition The position to start parsing at on input. 1190ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * On output, moved to after the last successfully 1191ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * parse character. On parse failure, does not change. 1192ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see Formattable 1193ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1194ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1195ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void parse(const UnicodeString& text, 1196ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru Formattable& result, 1197ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ParsePosition& parsePosition) const; 1198ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1199ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1200ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Parses text from the given string as a currency amount. Unlike 1201ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * the parse() method, this method will attempt to parse a generic 1202ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * currency name, searching for a match of this object's locale's 1203ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * currency display names, or for a 3-letter ISO currency code. 1204ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * This method will fail if this format is not a currency format, 1205ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * that is, if it does not contain the currency pattern symbol 1206ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * (U+00A4) in its prefix or suffix. 1207ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 1208ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param text the string to parse 1209103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @param pos input-output position; on input, the position within text 1210103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * to match; must have 0 <= pos.getIndex() < text.length(); 1211103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * on output, the position after the last matched character. 1212103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * If the parse fails, the position in unchanged upon output. 1213103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @return if parse succeeds, a pointer to a newly-created CurrencyAmount 1214103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * object (owned by the caller) containing information about 1215103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * the parsed currency; if parse fails, this is NULL. 12168393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius * @stable ICU 49 1217ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1218103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius virtual CurrencyAmount* parseCurrency(const UnicodeString& text, 1219103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius ParsePosition& pos) const; 1220ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1221ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1222ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Returns the decimal format symbols, which is generally not changed 1223ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * by the programmer or user. 1224ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return desired DecimalFormatSymbols 1225ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see DecimalFormatSymbols 1226ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1227ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1228ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual const DecimalFormatSymbols* getDecimalFormatSymbols(void) const; 1229ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1230ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1231ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Sets the decimal format symbols, which is generally not changed 1232ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * by the programmer or user. 1233ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param symbolsToAdopt DecimalFormatSymbols to be adopted. 1234ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1235ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1236ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void adoptDecimalFormatSymbols(DecimalFormatSymbols* symbolsToAdopt); 1237ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1238ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1239ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Sets the decimal format symbols, which is generally not changed 1240ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * by the programmer or user. 1241ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param symbols DecimalFormatSymbols. 1242ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1243ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1244ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void setDecimalFormatSymbols(const DecimalFormatSymbols& symbols); 1245ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1246ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1247ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 124850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Returns the currency plural format information, 124985bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * which is generally not changed by the programmer or user. 125085bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * @return desired CurrencyPluralInfo 125150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @stable ICU 4.2 125285bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho */ 125385bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho virtual const CurrencyPluralInfo* getCurrencyPluralInfo(void) const; 125485bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho 125585bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho /** 125650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Sets the currency plural format information, 125785bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * which is generally not changed by the programmer or user. 125885bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * @param toAdopt CurrencyPluralInfo to be adopted. 125950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @stable ICU 4.2 126085bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho */ 126185bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho virtual void adoptCurrencyPluralInfo(CurrencyPluralInfo* toAdopt); 126285bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho 126385bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho /** 126450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Sets the currency plural format information, 126585bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * which is generally not changed by the programmer or user. 126685bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * @param info Currency Plural Info. 126750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @stable ICU 4.2 126885bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho */ 126985bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho virtual void setCurrencyPluralInfo(const CurrencyPluralInfo& info); 127085bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho 127185bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho 127285bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho /** 1273ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Get the positive prefix. 1274ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 1275ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param result Output param which will receive the positive prefix. 1276ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return A reference to 'result'. 1277ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Examples: +123, $123, sFr123 1278ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1279ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1280ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UnicodeString& getPositivePrefix(UnicodeString& result) const; 1281ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1282ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1283ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Set the positive prefix. 1284ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 1285ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param newValue the new value of the the positive prefix to be set. 1286ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Examples: +123, $123, sFr123 1287ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1288ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1289ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void setPositivePrefix(const UnicodeString& newValue); 1290ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1291ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1292ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Get the negative prefix. 1293ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 1294ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param result Output param which will receive the negative prefix. 1295ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return A reference to 'result'. 1296ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Examples: -123, ($123) (with negative suffix), sFr-123 1297ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1298ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1299ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UnicodeString& getNegativePrefix(UnicodeString& result) const; 1300ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1301ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1302ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Set the negative prefix. 1303ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 1304ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param newValue the new value of the the negative prefix to be set. 1305ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Examples: -123, ($123) (with negative suffix), sFr-123 1306ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1307ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1308ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void setNegativePrefix(const UnicodeString& newValue); 1309ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1310ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1311ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Get the positive suffix. 1312ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 1313ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param result Output param which will receive the positive suffix. 1314ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return A reference to 'result'. 1315ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Example: 123% 1316ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1317ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1318ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UnicodeString& getPositiveSuffix(UnicodeString& result) const; 1319ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1320ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1321ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Set the positive suffix. 1322ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 1323ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param newValue the new value of the positive suffix to be set. 1324ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Example: 123% 1325ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1326ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1327ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void setPositiveSuffix(const UnicodeString& newValue); 1328ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1329ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1330ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Get the negative suffix. 1331ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 1332ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param result Output param which will receive the negative suffix. 1333ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return A reference to 'result'. 1334ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Examples: -123%, ($123) (with positive suffixes) 1335ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1336ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1337ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UnicodeString& getNegativeSuffix(UnicodeString& result) const; 1338ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1339ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1340ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Set the negative suffix. 1341ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 1342ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param newValue the new value of the negative suffix to be set. 1343ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Examples: 123% 1344ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1345ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1346ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void setNegativeSuffix(const UnicodeString& newValue); 1347ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1348ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1349ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Get the multiplier for use in percent, permill, etc. 1350ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * For a percentage, set the suffixes to have "%" and the multiplier to be 100. 1351ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * (For Arabic, use arabic percent symbol). 1352ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * For a permill, set the suffixes to have "\\u2031" and the multiplier to be 1000. 1353ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 1354ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return the multiplier for use in percent, permill, etc. 1355ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Examples: with 100, 1.23 -> "123", and "123" -> 1.23 1356ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1357ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1358ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t getMultiplier(void) const; 1359ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1360ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1361ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Set the multiplier for use in percent, permill, etc. 1362ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * For a percentage, set the suffixes to have "%" and the multiplier to be 100. 1363ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * (For Arabic, use arabic percent symbol). 1364ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * For a permill, set the suffixes to have "\\u2031" and the multiplier to be 1000. 1365ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 1366ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param newValue the new value of the multiplier for use in percent, permill, etc. 1367ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Examples: with 100, 1.23 -> "123", and "123" -> 1.23 1368ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1369ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1370ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void setMultiplier(int32_t newValue); 1371ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1372ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1373ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Get the rounding increment. 137459d709d503bab6e2b61931737e662dd293b40578ccornelius * @return A positive rounding increment, or 0.0 if a custom rounding 137527f654740f2a26ad62a5c155af9199af9e69b889claireho * increment is not in effect. 1376ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #setRoundingIncrement 1377ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #getRoundingMode 1378ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #setRoundingMode 1379ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1380ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1381ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual double getRoundingIncrement(void) const; 1382ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1383ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 138427f654740f2a26ad62a5c155af9199af9e69b889claireho * Set the rounding increment. In the absence of a rounding increment, 138527f654740f2a26ad62a5c155af9199af9e69b889claireho * numbers will be rounded to the number of digits displayed. 138659d709d503bab6e2b61931737e662dd293b40578ccornelius * @param newValue A positive rounding increment, or 0.0 to 138759d709d503bab6e2b61931737e662dd293b40578ccornelius * use the default rounding increment. 1388ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Negative increments are equivalent to 0.0. 1389ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #getRoundingIncrement 1390ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #getRoundingMode 1391ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #setRoundingMode 1392ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1393ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1394ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void setRoundingIncrement(double newValue); 1395ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1396ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1397ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Get the rounding mode. 1398ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return A rounding mode 1399ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #setRoundingIncrement 1400ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #getRoundingIncrement 1401ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #setRoundingMode 1402ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1403ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1404ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual ERoundingMode getRoundingMode(void) const; 1405ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1406ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1407fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * Set the rounding mode. 1408ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param roundingMode A rounding mode 1409ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #setRoundingIncrement 1410ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #getRoundingIncrement 1411ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #getRoundingMode 1412ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1413ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1414ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void setRoundingMode(ERoundingMode roundingMode); 1415ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1416ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1417ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Get the width to which the output of format() is padded. 1418ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * The width is counted in 16-bit code units. 1419ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return the format width, or zero if no padding is in effect 1420ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #setFormatWidth 1421ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #getPadCharacterString 1422ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #setPadCharacter 1423ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #getPadPosition 1424ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #setPadPosition 1425ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1426ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1427ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual int32_t getFormatWidth(void) const; 1428ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1429ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1430ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Set the width to which the output of format() is padded. 1431ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * The width is counted in 16-bit code units. 1432ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * This method also controls whether padding is enabled. 1433ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param width the width to which to pad the result of 1434ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * format(), or zero to disable padding. A negative 1435ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * width is equivalent to 0. 1436ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #getFormatWidth 1437ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #getPadCharacterString 1438ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #setPadCharacter 1439ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #getPadPosition 1440ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #setPadPosition 1441ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1442ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1443ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void setFormatWidth(int32_t width); 1444ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1445ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1446ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Get the pad character used to pad to the format width. The 1447ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * default is ' '. 1448ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return a string containing the pad character. This will always 1449ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * have a length of one 32-bit code point. 1450ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #setFormatWidth 1451ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #getFormatWidth 1452ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #setPadCharacter 1453ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #getPadPosition 1454ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #setPadPosition 1455ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1456ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1457ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual UnicodeString getPadCharacterString() const; 1458ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1459ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1460ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Set the character used to pad to the format width. If padding 1461ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * is not enabled, then this will take effect if padding is later 1462ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * enabled. 1463ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param padChar a string containing the pad charcter. If the string 1464ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * has length 0, then the pad characer is set to ' '. Otherwise 1465ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * padChar.char32At(0) will be used as the pad character. 1466ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #setFormatWidth 1467ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #getFormatWidth 1468ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #getPadCharacterString 1469ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #getPadPosition 1470ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #setPadPosition 1471ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1472ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1473ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void setPadCharacter(const UnicodeString &padChar); 1474ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1475ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1476ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Get the position at which padding will take place. This is the location 1477ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * at which padding will be inserted if the result of format() 1478ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * is shorter than the format width. 1479ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return the pad position, one of kPadBeforePrefix, 1480ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * kPadAfterPrefix, kPadBeforeSuffix, or 1481ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * kPadAfterSuffix. 1482ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #setFormatWidth 1483ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #getFormatWidth 1484ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #setPadCharacter 1485ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #getPadCharacterString 1486ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #setPadPosition 148785bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * @see #EPadPosition 1488ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1489ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1490ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual EPadPosition getPadPosition(void) const; 1491ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1492ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1493ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Set the position at which padding will take place. This is the location 1494ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * at which padding will be inserted if the result of format() 1495ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * is shorter than the format width. This has no effect unless padding is 1496ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * enabled. 1497ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param padPos the pad position, one of kPadBeforePrefix, 1498ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * kPadAfterPrefix, kPadBeforeSuffix, or 1499ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * kPadAfterSuffix. 1500ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #setFormatWidth 1501ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #getFormatWidth 1502ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #setPadCharacter 1503ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #getPadCharacterString 1504ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #getPadPosition 150585bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * @see #EPadPosition 1506ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1507ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1508ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void setPadPosition(EPadPosition padPos); 1509ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1510ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1511ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Return whether or not scientific notation is used. 1512ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return TRUE if this object formats and parses scientific notation 1513ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #setScientificNotation 1514ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #getMinimumExponentDigits 1515ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #setMinimumExponentDigits 1516ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #isExponentSignAlwaysShown 1517ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #setExponentSignAlwaysShown 1518ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1519ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 152059d709d503bab6e2b61931737e662dd293b40578ccornelius virtual UBool isScientificNotation(void) const; 1521ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1522ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1523ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Set whether or not scientific notation is used. When scientific notation 1524ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * is used, the effective maximum number of integer digits is <= 8. If the 1525ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * maximum number of integer digits is set to more than 8, the effective 1526ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * maximum will be 1. This allows this call to generate a 'default' scientific 1527ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * number format without additional changes. 1528ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param useScientific TRUE if this object formats and parses scientific 1529ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * notation 1530ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #isScientificNotation 1531ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #getMinimumExponentDigits 1532ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #setMinimumExponentDigits 1533ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #isExponentSignAlwaysShown 1534ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #setExponentSignAlwaysShown 1535ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1536ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1537ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void setScientificNotation(UBool useScientific); 1538ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1539ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1540ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Return the minimum exponent digits that will be shown. 1541ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return the minimum exponent digits that will be shown 1542ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #setScientificNotation 1543ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #isScientificNotation 1544ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #setMinimumExponentDigits 1545ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #isExponentSignAlwaysShown 1546ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #setExponentSignAlwaysShown 1547ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1548ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1549ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual int8_t getMinimumExponentDigits(void) const; 1550ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1551ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1552ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Set the minimum exponent digits that will be shown. This has no 1553ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * effect unless scientific notation is in use. 1554ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param minExpDig a value >= 1 indicating the fewest exponent digits 1555ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * that will be shown. Values less than 1 will be treated as 1. 1556ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #setScientificNotation 1557ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #isScientificNotation 1558ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #getMinimumExponentDigits 1559ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #isExponentSignAlwaysShown 1560ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #setExponentSignAlwaysShown 1561ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1562ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1563ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void setMinimumExponentDigits(int8_t minExpDig); 1564ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1565ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1566ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Return whether the exponent sign is always shown. 1567ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return TRUE if the exponent is always prefixed with either the 1568ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * localized minus sign or the localized plus sign, false if only negative 1569ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * exponents are prefixed with the localized minus sign. 1570ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #setScientificNotation 1571ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #isScientificNotation 1572ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #setMinimumExponentDigits 1573ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #getMinimumExponentDigits 1574ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #setExponentSignAlwaysShown 1575ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1576ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 157759d709d503bab6e2b61931737e662dd293b40578ccornelius virtual UBool isExponentSignAlwaysShown(void) const; 1578ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1579ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1580ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Set whether the exponent sign is always shown. This has no effect 1581ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * unless scientific notation is in use. 1582ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param expSignAlways TRUE if the exponent is always prefixed with either 1583ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * the localized minus sign or the localized plus sign, false if only 1584ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * negative exponents are prefixed with the localized minus sign. 1585ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #setScientificNotation 1586ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #isScientificNotation 1587ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #setMinimumExponentDigits 1588ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #getMinimumExponentDigits 1589ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #isExponentSignAlwaysShown 1590ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1591ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1592ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void setExponentSignAlwaysShown(UBool expSignAlways); 1593ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1594ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1595ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Return the grouping size. Grouping size is the number of digits between 1596ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * grouping separators in the integer portion of a number. For example, 1597ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * in the number "123,456.78", the grouping size is 3. 1598ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 1599ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return the grouping size. 1600ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see setGroupingSize 1601ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see NumberFormat::isGroupingUsed 1602ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see DecimalFormatSymbols::getGroupingSeparator 1603ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1604ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1605ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t getGroupingSize(void) const; 1606ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1607ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1608ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Set the grouping size. Grouping size is the number of digits between 1609ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * grouping separators in the integer portion of a number. For example, 1610ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * in the number "123,456.78", the grouping size is 3. 1611ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 1612ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param newValue the new value of the grouping size. 1613ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see getGroupingSize 1614ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see NumberFormat::setGroupingUsed 1615ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see DecimalFormatSymbols::setGroupingSeparator 1616ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1617ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1618ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void setGroupingSize(int32_t newValue); 1619ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1620ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1621ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Return the secondary grouping size. In some locales one 1622ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * grouping interval is used for the least significant integer 1623ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * digits (the primary grouping size), and another is used for all 1624ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * others (the secondary grouping size). A formatter supporting a 1625ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * secondary grouping size will return a positive integer unequal 1626ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * to the primary grouping size returned by 1627ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * getGroupingSize(). For example, if the primary 1628ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * grouping size is 4, and the secondary grouping size is 2, then 1629ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * the number 123456789 formats as "1,23,45,6789", and the pattern 1630ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * appears as "#,##,###0". 1631ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return the secondary grouping size, or a value less than 1632ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * one if there is none 1633ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see setSecondaryGroupingSize 1634ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see NumberFormat::isGroupingUsed 1635ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see DecimalFormatSymbols::getGroupingSeparator 1636ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4 1637ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1638ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t getSecondaryGroupingSize(void) const; 1639ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1640ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1641ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Set the secondary grouping size. If set to a value less than 1, 1642ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * then secondary grouping is turned off, and the primary grouping 1643ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * size is used for all intervals, not just the least significant. 1644ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 1645ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param newValue the new value of the secondary grouping size. 1646ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see getSecondaryGroupingSize 1647ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see NumberFormat#setGroupingUsed 1648ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see DecimalFormatSymbols::setGroupingSeparator 1649ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4 1650ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1651ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void setSecondaryGroupingSize(int32_t newValue); 1652ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1653c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert#ifndef U_HIDE_INTERNAL_API 1654c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert 1655c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert /** 1656c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * Returns the minimum number of grouping digits. 1657c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * Grouping separators are output if there are at least this many 1658c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * digits to the left of the first (rightmost) grouping separator, 1659c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * that is, there are at least (minimum grouping + grouping size) integer digits. 1660c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * (Subject to isGroupingUsed().) 1661c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * 1662c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * For example, if this value is 2, and the grouping size is 3, then 1663c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * 9999 -> "9999" and 10000 -> "10,000" 1664c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * 1665c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * This is a technology preview. This API may change behavior or may be removed. 1666c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * 1667c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * The default value for this attribute is 0. 1668c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * A value of 1, 0, or lower, means that the use of grouping separators 1669c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * only depends on the grouping size (and on isGroupingUsed()). 1670c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * Currently, the corresponding CLDR data is not used; this is likely to change. 1671c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * 1672c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * @see setMinimumGroupingDigits 1673c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * @see getGroupingSize 1674c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * @internal technology preview 1675c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert */ 1676c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert int32_t getMinimumGroupingDigits() const; 1677c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert 16788de051c3d18a56cc126f0f44e368495a52f9148cFredrik Roubert#endif /* U_HIDE_INTERNAL_API */ 16798de051c3d18a56cc126f0f44e368495a52f9148cFredrik Roubert 16808de051c3d18a56cc126f0f44e368495a52f9148cFredrik Roubert /* Cannot use #ifndef U_HIDE_INTERNAL_API for the following draft method since it is virtual. */ 1681c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert /** 1682c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * Sets the minimum grouping digits. Setting to a value less than or 1683c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * equal to 1 turns off minimum grouping digits. 1684c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * 1685c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * @param newValue the new value of minimum grouping digits. 1686c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * @see getMinimumGroupingDigits 1687c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * @internal technology preview 1688c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert */ 1689c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert virtual void setMinimumGroupingDigits(int32_t newValue); 1690c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert 1691c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert 1692ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1693ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Allows you to get the behavior of the decimal separator with integers. 1694ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * (The decimal separator will always appear with decimals.) 1695ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 1696ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return TRUE if the decimal separator always appear with decimals. 1697ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Example: Decimal ON: 12345 -> 12345.; OFF: 12345 -> 12345 1698ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1699ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1700ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UBool isDecimalSeparatorAlwaysShown(void) const; 1701ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1702ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1703ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Allows you to set the behavior of the decimal separator with integers. 1704ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * (The decimal separator will always appear with decimals.) 1705ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 1706ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param newValue set TRUE if the decimal separator will always appear with decimals. 1707ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Example: Decimal ON: 12345 -> 12345.; OFF: 12345 -> 12345 1708ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1709ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1710ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void setDecimalSeparatorAlwaysShown(UBool newValue); 1711ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1712f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius /** 1713f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius * Allows you to get the parse behavior of the pattern decimal mark. 1714f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius * 1715f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius * @return TRUE if input must contain a match to decimal mark in pattern 1716c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * @stable ICU 54 1717f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius */ 1718f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius UBool isDecimalPatternMatchRequired(void) const; 1719f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius 1720f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius /** 1721f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius * Allows you to set the behavior of the pattern decimal mark. 17228de051c3d18a56cc126f0f44e368495a52f9148cFredrik Roubert * 1723f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius * if TRUE, the input must have a decimal mark if one was specified in the pattern. When 1724f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius * FALSE the decimal mark may be omitted from the input. 1725f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius * 1726f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius * @param newValue set TRUE if input must contain a match to decimal mark in pattern 1727c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * @stable ICU 54 1728f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius */ 1729f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius virtual void setDecimalPatternMatchRequired(UBool newValue); 1730f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius 1731f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius 1732ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1733ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Synthesizes a pattern string that represents the current state 1734ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * of this Format object. 1735ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 1736ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param result Output param which will receive the pattern. 1737ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Previous contents are deleted. 1738ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return A reference to 'result'. 1739ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see applyPattern 1740ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1741ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1742ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual UnicodeString& toPattern(UnicodeString& result) const; 1743ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1744ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1745ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Synthesizes a localized pattern string that represents the current 1746ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * state of this Format object. 1747ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 1748ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param result Output param which will receive the localized pattern. 1749ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Previous contents are deleted. 1750ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return A reference to 'result'. 1751ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see applyPattern 1752ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1753ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1754ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual UnicodeString& toLocalizedPattern(UnicodeString& result) const; 175550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 1756ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1757ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Apply the given pattern to this Format object. A pattern is a 1758ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * short-hand specification for the various formatting properties. 1759ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * These properties can also be changed individually through the 1760ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * various setter methods. 1761ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <P> 1762ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * There is no limit to integer digits are set 1763ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * by this routine, since that is the typical end-user desire; 1764ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * use setMaximumInteger if you want to set a real value. 1765ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * For negative numbers, use a second pattern, separated by a semicolon 1766ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <pre> 1767ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * . Example "#,#00.0#" -> 1,234.56 1768ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * </pre> 1769ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * This means a minimum of 2 integer digits, 1 fraction digit, and 1770ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * a maximum of 2 fraction digits. 1771ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <pre> 1772ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * . Example: "#,#00.0#;(#,#00.0#)" for negatives in parantheses. 1773ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * </pre> 1774ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * In negative patterns, the minimum and maximum counts are ignored; 1775ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * these are presumed to be set in the positive pattern. 1776ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 1777ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param pattern The pattern to be applied. 177850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param parseError Struct to recieve information on position 1779ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * of error if an error is encountered 1780ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param status Output param set to success/failure code on 1781ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * exit. If the pattern is invalid, this will be 1782ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * set to a failure result. 1783ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1784ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1785ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void applyPattern(const UnicodeString& pattern, 1786ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UParseError& parseError, 1787ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UErrorCode& status); 1788ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1789ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Sets the pattern. 1790ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param pattern The pattern to be applied. 1791ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param status Output param set to success/failure code on 1792ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * exit. If the pattern is invalid, this will be 1793ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * set to a failure result. 1794ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 179550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho */ 1796ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void applyPattern(const UnicodeString& pattern, 1797ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UErrorCode& status); 1798ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1799ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1800ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Apply the given pattern to this Format object. The pattern 1801ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * is assumed to be in a localized notation. A pattern is a 1802ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * short-hand specification for the various formatting properties. 1803ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * These properties can also be changed individually through the 1804ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * various setter methods. 1805ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <P> 1806ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * There is no limit to integer digits are set 1807ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * by this routine, since that is the typical end-user desire; 1808ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * use setMaximumInteger if you want to set a real value. 1809ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * For negative numbers, use a second pattern, separated by a semicolon 1810ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <pre> 1811ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * . Example "#,#00.0#" -> 1,234.56 1812ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * </pre> 1813ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * This means a minimum of 2 integer digits, 1 fraction digit, and 1814ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * a maximum of 2 fraction digits. 1815ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 1816ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Example: "#,#00.0#;(#,#00.0#)" for negatives in parantheses. 1817ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 1818ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * In negative patterns, the minimum and maximum counts are ignored; 1819ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * these are presumed to be set in the positive pattern. 1820ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 1821ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param pattern The localized pattern to be applied. 182250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param parseError Struct to recieve information on position 1823ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * of error if an error is encountered 1824ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param status Output param set to success/failure code on 1825ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * exit. If the pattern is invalid, this will be 1826ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * set to a failure result. 1827ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1828ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1829ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void applyLocalizedPattern(const UnicodeString& pattern, 1830ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UParseError& parseError, 1831ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UErrorCode& status); 1832ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1833ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1834ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Apply the given pattern to this Format object. 1835ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 1836ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param pattern The localized pattern to be applied. 1837ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param status Output param set to success/failure code on 1838ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * exit. If the pattern is invalid, this will be 1839ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * set to a failure result. 1840ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1841ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1842ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void applyLocalizedPattern(const UnicodeString& pattern, 1843ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UErrorCode& status); 1844ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1845ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1846ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1847ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Sets the maximum number of digits allowed in the integer portion of a 1848ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * number. This override limits the integer digit count to 309. 1849ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 185050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param newValue the new value of the maximum number of digits 1851ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * allowed in the integer portion of a number. 1852ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see NumberFormat#setMaximumIntegerDigits 1853ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1854ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1855ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void setMaximumIntegerDigits(int32_t newValue); 1856ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1857ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1858ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Sets the minimum number of digits allowed in the integer portion of a 1859ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * number. This override limits the integer digit count to 309. 186050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 186150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param newValue the new value of the minimum number of digits 1862ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * allowed in the integer portion of a number. 1863ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see NumberFormat#setMinimumIntegerDigits 1864ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1865ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1866ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void setMinimumIntegerDigits(int32_t newValue); 1867ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1868ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1869ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Sets the maximum number of digits allowed in the fraction portion of a 1870ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * number. This override limits the fraction digit count to 340. 1871ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 187250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param newValue the new value of the maximum number of digits 1873ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * allowed in the fraction portion of a number. 1874ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see NumberFormat#setMaximumFractionDigits 1875ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1876ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1877ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void setMaximumFractionDigits(int32_t newValue); 1878ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1879ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1880ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Sets the minimum number of digits allowed in the fraction portion of a 1881ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * number. This override limits the fraction digit count to 340. 1882ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 188350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param newValue the new value of the minimum number of digits 1884ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * allowed in the fraction portion of a number. 1885ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see NumberFormat#setMinimumFractionDigits 1886ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1887ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1888ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void setMinimumFractionDigits(int32_t newValue); 1889ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1890ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1891ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Returns the minimum number of significant digits that will be 1892ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * displayed. This value has no effect unless areSignificantDigitsUsed() 1893ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * returns true. 1894ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return the fewest significant digits that will be shown 1895ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 3.0 1896ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1897ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t getMinimumSignificantDigits() const; 1898ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1899ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1900ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Returns the maximum number of significant digits that will be 1901ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * displayed. This value has no effect unless areSignificantDigitsUsed() 1902ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * returns true. 1903ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return the most significant digits that will be shown 1904ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 3.0 1905ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1906ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t getMaximumSignificantDigits() const; 1907ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1908ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1909ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Sets the minimum number of significant digits that will be 1910ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * displayed. If <code>min</code> is less than one then it is set 1911ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * to one. If the maximum significant digits count is less than 191259d709d503bab6e2b61931737e662dd293b40578ccornelius * <code>min</code>, then it is set to <code>min</code>. 191359d709d503bab6e2b61931737e662dd293b40578ccornelius * This function also enables the use of significant digits 191459d709d503bab6e2b61931737e662dd293b40578ccornelius * by this formatter - areSignificantDigitsUsed() will return TRUE. 191559d709d503bab6e2b61931737e662dd293b40578ccornelius * @see #areSignificantDigitsUsed 191650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param min the fewest significant digits to be shown 1917ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 3.0 1918ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1919ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void setMinimumSignificantDigits(int32_t min); 1920ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1921ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1922ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Sets the maximum number of significant digits that will be 1923ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * displayed. If <code>max</code> is less than one then it is set 1924ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * to one. If the minimum significant digits count is greater 1925ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * than <code>max</code>, then it is set to <code>max</code>. 192659d709d503bab6e2b61931737e662dd293b40578ccornelius * This function also enables the use of significant digits 192759d709d503bab6e2b61931737e662dd293b40578ccornelius * by this formatter - areSignificantDigitsUsed() will return TRUE. 192859d709d503bab6e2b61931737e662dd293b40578ccornelius * @see #areSignificantDigitsUsed 192950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param max the most significant digits to be shown 1930ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 3.0 1931ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1932ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void setMaximumSignificantDigits(int32_t max); 1933ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1934ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1935ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Returns true if significant digits are in use, or false if 1936ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * integer and fraction digit counts are in use. 1937ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return true if significant digits are in use 1938ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 3.0 1939ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1940ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UBool areSignificantDigitsUsed() const; 1941ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1942ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1943ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Sets whether significant digits are in use, or integer and 1944ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * fraction digit counts are in use. 1945ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param useSignificantDigits true to use significant digits, or 1946ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * false to use integer and fraction digit counts 1947ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 3.0 1948ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1949ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void setSignificantDigitsUsed(UBool useSignificantDigits); 1950ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1951ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru public: 1952ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1953ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Sets the currency used to display currency 1954ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * amounts. This takes effect immediately, if this format is a 1955ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * currency format. If this format is not a currency format, then 1956ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * the currency is used if and when this object becomes a 1957ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * currency format through the application of a new pattern. 1958ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param theCurrency a 3-letter ISO code indicating new currency 1959ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * to use. It need not be null-terminated. May be the empty 1960ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * string or NULL to indicate no currency. 1961ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param ec input-output error code 1962ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 3.0 1963ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1964ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void setCurrency(const UChar* theCurrency, UErrorCode& ec); 1965ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1966ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1967ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Sets the currency used to display currency amounts. See 1968ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * setCurrency(const UChar*, UErrorCode&). 1969ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @deprecated ICU 3.0. Use setCurrency(const UChar*, UErrorCode&). 1970ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1971ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void setCurrency(const UChar* theCurrency); 1972ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1973f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius /** 1974f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius * Sets the <tt>Currency Context</tt> object used to display currency. 1975f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius * This takes effect immediately, if this format is a 19768de051c3d18a56cc126f0f44e368495a52f9148cFredrik Roubert * currency format. 19778de051c3d18a56cc126f0f44e368495a52f9148cFredrik Roubert * @param currencyContext new currency context object to use. 1978c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * @stable ICU 54 1979f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius */ 1980f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius void setCurrencyUsage(UCurrencyUsage newUsage, UErrorCode* ec); 1981f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius 1982f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius /** 1983f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius * Returns the <tt>Currency Context</tt> object used to display currency 1984c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * @stable ICU 54 1985f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius */ 1986f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius UCurrencyUsage getCurrencyUsage() const; 1987f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius 1988f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius 1989f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius#ifndef U_HIDE_DEPRECATED_API 1990ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1991ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * The resource tags we use to retrieve decimal format data from 1992ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * locale resource bundles. 1993ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @deprecated ICU 3.4. This string has no public purpose. Please don't use it. 1994ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1995ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static const char fgNumberPatterns[]; 1996f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius#endif /* U_HIDE_DEPRECATED_API */ 1997ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 199859d709d503bab6e2b61931737e662dd293b40578ccornelius#ifndef U_HIDE_INTERNAL_API 199959d709d503bab6e2b61931737e662dd293b40578ccornelius /** 200059d709d503bab6e2b61931737e662dd293b40578ccornelius * Get a FixedDecimal corresponding to a double as it would be 200159d709d503bab6e2b61931737e662dd293b40578ccornelius * formatted by this DecimalFormat. 200259d709d503bab6e2b61931737e662dd293b40578ccornelius * Internal, not intended for public use. 200359d709d503bab6e2b61931737e662dd293b40578ccornelius * @internal 200459d709d503bab6e2b61931737e662dd293b40578ccornelius */ 200559d709d503bab6e2b61931737e662dd293b40578ccornelius FixedDecimal getFixedDecimal(double number, UErrorCode &status) const; 200659d709d503bab6e2b61931737e662dd293b40578ccornelius 200759d709d503bab6e2b61931737e662dd293b40578ccornelius /** 200859d709d503bab6e2b61931737e662dd293b40578ccornelius * Get a FixedDecimal corresponding to a formattable as it would be 200959d709d503bab6e2b61931737e662dd293b40578ccornelius * formatted by this DecimalFormat. 201059d709d503bab6e2b61931737e662dd293b40578ccornelius * Internal, not intended for public use. 201159d709d503bab6e2b61931737e662dd293b40578ccornelius * @internal 201259d709d503bab6e2b61931737e662dd293b40578ccornelius */ 201359d709d503bab6e2b61931737e662dd293b40578ccornelius FixedDecimal getFixedDecimal(const Formattable &number, UErrorCode &status) const; 201459d709d503bab6e2b61931737e662dd293b40578ccornelius 201559d709d503bab6e2b61931737e662dd293b40578ccornelius /** 201659d709d503bab6e2b61931737e662dd293b40578ccornelius * Get a FixedDecimal corresponding to a DigitList as it would be 201759d709d503bab6e2b61931737e662dd293b40578ccornelius * formatted by this DecimalFormat. Note: the DigitList may be modified. 201859d709d503bab6e2b61931737e662dd293b40578ccornelius * Internal, not intended for public use. 201959d709d503bab6e2b61931737e662dd293b40578ccornelius * @internal 202059d709d503bab6e2b61931737e662dd293b40578ccornelius */ 202159d709d503bab6e2b61931737e662dd293b40578ccornelius FixedDecimal getFixedDecimal(DigitList &number, UErrorCode &status) const; 2022c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert 2023c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert /** 2024c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * Get a VisibleDigitsWithExponent corresponding to a double 2025c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * as it would be formatted by this DecimalFormat. 2026c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * Internal, not intended for public use. 2027c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * @internal 2028c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert */ 2029c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert VisibleDigitsWithExponent &initVisibleDigitsWithExponent( 2030c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert double number, 2031c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert VisibleDigitsWithExponent &digits, 2032c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert UErrorCode &status) const; 2033c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert 2034c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert /** 2035c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * Get a VisibleDigitsWithExponent corresponding to a formattable 2036c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * as it would be formatted by this DecimalFormat. 2037c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * Internal, not intended for public use. 2038c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * @internal 2039c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert */ 2040c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert VisibleDigitsWithExponent &initVisibleDigitsWithExponent( 2041c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert const Formattable &number, 2042c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert VisibleDigitsWithExponent &digits, 2043c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert UErrorCode &status) const; 2044c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert 2045c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert /** 2046c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * Get a VisibleDigitsWithExponent corresponding to a DigitList 2047c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * as it would be formatted by this DecimalFormat. 2048c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * Note: the DigitList may be modified. 2049c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * Internal, not intended for public use. 2050c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * @internal 2051c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert */ 2052c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert VisibleDigitsWithExponent &initVisibleDigitsWithExponent( 2053c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert DigitList &number, 2054c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert VisibleDigitsWithExponent &digits, 2055c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert UErrorCode &status) const; 2056c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert 205759d709d503bab6e2b61931737e662dd293b40578ccornelius#endif /* U_HIDE_INTERNAL_API */ 205859d709d503bab6e2b61931737e662dd293b40578ccornelius 2059ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic: 2060ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 2061ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 2062ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Return the class ID for this class. This is useful only for 2063ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * comparing to a return value from getDynamicClassID(). For example: 2064ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <pre> 2065ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * . Base* polymorphic_pointer = createPolymorphicObject(); 2066ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * . if (polymorphic_pointer->getDynamicClassID() == 2067ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * . Derived::getStaticClassID()) ... 2068ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * </pre> 2069ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return The class ID for all objects of this class. 2070ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 2071ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 2072ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static UClassID U_EXPORT2 getStaticClassID(void); 2073ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 2074ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 2075ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. 2076ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * This method is to implement a simple version of RTTI, since not all 2077ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * C++ compilers support genuine RTTI. Polymorphic operator==() and 2078ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * clone() methods call this method. 2079ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 2080ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return The class ID for this object. All objects of a 2081ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * given class have the same class ID. Objects of 2082ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * other classes have different class IDs. 2083ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 2084ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 2085ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual UClassID getDynamicClassID(void) const; 2086ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 2087ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprivate: 208885bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho 2089ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru DecimalFormat(); // default constructor not implemented 2090ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 209150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho /** 209259d709d503bab6e2b61931737e662dd293b40578ccornelius * Initialize all fields of a new DecimalFormatter to a safe default value. 209350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Common code for use by constructors. 209450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho */ 209559d709d503bab6e2b61931737e662dd293b40578ccornelius void init(); 2096ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 2097ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 2098ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Do real work of constructing a new DecimalFormat. 2099ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 210059d709d503bab6e2b61931737e662dd293b40578ccornelius void construct(UErrorCode& status, 2101ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UParseError& parseErr, 2102ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const UnicodeString* pattern = 0, 2103ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru DecimalFormatSymbols* symbolsToAdopt = 0 2104ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ); 2105ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 210664339d36f8bd4db5025fe2988eda22b491a9219cFredrik Roubert void handleCurrencySignInPattern(UErrorCode& status); 210764339d36f8bd4db5025fe2988eda22b491a9219cFredrik Roubert 2108ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void parse(const UnicodeString& text, 2109ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru Formattable& result, 2110ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ParsePosition& pos, 2111103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius UChar* currency) const; 2112ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 2113ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru enum { 2114ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru fgStatusInfinite, 2115ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru fgStatusLength // Leave last in list. 2116ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } StatusFlags; 2117ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 211850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho UBool subparse(const UnicodeString& text, 211985bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho const UnicodeString* negPrefix, 212085bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho const UnicodeString* negSuffix, 212185bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho const UnicodeString* posPrefix, 212285bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho const UnicodeString* posSuffix, 212359d709d503bab6e2b61931737e662dd293b40578ccornelius UBool complexCurrencyParsing, 212485bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho int8_t type, 212585bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho ParsePosition& parsePosition, 2126ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru DigitList& digits, UBool* status, 2127ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UChar* currency) const; 2128ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 212985bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho // Mixed style parsing for currency. 213050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho // It parses against the current currency pattern 213185bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho // using complex affix comparison 213285bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho // parses against the currency plural patterns using complex affix comparison, 213385bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho // and parses against the current pattern using simple affix comparison. 213450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho UBool parseForCurrency(const UnicodeString& text, 213585bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho ParsePosition& parsePosition, 213685bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho DigitList& digits, 213785bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho UBool* status, 213885bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho UChar* currency) const; 213985bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho 2140ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t skipPadding(const UnicodeString& text, int32_t position) const; 2141ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 2142ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t compareAffix(const UnicodeString& input, 2143ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t pos, 2144ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UBool isNegative, 2145ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UBool isPrefix, 214685bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho const UnicodeString* affixPat, 214759d709d503bab6e2b61931737e662dd293b40578ccornelius UBool complexCurrencyParsing, 214885bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho int8_t type, 2149ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UChar* currency) const; 215050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 215159d709d503bab6e2b61931737e662dd293b40578ccornelius static UnicodeString& trimMarksFromAffix(const UnicodeString& affix, UnicodeString& trimmedAffix); 215259d709d503bab6e2b61931737e662dd293b40578ccornelius 215359d709d503bab6e2b61931737e662dd293b40578ccornelius UBool equalWithSignCompatibility(UChar32 lhs, UChar32 rhs) const; 215459d709d503bab6e2b61931737e662dd293b40578ccornelius 215559d709d503bab6e2b61931737e662dd293b40578ccornelius int32_t compareSimpleAffix(const UnicodeString& affix, 2156ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const UnicodeString& input, 2157b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho int32_t pos, 215859d709d503bab6e2b61931737e662dd293b40578ccornelius UBool lenient) const; 215950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 2160b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho static int32_t skipPatternWhiteSpace(const UnicodeString& text, int32_t pos); 216150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 2162ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static int32_t skipUWhiteSpace(const UnicodeString& text, int32_t pos); 216350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 216459d709d503bab6e2b61931737e662dd293b40578ccornelius static int32_t skipUWhiteSpaceAndMarks(const UnicodeString& text, int32_t pos); 216559d709d503bab6e2b61931737e662dd293b40578ccornelius 216659d709d503bab6e2b61931737e662dd293b40578ccornelius static int32_t skipBidiMarks(const UnicodeString& text, int32_t pos); 216759d709d503bab6e2b61931737e662dd293b40578ccornelius 2168ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t compareComplexAffix(const UnicodeString& affixPat, 2169ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const UnicodeString& input, 2170ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t pos, 217185bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho int8_t type, 2172ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UChar* currency) const; 2173ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 2174ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static int32_t match(const UnicodeString& text, int32_t pos, UChar32 ch); 2175ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 2176ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static int32_t match(const UnicodeString& text, int32_t pos, const UnicodeString& str); 2177ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 2178b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho static UBool matchSymbol(const UnicodeString &text, int32_t position, int32_t length, const UnicodeString &symbol, 2179b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho UnicodeSet *sset, UChar32 schar); 2180b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho 2181b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho static UBool matchDecimal(UChar32 symbolChar, 2182b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho UBool sawDecimal, UChar32 sawDecimalChar, 2183b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho const UnicodeSet *sset, UChar32 schar); 2184b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho 2185b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho static UBool matchGrouping(UChar32 groupingChar, 2186b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho UBool sawGrouping, UChar32 sawGroupingChar, 2187b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho const UnicodeSet *sset, 2188b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho UChar32 decimalChar, const UnicodeSet *decimalSet, 2189b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho UChar32 schar); 2190b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho 219185bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho // set up currency affix patterns for mix parsing. 219285bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho // The patterns saved here are the affix patterns of default currency 219385bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho // pattern and the unique affix patterns of the plural currency patterns. 219485bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho // Those patterns are used by parseForCurrency(). 219585bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho void setupCurrencyAffixPatterns(UErrorCode& status); 219685bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho 2197f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius // get the currency rounding with respect to currency usage 2198f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius double getCurrencyRounding(const UChar* currency, 2199f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius UErrorCode* ec) const; 22008de051c3d18a56cc126f0f44e368495a52f9148cFredrik Roubert 2201f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius // get the currency fraction with respect to currency usage 2202f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius int getCurrencyFractionDigits(const UChar* currency, 2203f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius UErrorCode* ec) const; 220450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 220585bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho // hashtable operations 220685bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho Hashtable* initHashForAffixPattern(UErrorCode& status); 220785bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho 220885bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho void deleteHashForAffixPattern(); 220985bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho 221085bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho void copyHashForAffixPattern(const Hashtable* source, 221185bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho Hashtable* target, UErrorCode& status); 2212ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 2213c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert DecimalFormatImpl *fImpl; 2214ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 2215ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 2216c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * Constants. 2217ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 2218ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 2219ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 222054dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius EnumSet<UNumberFormatAttribute, 2221fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius UNUM_MAX_NONBOOLEAN_ATTRIBUTE+1, 2222fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius UNUM_LIMIT_BOOLEAN_ATTRIBUTE> 222354dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius fBoolFlags; 222454dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius 2225ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 222685bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho // style is only valid when decimal formatter is constructed by 222785bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho // DecimalFormat(pattern, decimalFormatSymbol, style) 222885bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho int fStyle; 222950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 223085bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho 223185bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho // Affix pattern set for currency. 223285bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho // It is a set of AffixPatternsForCurrency, 223385bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho // each element of the set saves the negative prefix pattern, 223450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho // negative suffix pattern, positive prefix pattern, 223585bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho // and positive suffix pattern of a pattern. 223685bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho // It is used for currency mixed style parsing. 223785bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho // It is actually is a set. 223885bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho // The set contains the default currency pattern from the locale, 223985bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho // and the currency plural patterns. 224085bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho // Since it is a set, it does not contain duplicated items. 224185bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho // For example, if 2 currency plural patterns are the same, only one pattern 224285bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho // is included in the set. When parsing, we do not check whether the plural 224385bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho // count match or not. 224485bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho Hashtable* fAffixPatternsForCurrency; 224585bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho 224685bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho // Information needed for DecimalFormat to format/parse currency plural. 224785bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho CurrencyPluralInfo* fCurrencyPluralInfo; 224885bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho 2249103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#if UCONFIG_HAVE_PARSEALLINPUT 2250103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius UNumberFormatAttributeValue fParseAllInput; 2251103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif 2252103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius 225359d709d503bab6e2b61931737e662dd293b40578ccornelius // Decimal Format Static Sets singleton. 225459d709d503bab6e2b61931737e662dd293b40578ccornelius const DecimalFormatStaticSets *fStaticSets; 22558de051c3d18a56cc126f0f44e368495a52f9148cFredrik Roubert 2256ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprotected: 2257ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 22588393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius#ifndef U_HIDE_INTERNAL_API 22598393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius /** 22608393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius * Rounds a value according to the rules of this object. 22618393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius * @internal 22628393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius */ 22638393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius DigitList& _round(const DigitList& number, DigitList& adjustedNum, UBool& isNegative, UErrorCode& status) const; 22648393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius#endif /* U_HIDE_INTERNAL_API */ 22658393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius 2266ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 2267ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Returns the currency in effect for this formatter. Subclasses 2268ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * should override this method as needed. Unlike getCurrency(), 2269ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * this method should never return "". 2270ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @result output parameter for null-terminated result, which must 2271ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * have a capacity of at least 4 2272ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @internal 2273ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 2274ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void getEffectiveCurrency(UChar* result, UErrorCode& ec) const; 2275ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 227650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho /** number of integer digits 2277ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4 227850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho */ 2279ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static const int32_t kDoubleIntegerDigits; 228050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho /** number of fraction digits 2281ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4 228250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho */ 2283ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static const int32_t kDoubleFractionDigits; 2284ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 2285ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 2286ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * When someone turns on scientific mode, we assume that more than this 2287ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * number of digits is due to flipping from some other mode that didn't 2288ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * restrict the maximum, and so we force 1 integer digit. We don't bother 2289ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * to track and see if someone is using exponential notation with more than 2290ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * this number, it wouldn't make sense anyway, and this is just to make sure 2291ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * that someone turning on scientific mode with default settings doesn't 2292ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * end up with lots of zeroes. 2293ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.8 2294ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 2295ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static const int32_t kMaxScientificIntegerDigits; 2296103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius 2297ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}; 2298ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 2299ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_NAMESPACE_END 2300ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 2301ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif /* #if !UCONFIG_NO_FORMATTING */ 2302ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 2303ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif // _DECIMFMT 2304ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru//eof 2305