X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/73c04bcfe1096173b00431f0cdc742894b15eef0..4388f060552cc537e71e957d32f35e9d75a61233:/icuSources/i18n/unicode/decimfmt.h diff --git a/icuSources/i18n/unicode/decimfmt.h b/icuSources/i18n/unicode/decimfmt.h index 296906fb..2d54306f 100644 --- a/icuSources/i18n/unicode/decimfmt.h +++ b/icuSources/i18n/unicode/decimfmt.h @@ -1,6 +1,6 @@ /* ******************************************************************************** -* Copyright (C) 1997-2006, International Business Machines +* Copyright (C) 1997-2012, International Business Machines * Corporation and others. All Rights Reserved. ******************************************************************************** * @@ -20,26 +20,33 @@ * 07/20/98 stephen Changed documentation ******************************************************************************** */ - + #ifndef DECIMFMT_H #define DECIMFMT_H - + #include "unicode/utypes.h" /** - * \file + * \file * \brief C++ API: Formats decimal numbers. */ - + #if !UCONFIG_NO_FORMATTING #include "unicode/dcfmtsym.h" #include "unicode/numfmt.h" #include "unicode/locid.h" +#include "unicode/fpositer.h" +#include "unicode/stringpiece.h" +#include "unicode/curramt.h" U_NAMESPACE_BEGIN class DigitList; class ChoiceFormat; +class CurrencyPluralInfo; +class Hashtable; +class UnicodeSet; +class FieldPositionHandler; /** * DecimalFormat is a concrete subclass of NumberFormat that formats decimal @@ -47,8 +54,8 @@ class ChoiceFormat; * and format numbers in any locale, including support for Western, Arabic, or * Indic digits. It also supports different flavors of numbers, including * integers ("123"), fixed-point numbers ("123.4"), scientific notation - * ("1.23E4"), percentages ("12%"), and currency amounts ("$123"). All of these - * flavors can be easily localized. + * ("1.23E4"), percentages ("12%"), and currency amounts ("$123", "USD123", + * "123 US dollars"). All of these flavors can be easily localized. * *

To obtain a NumberFormat for a specific locale (including the default * locale) call one of NumberFormat's factory methods such as @@ -62,11 +69,11 @@ class ChoiceFormat; * // Normally we would have a GUI with a menu for this * int32_t locCount; * const Locale* locales = NumberFormat::getAvailableLocales(locCount); - * + * * double myNumber = -1234.56; * UErrorCode success = U_ZERO_ERROR; * NumberFormat* form; - * + * * // Print out a number with the localized number, currency and percent * // format for each locale. * UnicodeString countryName; @@ -95,11 +102,32 @@ class ChoiceFormat; * cout << locales[i].getDisplayName(displayName) << ": " << pattern; * cout << " -> " << form->format(myNumber,str) << endl; * form->parse(form->format(myNumber,str), fmtable, success); - * delete form; + * delete form; * } * } * } * \endcode + *

+ * Another example use createInstance(style) + *

+ *

+ * // Print out a number using the localized number, currency,
+ * // percent, scientific, integer, iso currency, and plural currency
+ * // format for each locale
+ * Locale* locale = new Locale("en", "US");
+ * double myNumber = 1234.56;
+ * UErrorCode success = U_ZERO_ERROR;
+ * UnicodeString str;
+ * Formattable fmtable;
+ * for (int j=NumberFormat::kNumberStyle;
+ *      j<=NumberFormat::kPluralCurrencyStyle;
+ *      ++j) {
+ *     NumberFormat* format = NumberFormat::createInstance(locale, j, success);
+ *     str.remove();
+ *     cout << "format result " << form->format(myNumber, str) << endl;
+ *     format->parse(form->format(myNumber, str), fmtable, success);
+ * }
+ * * *

Patterns * @@ -110,7 +138,7 @@ class ChoiceFormat; * digits. The symbols are stored in a DecimalFormatSymbols * object. When using the NumberFormat factory methods, the * pattern and symbols are read from ICU's locale data. - * + * *

Special Pattern Characters * *

Many characters in a pattern are taken literally; they are matched during @@ -208,6 +236,8 @@ class ChoiceFormat; * No * Currency sign, replaced by currency symbol. If * doubled, replaced by international currency symbol. + * If tripled, replaced by currency plural names, for example, + * "US dollar" or "US dollars" for America. * If present in a pattern, the monetary decimal separator * is used instead of the decimal separator. * @@ -288,7 +318,7 @@ class ChoiceFormat; * * The first subpattern is for positive numbers. The second (optional) * subpattern is for negative numbers. - * + * *

Not indicated in the BNF syntax above: * *